Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/main/java/com/podio/org/OrgAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,6 +140,47 @@ public List<OrganizationMember> getMembers(int orgId) {
new GenericType<List<OrganizationMember>>() {
});
}

/**
* 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<OrganizationMember> 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<List<OrganizationMember>>() { });
}

/**
* 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<OrganizationMember> getMembers(int orgId, MultivaluedMap<String, String> options) {
return getResourceFactory()
.getApiResource("/org/" + orgId + "/member/")
.queryParams(options)
.get(new GenericType<List<OrganizationMember>>() { });
}

/**
* Returns the member data for the given user in the given organization.
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/podio/space/SpaceAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
200 changes: 200 additions & 0 deletions src/main/java/com/podio/space/SpaceMemberAdd.java
Original file line number Diff line number Diff line change
@@ -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<Integer> users;

/**
* The list of profile ids to invite to the space
*/
private List<Integer> profiles;

/**
* The list of mail addresses for new or existing Podio users
*/
private List<String> mails;

/**
* The external contacts to invite
*/
private MultivaluedMap<Integer, String> 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<Integer> getUsers() {
return users;
}

/**
* @param users the users to set
*/
public void setUsers(List<Integer> users) {
this.users = users;
}

/**
* @return the profiles
*/
public List<Integer> getProfiles() {
return profiles;
}

/**
* @param profiles the profiles to set
*/
public void setProfiles(List<Integer> profiles) {
this.profiles = profiles;
}

/**
* @return the mails
*/
public List<String> getMails() {
return mails;
}

/**
* @param mails the mails to set
*/
public void setMails(List<String> mails) {
this.mails = mails;
}

/**
* @return the externalContacts
*/
@JsonProperty("external_contacts")
public MultivaluedMap<Integer, String> getExternalContacts() {
return externalContacts;
}

/**
* @param externalContacts the externalContacts to set
*/
@JsonProperty("external_contacts")
public void setExternalContacts(MultivaluedMap<Integer, String> 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;
}

}
Loading