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

Commit 7d336bd

Browse files
author
Christian Holm
committed
Merge pull request #15 from UseTheSrc/master
Add support for additional parameters available in the "get organization members" API call
2 parents c1316a6 + 33dacca commit 7d336bd

File tree

5 files changed

+459
-6
lines changed

5 files changed

+459
-6
lines changed

src/main/java/com/podio/org/OrgAPI.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.List;
55

66
import javax.ws.rs.core.MediaType;
7+
import javax.ws.rs.core.MultivaluedMap;
78

89
import com.podio.BaseAPI;
910
import com.podio.ResourceFactory;
@@ -139,6 +140,47 @@ public List<OrganizationMember> getMembers(int orgId) {
139140
new GenericType<List<OrganizationMember>>() {
140141
});
141142
}
143+
144+
/**
145+
* Returns the members, both invited and active, of the given organization.
146+
* This method is only available for organization administrators. For users
147+
* only invited, only very limited information will be returned for the user
148+
* and profile.
149+
*
150+
* @param orgId
151+
* The id of the organization
152+
* @param offset
153+
* The offset into the user list
154+
* @param limit
155+
* The number of results to return (max 500)
156+
* @return The list of members on the organization with detailed information
157+
*/
158+
public List<OrganizationMember> getMembers(int orgId, int offset, int limit) {
159+
return getResourceFactory()
160+
.getApiResource("/org/" + orgId + "/member/")
161+
.queryParam("offset", new Integer(offset).toString())
162+
.queryParam("limit", new Integer(limit).toString())
163+
.get(new GenericType<List<OrganizationMember>>() { });
164+
}
165+
166+
/**
167+
* Returns the members, both invited and active, of the given organization.
168+
* This method is only available for organization administrators. For users
169+
* only invited, only very limited information will be returned for the user
170+
* and profile.
171+
*
172+
* @param orgId
173+
* The id of the organization
174+
* @param options
175+
* The parameters for get organization members
176+
* @return The list of members on the organization with detailed information
177+
*/
178+
public List<OrganizationMember> getMembers(int orgId, MultivaluedMap<String, String> options) {
179+
return getResourceFactory()
180+
.getApiResource("/org/" + orgId + "/member/")
181+
.queryParams(options)
182+
.get(new GenericType<List<OrganizationMember>>() { });
183+
}
142184

143185
/**
144186
* Returns the member data for the given user in the given organization.

src/main/java/com/podio/space/SpaceAPI.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ public SpaceWithOrganization getSpaceByURL(String url) {
6666
return getResourceFactory().getApiResource("/space/url")
6767
.queryParam("url", url).get(SpaceWithOrganization.class);
6868
}
69+
70+
/**
71+
* Adds a list of users (either through user_id or email) to the space.
72+
*
73+
* @param spaceId
74+
* The id of the space
75+
* @param spaceMemberAdd
76+
* Information about the user(s) to add
77+
*/
78+
public void addSpaceMembers(int spaceId, SpaceMemberAdd spaceMemberAdd) {
79+
getResourceFactory()
80+
.getApiResource("/space/" + spaceId + "/member/")
81+
.entity(spaceMemberAdd, MediaType.APPLICATION_JSON_TYPE)
82+
.post();
83+
}
6984

7085
/**
7186
* Used to get the details of an active users membership of a space.
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/**
2+
* Podio Java client library
3+
*/
4+
package com.podio.space;
5+
6+
import java.util.List;
7+
8+
import javax.ws.rs.core.MultivaluedMap;
9+
10+
import org.codehaus.jackson.annotate.JsonProperty;
11+
12+
import com.podio.common.Role;
13+
14+
/**
15+
* To match the format of the JSON data sent using the 'add member to space' API call
16+
*
17+
* @author apitman
18+
*/
19+
public class SpaceMemberAdd {
20+
21+
/**
22+
* The role of the new users
23+
*/
24+
private Role role;
25+
26+
/**
27+
* The personalized message to put in the invitation
28+
*/
29+
private String message;
30+
31+
/**
32+
* The list of users ids to invite
33+
*/
34+
private List<Integer> users;
35+
36+
/**
37+
* The list of profile ids to invite to the space
38+
*/
39+
private List<Integer> profiles;
40+
41+
/**
42+
* The list of mail addresses for new or existing Podio users
43+
*/
44+
private List<String> mails;
45+
46+
/**
47+
* The external contacts to invite
48+
*/
49+
private MultivaluedMap<Integer, String> externalContacts;
50+
51+
/**
52+
* Optionally specify "item" to indicate invite to a specific item
53+
*/
54+
private String contextRefType;
55+
56+
/**
57+
* Must be set to the item id if source_key is set
58+
*/
59+
private int contextRefId;
60+
61+
/**
62+
* A optional custom string indicating where the user was when he/she invited the user(s)
63+
*/
64+
private String inviteContext;
65+
66+
/**
67+
* @return the role
68+
*/
69+
public Role getRole() {
70+
return role;
71+
}
72+
73+
/**
74+
* @param role the role to set
75+
*/
76+
public void setRole(Role role) {
77+
this.role = role;
78+
}
79+
80+
/**
81+
* @return the message
82+
*/
83+
public String getMessage() {
84+
return message;
85+
}
86+
87+
/**
88+
* @param message the message to set
89+
*/
90+
public void setMessage(String message) {
91+
this.message = message;
92+
}
93+
94+
/**
95+
* @return the users
96+
*/
97+
public List<Integer> getUsers() {
98+
return users;
99+
}
100+
101+
/**
102+
* @param users the users to set
103+
*/
104+
public void setUsers(List<Integer> users) {
105+
this.users = users;
106+
}
107+
108+
/**
109+
* @return the profiles
110+
*/
111+
public List<Integer> getProfiles() {
112+
return profiles;
113+
}
114+
115+
/**
116+
* @param profiles the profiles to set
117+
*/
118+
public void setProfiles(List<Integer> profiles) {
119+
this.profiles = profiles;
120+
}
121+
122+
/**
123+
* @return the mails
124+
*/
125+
public List<String> getMails() {
126+
return mails;
127+
}
128+
129+
/**
130+
* @param mails the mails to set
131+
*/
132+
public void setMails(List<String> mails) {
133+
this.mails = mails;
134+
}
135+
136+
/**
137+
* @return the externalContacts
138+
*/
139+
@JsonProperty("external_contacts")
140+
public MultivaluedMap<Integer, String> getExternalContacts() {
141+
return externalContacts;
142+
}
143+
144+
/**
145+
* @param externalContacts the externalContacts to set
146+
*/
147+
@JsonProperty("external_contacts")
148+
public void setExternalContacts(MultivaluedMap<Integer, String> externalContacts) {
149+
this.externalContacts = externalContacts;
150+
}
151+
152+
/**
153+
* @return the contextRefType
154+
*/
155+
@JsonProperty("context_ref_type")
156+
public String getContextRefType() {
157+
return contextRefType;
158+
}
159+
160+
/**
161+
* @param contextRefType the contextRefType to set
162+
*/
163+
@JsonProperty("context_ref_type")
164+
public void setContextRefType(String contextRefType) {
165+
this.contextRefType = contextRefType;
166+
}
167+
168+
/**
169+
* @return the contextRefId
170+
*/
171+
@JsonProperty("context_ref_id")
172+
public int getContextRefId() {
173+
return contextRefId;
174+
}
175+
176+
/**
177+
* @param contextRefId the contextRefId to set
178+
*/
179+
@JsonProperty("context_ref_id")
180+
public void setContextRefId(int contextRefId) {
181+
this.contextRefId = contextRefId;
182+
}
183+
184+
/**
185+
* @return the inviteContext
186+
*/
187+
@JsonProperty("invite_context")
188+
public String getInviteContext() {
189+
return inviteContext;
190+
}
191+
192+
/**
193+
* @param inviteContext the inviteContext to set
194+
*/
195+
@JsonProperty("invite_context")
196+
public void setInviteContext(String inviteContext) {
197+
this.inviteContext = inviteContext;
198+
}
199+
200+
}

0 commit comments

Comments
 (0)