Class Contact

java.lang.Object
com.independentsoft.graph.contacts.Contact
All Implemented Interfaces:
ICreatable, IUpdatable

public class Contact extends Object implements ICreatable, IUpdatable
Represents a personal contact in Microsoft Graph.

The Contact resource represents an entry in a user's personal contact folder. Contacts store information about people and organizations including names, email addresses, phone numbers, physical addresses, and other personal details.

Contacts support:

  • Multiple email addresses, phone numbers, and physical addresses
  • Personal information (birthday, anniversary, children, etc.)
  • Professional information (job title, company, manager, etc.)
  • Social information (IM addresses, websites, nicknames)
  • Notes and custom categorization
  • Integration with contact folders

Example usage:

 GraphClient client = new GraphClient();
 // ... configure authentication ...
 
 // Create a new contact
 Contact contact = new Contact();
 contact.setGivenName("John");
 contact.setSurname("Doe");
 contact.setDisplayName("John Doe");
 contact.setJobTitle("Software Engineer");
 contact.setCompanyName("Contoso Ltd.");
 
 // Add email address
 EmailAddress email = new EmailAddress();
 email.setAddress("john.doe@example.com");
 email.setName("John Doe");
 contact.getEmailAddresses().add(email);
 
 // Add phone number
 Phone phone = new Phone();
 phone.setNumber("+1-555-0123");
 phone.setType(PhoneType.MOBILE);
 contact.getPhones().add(phone);
 
 // Create the contact
 Contact createdContact = client.createContact(contact);
 
Since:
1.0
See Also:
contact resource type, Create contact, Update contact
  • Constructor Details

    • Contact

      public Contact()
    • Contact

      public Contact(JsonObject jsonObject)
  • Method Details

    • toCreateJson

      public String toCreateJson()
      Description copied from interface: ICreatable
      Converts this object to its JSON representation for creation.

      This method generates a JSON string containing all properties needed to create a new instance of this resource in Microsoft Graph. Only properties appropriate for creation should be included (e.g., excluding read-only properties like ID, createdTime, etc.).

      Specified by:
      toCreateJson in interface ICreatable
      Returns:
      JSON string representation for creating this resource
    • toUpdateJson

      public String toUpdateJson()
      Description copied from interface: IUpdatable
      Converts this object to its JSON representation for update.

      This method generates a JSON string containing all modified properties that should be updated in Microsoft Graph. Only writeable properties with non-null values are typically included.

      Specified by:
      toUpdateJson in interface IUpdatable
      Returns:
      JSON string representation for updating this resource
    • toUpdateJson

      public String toUpdateJson(List<String> propertyNames)
      Description copied from interface: IUpdatable
      Converts this object to JSON for update with specific properties.

      This method generates a JSON string containing only the specified properties. This enables partial updates where only certain fields need to be modified, reducing payload size and avoiding unintended changes to other properties.

      Specified by:
      toUpdateJson in interface IUpdatable
      Parameters:
      propertyNames - List of property names to include in the JSON. If null or empty, all modified properties are included.
      Returns:
      JSON string representation for updating specific properties
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getId

      public String getId()
    • setId

      public void setId(String id)
    • getChangeKey

      public String getChangeKey()
    • getAssistantName

      public String getAssistantName()
    • setAssistantName

      public void setAssistantName(String assistantName)
    • getBirthday

      public Date getBirthday()
    • setId

      public void setId(Date birthday)
    • getCategories

      public List<String> getCategories()
    • getChildren

      public List<String> getChildren()
    • getCompanyName

      public String getCompanyName()
    • setCompanyName

      public void setCompanyName(String companyName)
    • getCreatedTime

      public Date getCreatedTime()
    • getDepartment

      public String getDepartment()
    • setDepartment

      public void setDepartment(String department)
    • getDisplayName

      public String getDisplayName()
    • setDisplayName

      public void setDisplayName(String displayName)
    • getEmailAddresses

      public List<EmailAddress> getEmailAddresses()
    • getFileAs

      public String getFileAs()
    • setFileAs

      public void setFileAs(String fileAs)
    • getFlag

      public FollowupFlag getFlag()
    • setFlag

      public void setFlag(FollowupFlag flag)
    • getGender

      public String getGender()
    • setGender

      public void setGender(String gender)
    • getGeneration

      public String getGeneration()
    • setGeneration

      public void setGeneration(String generation)
    • getGivenName

      public String getGivenName()
    • setGivenName

      public void setGivenName(String givenName)
    • getImAddresses

      public List<String> getImAddresses()
    • getInitials

      public String getInitials()
    • setInitials

      public void setInitials(String initials)
    • getJobTitle

      public String getJobTitle()
    • setJobTitle

      public void setJobTitle(String jobTitle)
    • getLastModifiedTime

      public Date getLastModifiedTime()
    • getManager

      public String getManager()
    • setManager

      public void setManager(String manager)
    • getMiddleName

      public String getMiddleName()
    • setMiddleName

      public void setMiddleName(String middleName)
    • getNickName

      public String getNickName()
    • setNickName

      public void setNickName(String nickName)
    • getOfficeLocation

      public String getOfficeLocation()
    • setOfficeLocation

      public void setOfficeLocation(String officeLocation)
    • getParentFolderId

      public String getParentFolderId()
    • setParentFolderId

      public void setParentFolderId(String parentFolderId)
    • getPersonalNotes

      public String getPersonalNotes()
    • setPersonalNotes

      public void setPersonalNotes(String personalNotes)
    • getPostalAddresses

      public List<PhysicalAddress> getPostalAddresses()
    • getPhones

      public List<Phone> getPhones()
    • getWebsites

      public List<Website> getWebsites()
    • getProfession

      public String getProfession()
    • setProfession

      public void setProfession(String profession)
    • getSpouseName

      public String getSpouseName()
    • setSpouseName

      public void setSpouseName(String spouseName)
    • getSurname

      public String getSurname()
    • setSurname

      public void setSurname(String surname)
    • getTitle

      public String getTitle()
    • setTitle

      public void setTitle(String title)
    • getWeddingAnniversary

      public String getWeddingAnniversary()
    • setWeddingAnniversary

      public void setWeddingAnniversary(String weddingAnniversary)
    • getYomiCompanyName

      public String getYomiCompanyName()
    • setYomiCompanyName

      public void setYomiCompanyName(String yomiCompanyName)
    • getYomiGivenName

      public String getYomiGivenName()
    • setYomiGivenName

      public void setYomiGivenName(String yomiGivenName)
    • getYomiSurname

      public String getYomiSurname()
    • setYomiSurname

      public void setYomiSurname(String yomiSurname)