From 0dbebea5b944a0779ac24f7e80e58499b57823e8 Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Tue, 18 Nov 2014 15:31:44 -0500 Subject: [PATCH 1/2] Added SpaceMemberV2 class to package com.podio.space, added overloaded method getActiveMembersV2 to class SpaceAPI --- src/main/java/com/podio/space/SpaceAPI.java | 36 +++++++ .../java/com/podio/space/SpaceMemberV2.java | 96 +++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 src/main/java/com/podio/space/SpaceMemberV2.java diff --git a/src/main/java/com/podio/space/SpaceAPI.java b/src/main/java/com/podio/space/SpaceAPI.java index 897f7c1..2084b81 100644 --- a/src/main/java/com/podio/space/SpaceAPI.java +++ b/src/main/java/com/podio/space/SpaceAPI.java @@ -3,6 +3,7 @@ import java.util.List; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import com.podio.BaseAPI; import com.podio.ResourceFactory; @@ -125,6 +126,41 @@ public List getActiveMembers(int spaceId) { new GenericType>() { }); } + + /** + * Returns the active members of the given space ("v2"). + * + * @param spaceId + * The id of the space + * @param offset + * The offset into the user list + * @param limit + * The number of results to return (max 500) + * @return The active members of the space + */ + public List getActiveMembersV2(int spaceId, int offset, int limit) { + return getResourceFactory() + .getApiResource("/space/" + spaceId + "/member/v2/") + .queryParam("offset", new Integer(offset).toString()) + .queryParam("limit", new Integer(limit).toString()) + .get(new GenericType>() { }); + } + + /** + * Returns the active members of the given space ("v2"). + * + * @param spaceId + * The id of the space + * @param options + * The parameters for get space members v2 + * @return The active members of the space + */ + public List getActiveMembersV2(int spaceId, MultivaluedMap options) { + return getResourceFactory() + .getApiResource("/space/" + spaceId + "/member/v2/") + .queryParams(options) + .get(new GenericType>() { }); + } /** * Returns a list of the members that have been removed from the space. diff --git a/src/main/java/com/podio/space/SpaceMemberV2.java b/src/main/java/com/podio/space/SpaceMemberV2.java new file mode 100644 index 0000000..88bbf74 --- /dev/null +++ b/src/main/java/com/podio/space/SpaceMemberV2.java @@ -0,0 +1,96 @@ +/** + * Podio Java library + */ +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.Role; +import com.podio.contact.Profile; + +/** + * To match the data returned by the "get space members v2" API call + * + * @author apitman + */ +public class SpaceMemberV2 { + + /** + * Employee or external user + */ + private boolean employee; + + /** + * The member of the space + */ + private Profile profile; + + /** + * The number of grants given to the user on the space + */ + private int grants; + + /** + * The role that the member has + */ + private Role role; + + /** + * @return the employee + */ + public boolean isEmployee() { + return employee; + } + + /** + * @param employee the employee to set + */ + @JsonProperty("employee") + public void setEmployee(boolean employee) { + this.employee = employee; + } + + /** + * @return the profile + */ + public Profile getProfile() { + return profile; + } + + /** + * @param profile the profile to set + */ + @JsonProperty("profile") + public void setUser(Profile profile) { + this.profile = profile; + } + + /** + * @return the grants + */ + public int getGrants() { + return grants; + } + + /** + * @param grants the grants to set + */ + @JsonProperty("grants") + public void setGrants(int grants) { + this.grants = grants; + } + + /** + * @return the role + */ + public Role getRole() { + return role; + } + + /** + * @param role the role to set + */ + public void setRole(Role role) { + this.role = role; + } +} From 75cfd0bc7aa396e9f08131de3f78fe8f785f2269 Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Tue, 18 Nov 2014 15:51:54 -0500 Subject: [PATCH 2/2] Corrected setter method setUser -> setProfile --- src/main/java/com/podio/space/SpaceMemberV2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/podio/space/SpaceMemberV2.java b/src/main/java/com/podio/space/SpaceMemberV2.java index 88bbf74..c6b9cf9 100644 --- a/src/main/java/com/podio/space/SpaceMemberV2.java +++ b/src/main/java/com/podio/space/SpaceMemberV2.java @@ -61,7 +61,7 @@ public Profile getProfile() { * @param profile the profile to set */ @JsonProperty("profile") - public void setUser(Profile profile) { + public void setProfile(Profile profile) { this.profile = profile; }