Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.

Commit ba054e5

Browse files
author
Christian Holm
committed
Merge pull request #18 from PetrF0X/master
Added functionality to create a new Space Contact
2 parents 41295b8 + 15fe0aa commit ba054e5

File tree

3 files changed

+361
-0
lines changed

3 files changed

+361
-0
lines changed

src/main/java/com/podio/contact/ContactAPI.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.util.ArrayList;
66
import java.util.List;
77

8+
import javax.ws.rs.core.MediaType;
9+
810
import com.podio.BaseAPI;
911
import com.podio.ResourceFactory;
1012
import com.sun.jersey.api.client.GenericType;
@@ -24,6 +26,24 @@ public ContactAPI(ResourceFactory resourceFactory) {
2426
super(resourceFactory);
2527
}
2628

29+
/**
30+
* Adds a new contact to the given space.
31+
*
32+
* @param spaceId
33+
* The id of the space the contact should be added to
34+
* @param create
35+
* The data for the new contact
36+
* @param silent
37+
* True if the create should be silent, false otherwise
38+
* @return The id of the newly created contact
39+
*/
40+
public int addSpaceContact(int spaceId, ContactCreate create, boolean silent) {
41+
return getResourceFactory().getApiResource("/contact/space/" + spaceId + "/")
42+
.queryParam("silent", silent ? "1" : "0")
43+
.entity(create, MediaType.APPLICATION_JSON_TYPE)
44+
.post(ContactCreateResponse.class).getId();
45+
}
46+
2747
/**
2848
* Returns all the contact details about the user with the given id.
2949
*
Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
package com.podio.contact;
2+
3+
import java.util.Collections;
4+
import java.util.List;
5+
6+
import org.codehaus.jackson.annotate.JsonProperty;
7+
import org.joda.time.LocalDate;
8+
9+
public class ContactCreate {
10+
11+
/**
12+
* The full name
13+
*/
14+
private String name;
15+
16+
/**
17+
* The file id of the avatar
18+
*/
19+
private Integer avatar;
20+
21+
/**
22+
* The birthdate
23+
*/
24+
private LocalDate birthdate;
25+
26+
/**
27+
* The organization or company the person is associated with
28+
*/
29+
private String organization;
30+
31+
/**
32+
* The department of the organization 
33+
*/
34+
private String department;
35+
36+
/**
37+
* The username for Skype 
38+
*/
39+
private String skype;
40+
41+
/**
42+
* Short text about the person
43+
*/
44+
private String about;
45+
46+
/**
47+
* The address where the person lives or work 
48+
*/
49+
private List<String> addresses;
50+
51+
/**
52+
* The zip code of the address 
53+
*/
54+
private String zip;
55+
56+
/**
57+
* The name of the city
58+
*/
59+
private String city;
60+
61+
/**
62+
* The name of the state, only applicable in some countries
63+
*/
64+
private String state;
65+
66+
/**
67+
* The name of the country 
68+
*/
69+
private String country;
70+
71+
/**
72+
* The location of the person
73+
*/
74+
private List<String> locations;
75+
76+
/**
77+
* Email address
78+
*/
79+
private List<String> mails;
80+
81+
/**
82+
* The phone number 
83+
*/
84+
private List<String> phones;
85+
86+
/**
87+
* The persons title, usually the work title
88+
*/
89+
private List<String> titles;
90+
91+
/**
92+
* The full URL of the users LinkedIn profile
93+
*/
94+
private String linkedin;
95+
96+
/**
97+
* The name of the users Twitter profile
98+
*/
99+
private String twitter;
100+
101+
/**
102+
* An URL to the persons homepage or the homepage of the company 
103+
*/
104+
private List<String> urls;
105+
106+
/**
107+
* The skill of the user
108+
*/
109+
private List<String> skills;
110+
111+
public ContactCreate(String name) {
112+
this(name, null, null, null, null, null, null, Collections.<String>emptyList(),
113+
null, null, null, null, Collections.<String>emptyList(),
114+
Collections.<String>emptyList(), Collections.<String>emptyList(),
115+
Collections.<String>emptyList(), null, null,
116+
Collections.<String>emptyList(), Collections.<String>emptyList());
117+
}
118+
119+
public ContactCreate(String name, Integer avatar, LocalDate birthdate,
120+
String organization, String department, String skype, String about,
121+
List<String> addresses, String zip, String city, String state,
122+
String country, List<String> locations, List<String> mails,
123+
List<String> phones, List<String> titles, String linkedin,
124+
String twitter, List<String> urls, List<String> skills) {
125+
super();
126+
127+
this.name = name;
128+
this.avatar = avatar;
129+
this.birthdate = birthdate;
130+
this.organization = organization;
131+
this.department = department;
132+
this.skype = skype;
133+
this.about = about;
134+
this.addresses = addresses;
135+
this.zip = zip;
136+
this.city = city;
137+
this.state = state;
138+
this.country = country;
139+
this.locations = locations;
140+
this.mails = mails;
141+
this.phones = phones;
142+
this.titles = titles;
143+
this.linkedin = linkedin;
144+
this.twitter = twitter;
145+
this.urls = urls;
146+
this.skills = skills;
147+
}
148+
149+
public String getName() {
150+
return name;
151+
}
152+
153+
public void setName(String name) {
154+
this.name = name;
155+
}
156+
157+
public Integer getAvatar() {
158+
return avatar;
159+
}
160+
161+
public void setAvatar(Integer avatar) {
162+
this.avatar = avatar;
163+
}
164+
165+
public LocalDate getBirthdate() {
166+
return birthdate;
167+
}
168+
169+
public void setBirthdate(LocalDate birthdate) {
170+
this.birthdate = birthdate;
171+
}
172+
173+
public String getOrganization() {
174+
return organization;
175+
}
176+
177+
public void setOrganization(String organization) {
178+
this.organization = organization;
179+
}
180+
181+
public String getDepartment() {
182+
return department;
183+
}
184+
185+
public void setDepartment(String department) {
186+
this.department = department;
187+
}
188+
189+
public String getSkype() {
190+
return skype;
191+
}
192+
193+
public void setSkype(String skype) {
194+
this.skype = skype;
195+
}
196+
197+
public String getAbout() {
198+
return about;
199+
}
200+
201+
public void setAbout(String about) {
202+
this.about = about;
203+
}
204+
205+
@JsonProperty("adress")
206+
public List<String> getAddresses() {
207+
return addresses;
208+
}
209+
210+
@JsonProperty("adress")
211+
public void setAddresses(List<String> addresses) {
212+
this.addresses = addresses;
213+
}
214+
215+
public String getZip() {
216+
return zip;
217+
}
218+
219+
public void setZip(String zip) {
220+
this.zip = zip;
221+
}
222+
223+
public String getCity() {
224+
return city;
225+
}
226+
227+
public void setCity(String city) {
228+
this.city = city;
229+
}
230+
231+
public String getState() {
232+
return state;
233+
}
234+
235+
public void setState(String state) {
236+
this.state = state;
237+
}
238+
239+
public String getCountry() {
240+
return country;
241+
}
242+
243+
public void setCountry(String country) {
244+
this.country = country;
245+
}
246+
247+
@JsonProperty("location")
248+
public List<String> getLocations() {
249+
return locations;
250+
}
251+
252+
@JsonProperty("location")
253+
public void setLocations(List<String> locations) {
254+
this.locations = locations;
255+
}
256+
257+
@JsonProperty("mail")
258+
public List<String> getMails() {
259+
return mails;
260+
}
261+
262+
@JsonProperty("mail")
263+
public void setMails(List<String> mails) {
264+
this.mails = mails;
265+
}
266+
267+
@JsonProperty("phone")
268+
public List<String> getPhones() {
269+
return phones;
270+
}
271+
272+
@JsonProperty("phone")
273+
public void setPhones(List<String> phones) {
274+
this.phones = phones;
275+
}
276+
277+
@JsonProperty("title")
278+
public List<String> getTitles() {
279+
return titles;
280+
}
281+
282+
@JsonProperty("title")
283+
public void setTitles(List<String> titles) {
284+
this.titles = titles;
285+
}
286+
287+
public String getLinkedin() {
288+
return linkedin;
289+
}
290+
291+
public void setLinkedin(String linkedin) {
292+
this.linkedin = linkedin;
293+
}
294+
295+
public String getTwitter() {
296+
return twitter;
297+
}
298+
299+
public void setTwitter(String twitter) {
300+
this.twitter = twitter;
301+
}
302+
303+
@JsonProperty("url")
304+
public List<String> getUrls() {
305+
return urls;
306+
}
307+
308+
@JsonProperty("url")
309+
public void setUrls(List<String> urls) {
310+
this.urls = urls;
311+
}
312+
313+
@JsonProperty("skill")
314+
public List<String> getSkills() {
315+
return skills;
316+
}
317+
318+
@JsonProperty("skill")
319+
public void setSkills(List<String> skills) {
320+
this.skills = skills;
321+
}
322+
323+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.podio.contact;
2+
3+
import org.codehaus.jackson.annotate.JsonProperty;
4+
5+
public class ContactCreateResponse {
6+
7+
private int id;
8+
9+
public int getId() {
10+
return id;
11+
}
12+
13+
@JsonProperty("profile_id")
14+
public void setId(int id) {
15+
this.id = id;
16+
}
17+
18+
}

0 commit comments

Comments
 (0)