diff --git a/src/main/java/com/podio/contact/ContactAPI.java b/src/main/java/com/podio/contact/ContactAPI.java index 2a3f1e3..edf95a0 100644 --- a/src/main/java/com/podio/contact/ContactAPI.java +++ b/src/main/java/com/podio/contact/ContactAPI.java @@ -44,6 +44,41 @@ public int addSpaceContact(int spaceId, ContactCreate create, boolean silent) { .post(ContactCreateResponse.class).getId(); } + /** + * Updates the entire space contact. Only fields which have values specified + * will be updated. To delete the contents of a field, pass an empty array + * for the value. + * + * @param profileId + * The id of the space contact to be updated + * @param update + * The data for the update + * @param silent + * True if the update should be silent, false otherwise + * @param hook + * True if hooks should be executed for the change, false otherwise + */ + public void updateSpaceContact(int profileId, ContactUpdate update, boolean silent, boolean hook) { + getResourceFactory().getApiResource("/contact/" + profileId) + .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") + .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Deletes a space contact. + * + * @param profileId + * The id of the space contact to be deleted + * @param silent + * True if the deletion should be silent, false otherwise + */ + public void deleteSpaceContact(int profileId, boolean silent) { + getResourceFactory().getApiResource("/contact/" + profileId) + .queryParam("silent", silent ? "1" : "0") + .delete(); + } + /** * Returns all the contact details about the user with the given id. * diff --git a/src/main/java/com/podio/contact/ContactUpdate.java b/src/main/java/com/podio/contact/ContactUpdate.java new file mode 100644 index 0000000..3d70fa9 --- /dev/null +++ b/src/main/java/com/podio/contact/ContactUpdate.java @@ -0,0 +1,323 @@ +package com.podio.contact; + +import java.util.Collections; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.LocalDate; + +public class ContactUpdate { + + /** + * The full name + */ + private String name; + + /** + * The file id of the avatar + */ + private Integer avatar; + + /** + * The birthdate + */ + private LocalDate birthdate; + + /** + * The organization or company the person is associated with + */ + private String organization; + + /** + * The department of the organization  + */ + private String department; + + /** + * The username for Skype  + */ + private String skype; + + /** + * Short text about the person + */ + private String about; + + /** + * The address where the person lives or work  + */ + private List addresses; + + /** + * The zip code of the address  + */ + private String zip; + + /** + * The name of the city + */ + private String city; + + /** + * The name of the state, only applicable in some countries + */ + private String state; + + /** + * The name of the country  + */ + private String country; + + /** + * The location of the person + */ + private List locations; + + /** + * Email address + */ + private List mails; + + /** + * The phone number  + */ + private List phones; + + /** + * The persons title, usually the work title + */ + private List titles; + + /** + * The full URL of the users LinkedIn profile + */ + private String linkedin; + + /** + * The name of the users Twitter profile + */ + private String twitter; + + /** + * An URL to the persons homepage or the homepage of the company  + */ + private List urls; + + /** + * The skill of the user + */ + private List skills; + + public ContactUpdate() { + this(null, null, null, null, null, null, null, Collections.emptyList(), + null, null, null, null, Collections.emptyList(), + Collections.emptyList(), Collections.emptyList(), + Collections.emptyList(), null, null, + Collections.emptyList(), Collections.emptyList()); + } + + public ContactUpdate(String name, Integer avatar, LocalDate birthdate, + String organization, String department, String skype, String about, + List addresses, String zip, String city, String state, + String country, List locations, List mails, + List phones, List titles, String linkedin, + String twitter, List urls, List skills) { + super(); + + this.name = name; + this.avatar = avatar; + this.birthdate = birthdate; + this.organization = organization; + this.department = department; + this.skype = skype; + this.about = about; + this.addresses = addresses; + this.zip = zip; + this.city = city; + this.state = state; + this.country = country; + this.locations = locations; + this.mails = mails; + this.phones = phones; + this.titles = titles; + this.linkedin = linkedin; + this.twitter = twitter; + this.urls = urls; + this.skills = skills; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAvatar() { + return avatar; + } + + public void setAvatar(Integer avatar) { + this.avatar = avatar; + } + + public LocalDate getBirthdate() { + return birthdate; + } + + public void setBirthdate(LocalDate birthdate) { + this.birthdate = birthdate; + } + + public String getOrganization() { + return organization; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getSkype() { + return skype; + } + + public void setSkype(String skype) { + this.skype = skype; + } + + public String getAbout() { + return about; + } + + public void setAbout(String about) { + this.about = about; + } + + @JsonProperty("adress") + public List getAddresses() { + return addresses; + } + + @JsonProperty("adress") + public void setAddresses(List addresses) { + this.addresses = addresses; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + @JsonProperty("location") + public List getLocations() { + return locations; + } + + @JsonProperty("location") + public void setLocations(List locations) { + this.locations = locations; + } + + @JsonProperty("mail") + public List getMails() { + return mails; + } + + @JsonProperty("mail") + public void setMails(List mails) { + this.mails = mails; + } + + @JsonProperty("phone") + public List getPhones() { + return phones; + } + + @JsonProperty("phone") + public void setPhones(List phones) { + this.phones = phones; + } + + @JsonProperty("title") + public List getTitles() { + return titles; + } + + @JsonProperty("title") + public void setTitles(List titles) { + this.titles = titles; + } + + public String getLinkedin() { + return linkedin; + } + + public void setLinkedin(String linkedin) { + this.linkedin = linkedin; + } + + public String getTwitter() { + return twitter; + } + + public void setTwitter(String twitter) { + this.twitter = twitter; + } + + @JsonProperty("url") + public List getUrls() { + return urls; + } + + @JsonProperty("url") + public void setUrls(List urls) { + this.urls = urls; + } + + @JsonProperty("skill") + public List getSkills() { + return skills; + } + + @JsonProperty("skill") + public void setSkills(List skills) { + this.skills = skills; + } + +}