From 407f9a5db5134006563d623b3ee8cf0fe676be45 Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Wed, 19 Nov 2014 10:38:17 -0500 Subject: [PATCH 1/8] Overloaded getMembers method in OrgAPI, adding support for additional parameters available in the "get organization members" API call --- src/main/java/com/podio/org/OrgAPI.java | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/java/com/podio/org/OrgAPI.java b/src/main/java/com/podio/org/OrgAPI.java index dea7010..dce0cea 100644 --- a/src/main/java/com/podio/org/OrgAPI.java +++ b/src/main/java/com/podio/org/OrgAPI.java @@ -4,6 +4,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; @@ -139,6 +140,47 @@ public List getMembers(int orgId) { new GenericType>() { }); } + + /** + * Returns the members, both invited and active, of the given organization. + * This method is only available for organization administrators. For users + * only invited, only very limited information will be returned for the user + * and profile. + * + * @param orgId + * The id of the organization + * @param offset + * The offset into the user list + * @param limit + * The number of results to return (max 500) + * @return The list of members on the organization with detailed information + */ + public List getMembers(int orgId, int offset, int limit) { + return getResourceFactory() + .getApiResource("/org/" + orgId + "/member/") + .queryParam("offset", new Integer(offset).toString()) + .queryParam("limit", new Integer(limit).toString()) + .get(new GenericType>() { }); + } + + /** + * Returns the members, both invited and active, of the given organization. + * This method is only available for organization administrators. For users + * only invited, only very limited information will be returned for the user + * and profile. + * + * @param orgId + * The id of the organization + * @param options + * The parameters for get organization members + * @return The list of members on the organization with detailed information + */ + public List getMembers(int orgId, MultivaluedMap options) { + return getResourceFactory() + .getApiResource("/org/" + orgId + "/member/") + .queryParams(options) + .get(new GenericType>() { }); + } /** * Returns the member data for the given user in the given organization. From 5f770c3ccced691daeb6c392731bb62b270ecc57 Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Mon, 24 Nov 2014 12:10:46 -0500 Subject: [PATCH 2/8] Added support for 'hook' parameter for 'create task' API call to TaskAPI method createTask --- src/main/java/com/podio/task/TaskAPI.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/podio/task/TaskAPI.java b/src/main/java/com/podio/task/TaskAPI.java index 2532432..a41aee6 100644 --- a/src/main/java/com/podio/task/TaskAPI.java +++ b/src/main/java/com/podio/task/TaskAPI.java @@ -152,12 +152,30 @@ public void updateText(int taskId, String text) { * * @param task * The data of the task to be created + * @param silent + * Disable notifications * @return The id of the newly created task */ public int createTask(TaskCreate task, boolean silent) { + return createTask(task, silent, true); + } + + /** + * Creates a new task with no reference to other objects. + * + * @param task + * The data of the task to be created + * @param silent + * Disable notifications + * @param hook + * Execute hooks for the change + * @return The id of the newly created task + */ + public int createTask(TaskCreate task, boolean silent, boolean hook) { TaskCreateResponse response = getResourceFactory() .getApiResource("/task/") .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") .entity(task, MediaType.APPLICATION_JSON_TYPE) .post(TaskCreateResponse.class); From ba9019c05b3ffe31d7690792392d8d173e75b65f Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Mon, 24 Nov 2014 12:36:56 -0500 Subject: [PATCH 3/8] Added support for 'hook' parameter for 'create task with reference' API call to TaskAPI method createTaskWithReference --- src/main/java/com/podio/task/TaskAPI.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/com/podio/task/TaskAPI.java b/src/main/java/com/podio/task/TaskAPI.java index a41aee6..72ed120 100644 --- a/src/main/java/com/podio/task/TaskAPI.java +++ b/src/main/java/com/podio/task/TaskAPI.java @@ -189,15 +189,36 @@ public int createTask(TaskCreate task, boolean silent, boolean hook) { * The data of the task to be created * @param reference * The reference to the object the task should be attached to + * @param silent + * Disable notifications * @return The id of the newly created task */ public int createTaskWithReference(TaskCreate task, Reference reference, boolean silent) { + return createTaskWithReference(task, reference, silent, true); + } + + /** + * Creates a new task with a reference to the given object. + * + * @param task + * The data of the task to be created + * @param reference + * The reference to the object the task should be attached to + * @param silent + * Disable notifications + * @param hook + * Execute hooks for the change + * @return The id of the newly created task + */ + public int createTaskWithReference(TaskCreate task, Reference reference, + boolean silent, boolean hook) { return getResourceFactory() .getApiResource( "/task/" + reference.getType().name().toLowerCase() + "/" + reference.getId() + "/") .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") .entity(task, MediaType.APPLICATION_JSON_TYPE) .post(TaskCreateResponse.class).getId(); } From 2c3af9e3a99646f580eac66e96327f08b63e5d02 Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Mon, 24 Nov 2014 16:02:35 -0500 Subject: [PATCH 4/8] Added overloaded method 'getTagsOnOrg' to TagAPI to implement 'get tags on organization' API call --- src/main/java/com/podio/tag/TagAPI.java | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/main/java/com/podio/tag/TagAPI.java b/src/main/java/com/podio/tag/TagAPI.java index e7537f4..ee7611c 100644 --- a/src/main/java/com/podio/tag/TagAPI.java +++ b/src/main/java/com/podio/tag/TagAPI.java @@ -5,11 +5,13 @@ import java.util.List; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import com.podio.BaseAPI; import com.podio.ResourceFactory; import com.podio.common.Reference; import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tags are words or short sentences that are used as metadata for objects. For @@ -105,6 +107,65 @@ public List getTagsOnApp(int appId) { .get(new GenericType>() { }); } + + /** + * Returns the tags on the given org. This includes both items and statuses on + * all spaces in the organization that the user is part of. The tags are first + * limited ordered by their frequency of use, and then returned sorted + * alphabetically. + * + * @param orgId + * The id of the org to return tags from + * @return The list of tags with their count + */ + public List getTagsOnOrg(int orgId) { + return getResourceFactory() + .getApiResource("/tag/org/" + orgId + "/") + .get(new GenericType>() { }); + } + + /** + * Returns the tags on the given org. This includes both items and statuses on + * all spaces in the organization that the user is part of. The tags are first + * limited ordered by their frequency of use, and then returned sorted + * alphabetically. + * + * @param orgId + * The id of the org to return tags from + * @param options + * The options for this operation, including limit on number of tags + * returned and/or text of tag to search for + * @return The list of tags with their count + */ + public List getTagsOnOrg(int orgId, MultivaluedMap options) { + return getResourceFactory() + .getApiResource("/tag/org/" + orgId + "/") + .queryParams(options) + .get(new GenericType>() { }); + } + + /** + * Returns the tags on the given org. This includes both items and statuses on + * all spaces in the organization that the user is part of. The tags are first + * limited ordered by their frequency of use, and then returned sorted + * alphabetically. + * + * @param orgId + * The id of the org to return tags from + * @param limit + * limit on number of tags returned (max 250) + * @param text + * text of tag to search for + * @return The list of tags with their count + */ + public List getTagsOnOrg(int orgId, int limit, String text) { + MultivaluedMap params=new MultivaluedMapImpl(); + params.add("limit", new Integer(limit).toString()); + if ((text != null) && (!text.isEmpty())) { + params.add("text", text); + } + return getTagsOnOrg(orgId, params); + } /** * Returns the tags on the given space. This includes both items and From f05a0a501d738d813c28e0b2fc35ece27684428c Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Mon, 24 Nov 2014 16:21:13 -0500 Subject: [PATCH 5/8] Added method 'getTagsOnOrgWithText' to TagAPI to implement 'get objects on organization with tag' API call --- src/main/java/com/podio/tag/TagAPI.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/podio/tag/TagAPI.java b/src/main/java/com/podio/tag/TagAPI.java index ee7611c..d2541b2 100644 --- a/src/main/java/com/podio/tag/TagAPI.java +++ b/src/main/java/com/podio/tag/TagAPI.java @@ -200,6 +200,24 @@ public List getTagsOnAppWithText(int appId, String text) { .get(new GenericType>() { }); } + + /** + * Returns the objects that are tagged with the given text on the org. The + * objects are returned sorted descending by the time the tag was added. + * + * @param orgId + * The id of the org to search within + * @param text + * The tag to search for + * @return The list of objects in the org that have the given tag + */ + public List getTagsOnOrgWithText(int orgId, String text) { + return getResourceFactory() + .getApiResource("/tag/org/" + orgId + "/search/") + .queryParam("text", text) + .get(new GenericType>() { + }); + } /** * Returns the objects that are tagged with the given text on the space. The From 1dc907d73814221d4ab1c70751fd9573afac9649 Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Mon, 24 Nov 2014 17:10:27 -0500 Subject: [PATCH 6/8] Overloaded getTagsOnApp method in TagAPI to support additional parameters in 'get tags on app' API call --- src/main/java/com/podio/tag/TagAPI.java | 42 +++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/podio/tag/TagAPI.java b/src/main/java/com/podio/tag/TagAPI.java index d2541b2..ea9317e 100644 --- a/src/main/java/com/podio/tag/TagAPI.java +++ b/src/main/java/com/podio/tag/TagAPI.java @@ -104,8 +104,46 @@ public void removeTag(Reference reference, String tag) { */ public List getTagsOnApp(int appId) { return getResourceFactory().getApiResource("/tag/app/" + appId + "/") - .get(new GenericType>() { - }); + .get(new GenericType>() { }); + } + + /** + * Returns the tags on the given app. This includes only items. The tags are + * ordered firstly by the number of uses, secondly by the tag text. + * + * @param appId + * The id of the app to return tags from * + * @param options + * The options for this operation, including limit on number of tags + * returned and/or text of tag to search for + * @return The list of tags with their count + */ + public List getTagsOnApp(int appId, MultivaluedMap options) { + return getResourceFactory() + .getApiResource("/tag/app/" + appId + "/") + .queryParams(options) + .get(new GenericType>() { }); + } + + /** + * Returns the tags on the given app. This includes only items. The tags are + * ordered firstly by the number of uses, secondly by the tag text. + * + * @param appId + * The id of the app to return tags from + * @param limit + * limit on number of tags returned (max 250) + * @param text + * text of tag to search for + * @return The list of tags with their count + */ + public List getTagsOnApp(int appId, int limit, String text) { + MultivaluedMap params=new MultivaluedMapImpl(); + params.add("limit", new Integer(limit).toString()); + if ((text != null) && (!text.isEmpty())) { + params.add("text", text); + } + return getTagsOnApp(appId, params); } /** From 7763fea68daedbbecaa0fde490dcc61122b4f05a Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Mon, 24 Nov 2014 17:34:46 -0500 Subject: [PATCH 7/8] Overloaded getTagsOnSpace method in TagAPI to support additional parameters in 'get tags on space' API call --- src/main/java/com/podio/tag/TagAPI.java | 48 ++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/podio/tag/TagAPI.java b/src/main/java/com/podio/tag/TagAPI.java index ea9317e..dd337b8 100644 --- a/src/main/java/com/podio/tag/TagAPI.java +++ b/src/main/java/com/podio/tag/TagAPI.java @@ -215,10 +215,50 @@ public List getTagsOnOrg(int orgId, int limit, String text) { * @return The list of tags with their count */ public List getTagsOnSpace(int spaceId) { - return getResourceFactory().getApiResource( - "/tag/space/" + spaceId + "/").get( - new GenericType>() { - }); + return getResourceFactory() + .getApiResource("/tag/space/" + spaceId + "/") + .get(new GenericType>() { }); + } + + /** + * Returns the tags on the given space. This includes both items and + * statuses. The tags are ordered firstly by the number of uses, secondly by + * the tag text. + * + * @param spaceId + * The id of the space to return tags from + * @param options + * The options for this operation, including limit on number of tags + * returned and/or text of tag to search for + * @return The list of tags with their count + */ + public List getTagsOnSpace(int spaceId, MultivaluedMap options) { + return getResourceFactory() + .getApiResource("/tag/space/" + spaceId + "/") + .queryParams(options) + .get(new GenericType>() { }); + } + + /** + * Returns the tags on the given space. This includes both items and + * statuses. The tags are ordered firstly by the number of uses, secondly by + * the tag text. + * + * @param spaceId + * The id of the space to return tags from + * @param limit + * limit on number of tags returned (max 250) + * @param text + * text of tag to search for + * @return The list of tags with their count + */ + public List getTagsOnSpace(int spaceId, int limit, String text) { + MultivaluedMap params=new MultivaluedMapImpl(); + params.add("limit", new Integer(limit).toString()); + if ((text != null) && (!text.isEmpty())) { + params.add("text", text); + } + return getTagsOnSpace(spaceId, params); } /** From e051133389586a5a7aa6fbd58ae0f55530ef0d69 Mon Sep 17 00:00:00 2001 From: Andrew Pitman Date: Fri, 28 Nov 2014 17:55:36 -0500 Subject: [PATCH 8/8] Added class SpaceMemberAdd to com.podio.space package, added method addSpaceMembers to SpaceAPI --- src/main/java/com/podio/space/SpaceAPI.java | 15 ++ .../java/com/podio/space/SpaceMemberAdd.java | 200 ++++++++++++++++++ 2 files changed, 215 insertions(+) create mode 100644 src/main/java/com/podio/space/SpaceMemberAdd.java diff --git a/src/main/java/com/podio/space/SpaceAPI.java b/src/main/java/com/podio/space/SpaceAPI.java index 2084b81..e4cbd78 100644 --- a/src/main/java/com/podio/space/SpaceAPI.java +++ b/src/main/java/com/podio/space/SpaceAPI.java @@ -66,6 +66,21 @@ public SpaceWithOrganization getSpaceByURL(String url) { return getResourceFactory().getApiResource("/space/url") .queryParam("url", url).get(SpaceWithOrganization.class); } + + /** + * Adds a list of users (either through user_id or email) to the space. + * + * @param spaceId + * The id of the space + * @param spaceMemberAdd + * Information about the user(s) to add + */ + public void addSpaceMembers(int spaceId, SpaceMemberAdd spaceMemberAdd) { + getResourceFactory() + .getApiResource("/space/" + spaceId + "/member/") + .entity(spaceMemberAdd, MediaType.APPLICATION_JSON_TYPE) + .post(); + } /** * Used to get the details of an active users membership of a space. diff --git a/src/main/java/com/podio/space/SpaceMemberAdd.java b/src/main/java/com/podio/space/SpaceMemberAdd.java new file mode 100644 index 0000000..5f447d3 --- /dev/null +++ b/src/main/java/com/podio/space/SpaceMemberAdd.java @@ -0,0 +1,200 @@ +/** + * Podio Java client library + */ +package com.podio.space; + +import java.util.List; + +import javax.ws.rs.core.MultivaluedMap; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.Role; + +/** + * To match the format of the JSON data sent using the 'add member to space' API call + * + * @author apitman + */ +public class SpaceMemberAdd { + + /** + * The role of the new users + */ + private Role role; + + /** + * The personalized message to put in the invitation + */ + private String message; + + /** + * The list of users ids to invite + */ + private List users; + + /** + * The list of profile ids to invite to the space + */ + private List profiles; + + /** + * The list of mail addresses for new or existing Podio users + */ + private List mails; + + /** + * The external contacts to invite + */ + private MultivaluedMap externalContacts; + + /** + * Optionally specify "item" to indicate invite to a specific item + */ + private String contextRefType; + + /** + * Must be set to the item id if source_key is set + */ + private int contextRefId; + + /** + * A optional custom string indicating where the user was when he/she invited the user(s) + */ + private String inviteContext; + + /** + * @return the role + */ + public Role getRole() { + return role; + } + + /** + * @param role the role to set + */ + public void setRole(Role role) { + this.role = role; + } + + /** + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * @param message the message to set + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * @return the users + */ + public List getUsers() { + return users; + } + + /** + * @param users the users to set + */ + public void setUsers(List users) { + this.users = users; + } + + /** + * @return the profiles + */ + public List getProfiles() { + return profiles; + } + + /** + * @param profiles the profiles to set + */ + public void setProfiles(List profiles) { + this.profiles = profiles; + } + + /** + * @return the mails + */ + public List getMails() { + return mails; + } + + /** + * @param mails the mails to set + */ + public void setMails(List mails) { + this.mails = mails; + } + + /** + * @return the externalContacts + */ + @JsonProperty("external_contacts") + public MultivaluedMap getExternalContacts() { + return externalContacts; + } + + /** + * @param externalContacts the externalContacts to set + */ + @JsonProperty("external_contacts") + public void setExternalContacts(MultivaluedMap externalContacts) { + this.externalContacts = externalContacts; + } + + /** + * @return the contextRefType + */ + @JsonProperty("context_ref_type") + public String getContextRefType() { + return contextRefType; + } + + /** + * @param contextRefType the contextRefType to set + */ + @JsonProperty("context_ref_type") + public void setContextRefType(String contextRefType) { + this.contextRefType = contextRefType; + } + + /** + * @return the contextRefId + */ + @JsonProperty("context_ref_id") + public int getContextRefId() { + return contextRefId; + } + + /** + * @param contextRefId the contextRefId to set + */ + @JsonProperty("context_ref_id") + public void setContextRefId(int contextRefId) { + this.contextRefId = contextRefId; + } + + /** + * @return the inviteContext + */ + @JsonProperty("invite_context") + public String getInviteContext() { + return inviteContext; + } + + /** + * @param inviteContext the inviteContext to set + */ + @JsonProperty("invite_context") + public void setInviteContext(String inviteContext) { + this.inviteContext = inviteContext; + } + +}