diff --git a/.classpath b/.classpath index 2062d39..4a67902 100644 --- a/.classpath +++ b/.classpath @@ -1,8 +1,32 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index ea8c4bf..ec23a61 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -/target +/target +.settings +.classpath +podio-java +.project +.factorypath diff --git a/.project b/.project index cd0f51a..e7a3349 100644 --- a/.project +++ b/.project @@ -1,23 +1,36 @@ - - - podio-java - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - + + + podio-java + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 861406d..4c28b1a 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ -#Wed Dec 22 15:42:05 CET 2010 eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index eacf108..00f1aa1 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,3 @@ -#Fri Oct 22 23:39:37 CEST 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 @@ -10,4 +9,5 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.processAnnotations=enabled org.eclipse.jdt.core.compiler.source=1.6 diff --git a/LICENSE b/LICENSE index d7462bc..1a3ed08 100644 --- a/LICENSE +++ b/LICENSE @@ -1,20 +1,20 @@ -Copyright (c) 2010-2011 Podio - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Copyright (c) 2010-2011 Podio + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.markdown b/README.markdown index 4345e48..cae9013 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,7 @@ -Podio Java API Client ---------------------- - -This is the Java client for the [Podio](http://podio.com) API. Detailed documentation for the API is available on https://developers.podio.com. There you will find details on how to create an API key and use the API. - -An introduction to the Java client is also available at https://developers.podio.com/clients/java +Podio Java API Client +--------------------- + +This is the Java client for the [Podio](http://podio.com) API. Detailed documentation for the API is available on https://developers.podio.com. There you will find details on how to create an API key and use the API. + +An introduction to the Java client is also available at https://developers.podio.com/clients/java \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8cbef39..873e551 100644 --- a/pom.xml +++ b/pom.xml @@ -1,161 +1,169 @@ - - 4.0.0 - - - org.sonatype.oss - oss-parent - 5 - - - com.podio - api - jar - - api - 0.7.10-SNAPSHOT - The official Java wrapper for the Podio API - http://podio.com - - - scm:git:git@github.com:podio/podio-java.git - scm:git:git@github.com:podio/podio-java.git - git@github.com:podio/podio-java.git - - - - - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - - - Hudson - http://hudson.ohoist.com/job/PodioJava/ - - - - MIT - http://creativecommons.org/licenses/MIT/ - - - - - holm - Christian Holm - holm@podio.com - - - - - maven2-repository.dev.java.net - Java.net Repository for Maven - http://download.java.net/maven/2/ - default - - - oss-joda-money - OSS joda money - http://oss.sonatype.org/content/repositories/joda-snapshots/ - - - - UTF-8 - - - - - junit - junit - 4.12 - - - com.sun.jersey - jersey-client - 1.18.3 - - - com.sun.jersey.contribs - jersey-multipart - 1.18.3 - - - com.sun.jersey - jersey-json - 1.18.3 - compile - - - org.eclipse.jetty - jetty-client - 9.2.7.v20150116 - - - org.codehaus.jackson - jackson-jaxrs - 1.9.13 - - - org.codehaus.jackson - jackson-core-asl - 1.9.13 - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.13 - - - org.codehaus.jackson - jackson-xc - 1.9.13 - - - joda-time - joda-time - 2.7 - - - org.joda - joda-money - 0.10.0 - true - - - org.apache.commons - commons-io - 1.3.2 - jar - compile - - - commons-beanutils - commons-beanutils - 1.9.2 - - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.6 - - - html - - - - - - + + 4.0.0 + + + org.sonatype.oss + oss-parent + 5 + + + com.podio + api + jar + + api + 0.7.10-SNAPSHOT + The official Java wrapper for the Podio API + http://podio.com + + + scm:git:git@github.com:podio/podio-java.git + scm:git:git@github.com:podio/podio-java.git + git@github.com:podio/podio-java.git + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.7 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12.4 + + true + + + + + + Hudson + http://hudson.ohoist.com/job/PodioJava/ + + + + MIT + http://creativecommons.org/licenses/MIT/ + + + + + holm + Christian Holm + holm@podio.com + + + + + maven2-repository.dev.java.net + Java.net Repository for Maven + http://download.java.net/maven/2/ + default + + + oss-joda-money + OSS joda money + http://oss.sonatype.org/content/repositories/joda-snapshots/ + + + + UTF-8 + + + + + junit + junit + 4.12 + + + com.sun.jersey + jersey-client + 1.18.3 + + + com.sun.jersey.contribs + jersey-multipart + 1.18.3 + + + com.sun.jersey + jersey-json + 1.18.3 + compile + + + org.eclipse.jetty + jetty-client + 9.2.7.v20150116 + + + org.codehaus.jackson + jackson-jaxrs + 1.9.13 + + + org.codehaus.jackson + jackson-core-asl + 1.9.13 + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.13 + + + org.codehaus.jackson + jackson-xc + 1.9.13 + + + joda-time + joda-time + 2.7 + + + org.joda + joda-money + 0.10.0 + true + + + org.apache.commons + commons-io + 1.3.2 + jar + compile + + + commons-beanutils + commons-beanutils + 1.9.2 + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.6 + + + html + + + + + + diff --git a/src/main/java/com/podio/APIApplicationException.java b/src/main/java/com/podio/APIApplicationException.java index fc2c5ae..e0a5921 100644 --- a/src/main/java/com/podio/APIApplicationException.java +++ b/src/main/java/com/podio/APIApplicationException.java @@ -1,50 +1,50 @@ -package com.podio; - -import java.util.Map; - -import com.sun.jersey.api.client.ClientResponse.Status; - -public class APIApplicationException extends RuntimeException { - - private static final long serialVersionUID = -4533177892434958205L; - - private final Status status; - - private final String error; - - private final String description; - - private final Map parameters; - - public APIApplicationException(Status status, String error, - String description, Map parameters) { - super(); - this.status = status; - this.error = error; - this.description = description; - this.parameters = parameters; - } - - @Override - public String toString() { - return "APIException [status=" + status + ", error=" + error - + ", description=" + description + ", parameters=" + parameters - + "]"; - } - - public Status getStatus() { - return status; - } - - public String getError() { - return error; - } - - public String getDescription() { - return description; - } - - public Map getParameters() { - return parameters; - } -} +package com.podio; + +import java.util.Map; + +import com.sun.jersey.api.client.ClientResponse.Status; + +public class APIApplicationException extends RuntimeException { + + private static final long serialVersionUID = -4533177892434958205L; + + private final Status status; + + private final String error; + + private final String description; + + private final Map parameters; + + public APIApplicationException(Status status, String error, + String description, Map parameters) { + super(); + this.status = status; + this.error = error; + this.description = description; + this.parameters = parameters; + } + + @Override + public String toString() { + return "APIException [status=" + status + ", error=" + error + + ", description=" + description + ", parameters=" + parameters + + "]"; + } + + public Status getStatus() { + return status; + } + + public String getError() { + return error; + } + + public String getDescription() { + return description; + } + + public Map getParameters() { + return parameters; + } +} diff --git a/src/main/java/com/podio/APIFactory.java b/src/main/java/com/podio/APIFactory.java index 75a38c0..31e14c0 100644 --- a/src/main/java/com/podio/APIFactory.java +++ b/src/main/java/com/podio/APIFactory.java @@ -1,31 +1,31 @@ -package com.podio; - -import java.lang.reflect.InvocationTargetException; - -/** - * Factory to make it simple to get a specific API to work with - */ -public class APIFactory { - - private final ResourceFactory resourceFactory; - - public APIFactory(ResourceFactory resourceFactory) { - super(); - this.resourceFactory = resourceFactory; - } - - public T getAPI(Class apiClass) { - try { - return apiClass.getConstructor(ResourceFactory.class).newInstance( - this.resourceFactory); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } -} +package com.podio; + +import java.lang.reflect.InvocationTargetException; + +/** + * Factory to make it simple to get a specific API to work with + */ +public class APIFactory { + + private final ResourceFactory resourceFactory; + + public APIFactory(ResourceFactory resourceFactory) { + super(); + this.resourceFactory = resourceFactory; + } + + public T getAPI(Class apiClass) { + try { + return apiClass.getConstructor(ResourceFactory.class).newInstance( + this.resourceFactory); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/podio/APITransportException.java b/src/main/java/com/podio/APITransportException.java index 936c721..9569b5f 100644 --- a/src/main/java/com/podio/APITransportException.java +++ b/src/main/java/com/podio/APITransportException.java @@ -1,10 +1,10 @@ -package com.podio; - -public class APITransportException extends RuntimeException { - - private static final long serialVersionUID = 5668433811286152593L; - - public APITransportException(Throwable cause) { - super(cause); - } -} +package com.podio; + +public class APITransportException extends RuntimeException { + + private static final long serialVersionUID = 5668433811286152593L; + + public APITransportException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/com/podio/BaseAPI.java b/src/main/java/com/podio/BaseAPI.java index 3e8415a..453cc60 100644 --- a/src/main/java/com/podio/BaseAPI.java +++ b/src/main/java/com/podio/BaseAPI.java @@ -1,14 +1,14 @@ -package com.podio; - -public abstract class BaseAPI { - - private final ResourceFactory resourceFactory; - - public BaseAPI(ResourceFactory resourceFactory) { - this.resourceFactory = resourceFactory; - } - - protected ResourceFactory getResourceFactory() { - return resourceFactory; - } -} +package com.podio; + +public abstract class BaseAPI { + + private final ResourceFactory resourceFactory; + + public BaseAPI(ResourceFactory resourceFactory) { + this.resourceFactory = resourceFactory; + } + + protected ResourceFactory getResourceFactory() { + return resourceFactory; + } +} diff --git a/src/main/java/com/podio/CustomJacksonJsonProvider.java b/src/main/java/com/podio/CustomJacksonJsonProvider.java index bd4090c..1336891 100644 --- a/src/main/java/com/podio/CustomJacksonJsonProvider.java +++ b/src/main/java/com/podio/CustomJacksonJsonProvider.java @@ -1,34 +1,34 @@ -package com.podio; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -import org.codehaus.jackson.map.ObjectMapper; - -/** - * Custom jackson provider to accept multiple kinds of data as JSON - */ -@Consumes({ MediaType.APPLICATION_JSON, "text/json", "text/javascript", - "application/x-javascript", "text/plain" }) -public class CustomJacksonJsonProvider extends JacksonJsonProvider { - - public CustomJacksonJsonProvider(ObjectMapper mapper) { - super(mapper); - } - - @Override - protected boolean isJsonType(MediaType mediaType) { - if (super.isJsonType(mediaType)) { - return true; - } - - return mediaType != null - && (mediaType.getType().equalsIgnoreCase("text") && mediaType - .getSubtype().equals("javascript")) - || (mediaType.getType().equalsIgnoreCase("application") && mediaType - .getSubtype().equals("x-javascript")) - || (mediaType.getType().equalsIgnoreCase("text") && mediaType - .getSubtype().equals("plain")); - } -} +package com.podio; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.codehaus.jackson.jaxrs.JacksonJsonProvider; +import org.codehaus.jackson.map.ObjectMapper; + +/** + * Custom jackson provider to accept multiple kinds of data as JSON + */ +@Consumes({ MediaType.APPLICATION_JSON, "text/json", "text/javascript", + "application/x-javascript", "text/plain" }) +public class CustomJacksonJsonProvider extends JacksonJsonProvider { + + public CustomJacksonJsonProvider(ObjectMapper mapper) { + super(mapper); + } + + @Override + protected boolean isJsonType(MediaType mediaType) { + if (super.isJsonType(mediaType)) { + return true; + } + + return mediaType != null + && (mediaType.getType().equalsIgnoreCase("text") && mediaType + .getSubtype().equals("javascript")) + || (mediaType.getType().equalsIgnoreCase("application") && mediaType + .getSubtype().equals("x-javascript")) + || (mediaType.getType().equalsIgnoreCase("text") && mediaType + .getSubtype().equals("plain")); + } +} diff --git a/src/main/java/com/podio/DryRunFilter.java b/src/main/java/com/podio/DryRunFilter.java index e70c260..1a6ea48 100644 --- a/src/main/java/com/podio/DryRunFilter.java +++ b/src/main/java/com/podio/DryRunFilter.java @@ -1,23 +1,23 @@ -package com.podio; - -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientRequest; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.filter.ClientFilter; - -/** - * Used to put the API in testmode - */ -public class DryRunFilter extends ClientFilter { - - @Override - public ClientResponse handle(ClientRequest cr) - throws ClientHandlerException { - if (!cr.getURI().getPath().startsWith("/oauth")) { - cr.getHeaders().putSingle("X-Podio-Dry-Run", "steYut44"); - } - - return getNext().handle(cr); - } - -} +package com.podio; + +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.ClientRequest; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.filter.ClientFilter; + +/** + * Used to put the API in testmode + */ +public class DryRunFilter extends ClientFilter { + + @Override + public ClientResponse handle(ClientRequest cr) + throws ClientHandlerException { + if (!cr.getURI().getPath().startsWith("/oauth")) { + cr.getHeaders().putSingle("X-Podio-Dry-Run", "steYut44"); + } + + return getNext().handle(cr); + } + +} diff --git a/src/main/java/com/podio/ExceptionFilter.java b/src/main/java/com/podio/ExceptionFilter.java index 95e135f..aa77f99 100644 --- a/src/main/java/com/podio/ExceptionFilter.java +++ b/src/main/java/com/podio/ExceptionFilter.java @@ -1,39 +1,40 @@ -package com.podio; - -import java.util.Map; - -import javax.ws.rs.core.Response.Status.Family; - -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientRequest; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.filter.ClientFilter; - -public class ExceptionFilter extends ClientFilter { - - @SuppressWarnings("unchecked") - @Override - public ClientResponse handle(ClientRequest cr) - throws ClientHandlerException { - try { - ClientResponse response = getNext().handle(cr); - if (response.getClientResponseStatus() == null - || response.getClientResponseStatus().getFamily() != Family.SUCCESSFUL) { - Map errorData = response - .getEntity(new GenericType>() { - }); - - throw new APIApplicationException( - response.getClientResponseStatus(), - (String) errorData.get("error"), - (String) errorData.get("error_description"), - (Map) errorData.get("parameters")); - } else { - return response; - } - } catch (ClientHandlerException e) { - throw new APITransportException(e.getCause()); - } - } +package com.podio; + +import java.util.Map; + +import javax.ws.rs.core.Response.Status.Family; + +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.ClientRequest; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.ClientResponse.Status; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.filter.ClientFilter; + +public class ExceptionFilter extends ClientFilter { + + @SuppressWarnings("unchecked") + @Override + public ClientResponse handle(ClientRequest cr) + throws ClientHandlerException { + try { + ClientResponse response = getNext().handle(cr); + if (response.getStatusInfo() == null + || response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { + Map errorData = response + .getEntity(new GenericType>() { + }); + + throw new APIApplicationException( + Status.fromStatusCode(response.getStatusInfo().getStatusCode()), + (String) errorData.get("error"), + (String) errorData.get("error_description"), + (Map) errorData.get("parameters")); + } else { + return response; + } + } catch (ClientHandlerException e) { + throw new APITransportException(e.getCause()); + } + } } \ No newline at end of file diff --git a/src/main/java/com/podio/RateLimitFilter.java b/src/main/java/com/podio/RateLimitFilter.java index 23b6005..fcfc8e0 100644 --- a/src/main/java/com/podio/RateLimitFilter.java +++ b/src/main/java/com/podio/RateLimitFilter.java @@ -1,43 +1,43 @@ -package com.podio; - -import com.sun.jersey.api.client.ClientRequest; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.filter.ClientFilter; -import java.util.List; -import javax.ws.rs.core.MultivaluedMap; - -public class RateLimitFilter extends ClientFilter { - - @SuppressWarnings("unchecked") - @Override - public ClientResponse handle(ClientRequest cr) { - ClientResponse response = getNext().handle(cr); - MultivaluedMap headers = response.getHeaders(); - if (headers != null) { - List limitHeader = headers.get("X-Rate-Limit-Limit"); - if (limitHeader != null && limitHeader.size() == 1) { - try { - RateLimits.setLimit(Integer.parseInt(limitHeader.get(0))); - } catch (NumberFormatException nfe) { - RateLimits.setLimit(null); - } - } else { - RateLimits.setLimit(null); - } - List remainingHeader = response.getHeaders().get("X-Rate-Limit-Remaining"); - if (remainingHeader != null && remainingHeader.size() == 1) { - try { - RateLimits.setRemaining(Integer.parseInt(remainingHeader.get(0))); - } catch (NumberFormatException nfe) { - RateLimits.setRemaining(null); - } - } else { - RateLimits.setRemaining(null); - } - } else { - RateLimits.setLimit(null); - RateLimits.setRemaining(null); - } - return response; - } -} +package com.podio; + +import com.sun.jersey.api.client.ClientRequest; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.filter.ClientFilter; +import java.util.List; +import javax.ws.rs.core.MultivaluedMap; + +public class RateLimitFilter extends ClientFilter { + + @SuppressWarnings("unchecked") + @Override + public ClientResponse handle(ClientRequest cr) { + ClientResponse response = getNext().handle(cr); + MultivaluedMap headers = response.getHeaders(); + if (headers != null) { + List limitHeader = headers.get("X-Rate-Limit-Limit"); + if (limitHeader != null && limitHeader.size() == 1) { + try { + RateLimits.setLimit(Integer.parseInt(limitHeader.get(0))); + } catch (NumberFormatException nfe) { + RateLimits.setLimit(null); + } + } else { + RateLimits.setLimit(null); + } + List remainingHeader = response.getHeaders().get("X-Rate-Limit-Remaining"); + if (remainingHeader != null && remainingHeader.size() == 1) { + try { + RateLimits.setRemaining(Integer.parseInt(remainingHeader.get(0))); + } catch (NumberFormatException nfe) { + RateLimits.setRemaining(null); + } + } else { + RateLimits.setRemaining(null); + } + } else { + RateLimits.setLimit(null); + RateLimits.setRemaining(null); + } + return response; + } +} diff --git a/src/main/java/com/podio/RateLimits.java b/src/main/java/com/podio/RateLimits.java index b17cd92..5203b1b 100644 --- a/src/main/java/com/podio/RateLimits.java +++ b/src/main/java/com/podio/RateLimits.java @@ -1,37 +1,37 @@ -package com.podio; - -public class RateLimits { - - private static Integer limit; - private static Integer remaining; - - /** - * Returns the ceiling for the request you just made. May be null if - * there is no limit. - * - * @return the ceiling for the request you just made - */ - public static Integer getLimit() { - return limit; - } - - public static void setLimit(Integer limit) { - RateLimits.limit = limit; - } - - /** - * Returns the number of requests you have left for the current 1 hour - * window. May be null if there is no limit. - * - * @return the number of requests you have left for the current 1 hour - * window - */ - public static Integer getRemaining() { - return remaining; - } - - public static void setRemaining(Integer remaining) { - RateLimits.remaining = remaining; - } - -} +package com.podio; + +public class RateLimits { + + private static Integer limit; + private static Integer remaining; + + /** + * Returns the ceiling for the request you just made. May be null if + * there is no limit. + * + * @return the ceiling for the request you just made + */ + public static Integer getLimit() { + return limit; + } + + public static void setLimit(Integer limit) { + RateLimits.limit = limit; + } + + /** + * Returns the number of requests you have left for the current 1 hour + * window. May be null if there is no limit. + * + * @return the number of requests you have left for the current 1 hour + * window + */ + public static Integer getRemaining() { + return remaining; + } + + public static void setRemaining(Integer remaining) { + RateLimits.remaining = remaining; + } + +} diff --git a/src/main/java/com/podio/ResourceFactory.java b/src/main/java/com/podio/ResourceFactory.java index ddc7f0f..6ebc34d 100644 --- a/src/main/java/com/podio/ResourceFactory.java +++ b/src/main/java/com/podio/ResourceFactory.java @@ -1,147 +1,148 @@ -package com.podio; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Locale; -import java.util.TimeZone; - -import javax.ws.rs.core.HttpHeaders; - -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -import org.codehaus.jackson.map.DeserializationConfig.Feature; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; -import org.codehaus.jackson.map.deser.CustomDeserializerFactory; -import org.codehaus.jackson.map.deser.StdDeserializerProvider; -import org.codehaus.jackson.map.ser.CustomSerializerFactory; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; - -import com.podio.oauth.OAuthClientCredentials; -import com.podio.oauth.OAuthUserCredentials; -import com.podio.serialize.DateTimeDeserializer; -import com.podio.serialize.DateTimeSerializer; -import com.podio.serialize.LocalDateDeserializer; -import com.podio.serialize.LocalDateSerializer; -import com.podio.serialize.LocaleDeserializer; -import com.podio.serialize.LocaleSerializer; -import com.podio.serialize.TimeZoneDeserializer; -import com.podio.serialize.TimeZoneSerializer; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter; -import com.sun.jersey.multipart.impl.MultiPartWriter; - -/** - * This is the main low level entry point to access the Podio API. Construct - * this and pass it to the APIFactory. - */ -public final class ResourceFactory { - - private final WebResource apiResource; - private final WebResource fileResource; - - private final LoginFilter loginFilter; - - public ResourceFactory(OAuthClientCredentials clientCredentials, - OAuthUserCredentials userCredentials) { - this("api.podio.com", "files.podio.com", 443, true, false, - clientCredentials, userCredentials); - } - - public ResourceFactory(String apiHostname, String fileHostname, int port, - boolean ssl, boolean dryRun, - OAuthClientCredentials clientCredentials, - OAuthUserCredentials userCredentials) { - ClientConfig config = new DefaultClientConfig(); - config.getSingletons().add(getJsonProvider()); - config.getClasses().add(MultiPartWriter.class); - Client client = Client.create(config); - client.addFilter(new GZIPContentEncodingFilter(false)); - client.addFilter(new ExceptionFilter()); - client.addFilter(new RateLimitFilter()); - if (dryRun) { - client.addFilter(new DryRunFilter()); - } - // client.addFilter(new LoggingFilter()); - - this.apiResource = client.resource(getURI(apiHostname, port, ssl)); - apiResource.header(HttpHeaders.USER_AGENT, "Podio Java API Client"); - this.fileResource = client.resource(getURI(fileHostname, port, ssl)); - fileResource.header(HttpHeaders.USER_AGENT, "Podio Java API Client"); - - AuthProvider authProvider = new AuthProvider(this, clientCredentials, - userCredentials); - this.loginFilter = new LoginFilter(authProvider); - } - - private URI getURI(String hostname, int port, boolean ssl) { - try { - return new URI(ssl ? "https" : "http", null, hostname, port, null, - null, null); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - private JacksonJsonProvider getJsonProvider() { - ObjectMapper mapper = new ObjectMapper(); - mapper.disable(Feature.FAIL_ON_UNKNOWN_PROPERTIES); - mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS); - mapper.setSerializationInclusion(Inclusion.NON_NULL); - - CustomSerializerFactory serializerFactory = new CustomSerializerFactory(); - serializerFactory.addSpecificMapping(DateTime.class, - new DateTimeSerializer()); - serializerFactory.addSpecificMapping(LocalDate.class, - new LocalDateSerializer()); - serializerFactory.addGenericMapping(TimeZone.class, - new TimeZoneSerializer()); - serializerFactory.addSpecificMapping(Locale.class, - new LocaleSerializer()); - mapper.setSerializerFactory(serializerFactory); - - CustomDeserializerFactory deserializerFactory = new CustomDeserializerFactory(); - deserializerFactory.addSpecificMapping(DateTime.class, - new DateTimeDeserializer()); - deserializerFactory.addSpecificMapping(LocalDate.class, - new LocalDateDeserializer()); - deserializerFactory.addSpecificMapping(TimeZone.class, - new TimeZoneDeserializer()); - deserializerFactory.addSpecificMapping(Locale.class, - new LocaleDeserializer()); - mapper.setDeserializerProvider(new StdDeserializerProvider( - deserializerFactory)); - - return new CustomJacksonJsonProvider(mapper); - } - - public WebResource getFileResource(String path) { - return getFileResource(path, true); - } - - public WebResource getFileResource(String path, boolean secure) { - WebResource subResource = fileResource.path(path); - if (secure) { - subResource.addFilter(this.loginFilter); - } - - return subResource; - } - - public WebResource getApiResource(String path) { - return getApiResource(path, true); - } - - public WebResource getApiResource(String path, boolean secure) { - WebResource subResource = apiResource.path(path); - if (secure) { - subResource.addFilter(this.loginFilter); - } - - return subResource; - } -} +package com.podio; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Locale; +import java.util.TimeZone; + +import javax.ws.rs.core.HttpHeaders; + +import org.codehaus.jackson.jaxrs.JacksonJsonProvider; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; +import org.codehaus.jackson.map.deser.CustomDeserializerFactory; +import org.codehaus.jackson.map.deser.StdDeserializerProvider; +import org.codehaus.jackson.map.ser.CustomSerializerFactory; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; + +import com.podio.oauth.OAuthClientCredentials; +import com.podio.oauth.OAuthUserCredentials; +import com.podio.serialize.DateTimeDeserializer; +import com.podio.serialize.DateTimeSerializer; +import com.podio.serialize.LocalDateDeserializer; +import com.podio.serialize.LocalDateSerializer; +import com.podio.serialize.LocaleDeserializer; +import com.podio.serialize.LocaleSerializer; +import com.podio.serialize.TimeZoneDeserializer; +import com.podio.serialize.TimeZoneSerializer; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter; +import com.sun.jersey.multipart.impl.MultiPartWriter; + +/** + * This is the main low level entry point to access the Podio API. Construct + * this and pass it to the APIFactory. + */ +@SuppressWarnings( "deprecation" ) +public final class ResourceFactory { + + private final WebResource apiResource; + private final WebResource fileResource; + + private final LoginFilter loginFilter; + + public ResourceFactory(OAuthClientCredentials clientCredentials, + OAuthUserCredentials userCredentials) { + this("api.podio.com", "files.podio.com", 443, true, false, + clientCredentials, userCredentials); + } + + public ResourceFactory(String apiHostname, String fileHostname, int port, + boolean ssl, boolean dryRun, + OAuthClientCredentials clientCredentials, + OAuthUserCredentials userCredentials) { + ClientConfig config = new DefaultClientConfig(); + config.getSingletons().add(getJsonProvider()); + config.getClasses().add(MultiPartWriter.class); + Client client = Client.create(config); + client.addFilter(new GZIPContentEncodingFilter(false)); + client.addFilter(new ExceptionFilter()); + client.addFilter(new RateLimitFilter()); + if (dryRun) { + client.addFilter(new DryRunFilter()); + } + // client.addFilter(new LoggingFilter()); + + this.apiResource = client.resource(getURI(apiHostname, port, ssl)); + apiResource.header(HttpHeaders.USER_AGENT, "Podio Java API Client"); + this.fileResource = client.resource(getURI(fileHostname, port, ssl)); + fileResource.header(HttpHeaders.USER_AGENT, "Podio Java API Client"); + + AuthProvider authProvider = new AuthProvider(this, clientCredentials, + userCredentials); + this.loginFilter = new LoginFilter(authProvider); + } + + private URI getURI(String hostname, int port, boolean ssl) { + try { + return new URI(ssl ? "https" : "http", null, hostname, port, null, + null, null); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + + private JacksonJsonProvider getJsonProvider() { + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(Feature.FAIL_ON_UNKNOWN_PROPERTIES); + mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS); + mapper.setSerializationInclusion(Inclusion.NON_NULL); + + CustomSerializerFactory serializerFactory = new CustomSerializerFactory(); + serializerFactory.addSpecificMapping(DateTime.class, + new DateTimeSerializer()); + serializerFactory.addSpecificMapping(LocalDate.class, + new LocalDateSerializer()); + serializerFactory.addGenericMapping(TimeZone.class, + new TimeZoneSerializer()); + serializerFactory.addSpecificMapping(Locale.class, + new LocaleSerializer()); + mapper.setSerializerFactory(serializerFactory); + + CustomDeserializerFactory deserializerFactory = new CustomDeserializerFactory(); + deserializerFactory.addSpecificMapping(DateTime.class, + new DateTimeDeserializer()); + deserializerFactory.addSpecificMapping(LocalDate.class, + new LocalDateDeserializer()); + deserializerFactory.addSpecificMapping(TimeZone.class, + new TimeZoneDeserializer()); + deserializerFactory.addSpecificMapping(Locale.class, + new LocaleDeserializer()); + mapper.setDeserializerProvider(new StdDeserializerProvider( + deserializerFactory)); + + return new CustomJacksonJsonProvider(mapper); + } + + public WebResource getFileResource(String path) { + return getFileResource(path, true); + } + + public WebResource getFileResource(String path, boolean secure) { + WebResource subResource = fileResource.path(path); + if (secure) { + subResource.addFilter(this.loginFilter); + } + + return subResource; + } + + public WebResource getApiResource(String path) { + return getApiResource(path, true); + } + + public WebResource getApiResource(String path, boolean secure) { + WebResource subResource = apiResource.path(path); + if (secure) { + subResource.addFilter(this.loginFilter); + } + + return subResource; + } +} diff --git a/src/main/java/com/podio/app/AppAPI.java b/src/main/java/com/podio/app/AppAPI.java index 1581f7a..898e308 100644 --- a/src/main/java/com/podio/app/AppAPI.java +++ b/src/main/java/com/podio/app/AppAPI.java @@ -1,268 +1,268 @@ -package com.podio.app; - -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.Empty; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; - -/** - * This area is used to manage application definitions. An application - * definition, commonly called just an app, is the setup of an application. It - * consists primarily of a list of fields and secondly of various settings. - */ -public class AppAPI extends BaseAPI { - - public AppAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Gets the definition of an app and can include configuration and fields. - * This method will always return the latest revision of the app definition. - * - * @param appId - * The id of the app to be returned - * @return The full definition of the app - */ - public Application getApp(int appId) { - return getResourceFactory().getApiResource("/app/" + appId).get( - Application.class); - } - - /** - * Returns all the apps on the space that are visible. The apps are sorted - * by any custom ordering and else by name. - * - * @param spaceId - * The id of the space - * @return The list of apps on the given space - */ - public List getAppsOnSpace(int spaceId) { - return getResourceFactory().getApiResource( - "/app/space/" + spaceId + "/").get( - new GenericType>() { - }); - } - - /** - * Returns the top apps for the active user. This is the apps that the user - * have interacted with the most. - * - * @param limit - * The maximum number of apps to return, defaults to 4. - * @return The top apps for the active user - */ - public List getTopApps(Integer limit) { - WebResource resource = getResourceFactory().getApiResource("/app/top/"); - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - return resource.get(new GenericType>() { - }); - } - - /** - * Creates a new app on a space. - * - * @param app - * The definition for the new app - * @return The id of the newly created app - */ - public int addApp(ApplicationCreate app) { - return getResourceFactory().getApiResource("/app/") - .entity(app, MediaType.APPLICATION_JSON_TYPE) - .post(ApplicationCreateResponse.class).getId(); - } - - /** - * Updates an app. The update can contain an new configuration for the app, - * addition of new fields as well as updates to the configuration of - * existing fields. Fields not included will not be deleted. To delete a - * field use the "delete field" operation. - * - * When adding/updating/deleting apps and fields, it can be simpler to only - * update the app config here and add/update/remove fields using the - * field/{field_id} sub resource. - * - * @param appId - * The id of the app to be updated - * @param app - * The updated app definition - */ - public void updateApp(int appId, ApplicationUpdate app) { - getResourceFactory().getApiResource("/app/" + appId) - .entity(app, MediaType.APPLICATION_JSON).put(); - } - - /** - * Adds a new field to an app - * - * @param appId - * The id of the the field should be added to - * @param field - * The definition of the new field - * @return The id of the newly created field - */ - public int addField(int appId, ApplicationFieldCreate field) { - return getResourceFactory().getApiResource("/app/" + appId + "/field/") - .entity(field, MediaType.APPLICATION_JSON_TYPE) - .post(ApplicationFieldCreateResponse.class).getId(); - } - - /** - * Updates the configuration of an app field. The type of the field cannot - * be updated, only the configuration. - * - * @param appId - * The id of the app the field is one - * @param fieldId - * The id of the field to be updated - * @param configuration - * The new configuration of the field - */ - public void updateField(int appId, int fieldId, - ApplicationFieldConfiguration configuration) { - getResourceFactory() - .getApiResource("/app/" + appId + "/field/" + fieldId) - .entity(configuration, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Returns a single field from an app. - * - * @param appId - * The id of the app the field is on - * @param fieldId - * The id of the field to be returned - * @return The definition and current configuration of the requested field - */ - public ApplicationField getField(int appId, int fieldId) { - return getResourceFactory().getApiResource( - "/app/" + appId + "/field/" + fieldId).get( - ApplicationField.class); - } - - /** - * Returns a single field from an app. - * - * @param appId - * The id of the app the field is on - * @param externalId - * The id of the field to be returned - * @return The definition and current configuration of the requested field - */ - public ApplicationField getField(int appId, String externalId) { - return getResourceFactory().getApiResource( - "/app/" + appId + "/field/" + externalId).get( - ApplicationField.class); - } - - /** - * Deletes a field on an app. When deleting a field any new items and - * updates to existing items will not have this field present. For existing - * items, the field will still be presented when viewing the item. - * - * @param appId - * The id of the app the field is on - * @param fieldId - * The id of the field that should be deleted - */ - public void deleteField(int appId, int fieldId) { - getResourceFactory().getApiResource( - "/app/" + appId + "/field/" + fieldId).delete(); - } - - /** - * Installs the app with the given id on the space. - * - * @param appId - * The id of the app to be installed - * @param spaceId - * The id of the space the app should be installed o n - * @return The id of the newly installed app - */ - public int install(int appId, int spaceId) { - return getResourceFactory() - .getApiResource("/app/" + appId + "/install") - .entity(new ApplicationInstall(spaceId), - MediaType.APPLICATION_JSON_TYPE) - .post(ApplicationCreateResponse.class).getId(); - } - - /** - * Updates the order of the apps on the space. It should post all the apps - * from the space in the order required. - * - * @param spaceId - * The id of the space the apps are on - * @param appIds - * The ids of the apps in the new order - */ - public void updateOrder(int spaceId, List appIds) { - getResourceFactory().getApiResource("/app/space/" + spaceId + "/order") - .entity(appIds, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Returns the apps available to the user. - * - * @return The list of apps the user has access to - */ - public List getApps() { - return getResourceFactory().getApiResource("/app/v2/").get( - new GenericType>() { - }); - } - - /** - * Returns the apps that the given app depends on. - * - * @param appId - * The id of the app the dependecies should be returned for - * @return The applications that the given app depends on - */ - public Dependencies getDependencies(int appId) { - return getResourceFactory().getApiResource( - "/app/" + appId + "/dependencies/").get(Dependencies.class); - } - - /** - * Deactivates the app with the given id. This removes the app from the app - * navigator, and disables insertion of new items. - * - * @param appId - * The id of the app to deactivate - */ - public void deactivateApp(int appId) { - getResourceFactory().getApiResource("/app/" + appId + "/deactivate") - .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Activates a deactivated app. This puts the app back in the app navigator - * and allows insertion of new items. - * - * @param appId - * The id of the app to activate - */ - public void activateApp(int appId) { - getResourceFactory().getApiResource("/app/" + appId + "/activate") - .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Deletes the app with the given id. This will delete all items, widgets, - * filters and shares on the app. This operating is not reversible. - * - * @param appId - * The id of the app to delete - */ - public void deleteApp(int appId) { - getResourceFactory().getApiResource("/app/" + appId).delete(); - } -} +package com.podio.app; + +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.Empty; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; + +/** + * This area is used to manage application definitions. An application + * definition, commonly called just an app, is the setup of an application. It + * consists primarily of a list of fields and secondly of various settings. + */ +public class AppAPI extends BaseAPI { + + public AppAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Gets the definition of an app and can include configuration and fields. + * This method will always return the latest revision of the app definition. + * + * @param appId + * The id of the app to be returned + * @return The full definition of the app + */ + public Application getApp(int appId) { + return getResourceFactory().getApiResource("/app/" + appId).get( + Application.class); + } + + /** + * Returns all the apps on the space that are visible. The apps are sorted + * by any custom ordering and else by name. + * + * @param spaceId + * The id of the space + * @return The list of apps on the given space + */ + public List getAppsOnSpace(int spaceId) { + return getResourceFactory().getApiResource( + "/app/space/" + spaceId + "/").get( + new GenericType>() { + }); + } + + /** + * Returns the top apps for the active user. This is the apps that the user + * have interacted with the most. + * + * @param limit + * The maximum number of apps to return, defaults to 4. + * @return The top apps for the active user + */ + public List getTopApps(Integer limit) { + WebResource resource = getResourceFactory().getApiResource("/app/top/"); + if (limit != null) { + resource = resource.queryParam("limit", limit.toString()); + } + return resource.get(new GenericType>() { + }); + } + + /** + * Creates a new app on a space. + * + * @param app + * The definition for the new app + * @return The id of the newly created app + */ + public int addApp(ApplicationCreate app) { + return getResourceFactory().getApiResource("/app/") + .entity(app, MediaType.APPLICATION_JSON_TYPE) + .post(ApplicationCreateResponse.class).getId(); + } + + /** + * Updates an app. The update can contain an new configuration for the app, + * addition of new fields as well as updates to the configuration of + * existing fields. Fields not included will not be deleted. To delete a + * field use the "delete field" operation. + * + * When adding/updating/deleting apps and fields, it can be simpler to only + * update the app config here and add/update/remove fields using the + * field/{field_id} sub resource. + * + * @param appId + * The id of the app to be updated + * @param app + * The updated app definition + */ + public void updateApp(int appId, ApplicationUpdate app) { + getResourceFactory().getApiResource("/app/" + appId) + .entity(app, MediaType.APPLICATION_JSON).put(); + } + + /** + * Adds a new field to an app + * + * @param appId + * The id of the the field should be added to + * @param field + * The definition of the new field + * @return The id of the newly created field + */ + public int addField(int appId, ApplicationFieldCreate field) { + return getResourceFactory().getApiResource("/app/" + appId + "/field/") + .entity(field, MediaType.APPLICATION_JSON_TYPE) + .post(ApplicationFieldCreateResponse.class).getId(); + } + + /** + * Updates the configuration of an app field. The type of the field cannot + * be updated, only the configuration. + * + * @param appId + * The id of the app the field is one + * @param fieldId + * The id of the field to be updated + * @param configuration + * The new configuration of the field + */ + public void updateField(int appId, int fieldId, + ApplicationFieldConfiguration configuration) { + getResourceFactory() + .getApiResource("/app/" + appId + "/field/" + fieldId) + .entity(configuration, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Returns a single field from an app. + * + * @param appId + * The id of the app the field is on + * @param fieldId + * The id of the field to be returned + * @return The definition and current configuration of the requested field + */ + public ApplicationField getField(int appId, int fieldId) { + return getResourceFactory().getApiResource( + "/app/" + appId + "/field/" + fieldId).get( + ApplicationField.class); + } + + /** + * Returns a single field from an app. + * + * @param appId + * The id of the app the field is on + * @param externalId + * The id of the field to be returned + * @return The definition and current configuration of the requested field + */ + public ApplicationField getField(int appId, String externalId) { + return getResourceFactory().getApiResource( + "/app/" + appId + "/field/" + externalId).get( + ApplicationField.class); + } + + /** + * Deletes a field on an app. When deleting a field any new items and + * updates to existing items will not have this field present. For existing + * items, the field will still be presented when viewing the item. + * + * @param appId + * The id of the app the field is on + * @param fieldId + * The id of the field that should be deleted + */ + public void deleteField(int appId, int fieldId) { + getResourceFactory().getApiResource( + "/app/" + appId + "/field/" + fieldId).delete(); + } + + /** + * Installs the app with the given id on the space. + * + * @param appId + * The id of the app to be installed + * @param spaceId + * The id of the space the app should be installed o n + * @return The id of the newly installed app + */ + public int install(int appId, int spaceId) { + return getResourceFactory() + .getApiResource("/app/" + appId + "/install") + .entity(new ApplicationInstall(spaceId), + MediaType.APPLICATION_JSON_TYPE) + .post(ApplicationCreateResponse.class).getId(); + } + + /** + * Updates the order of the apps on the space. It should post all the apps + * from the space in the order required. + * + * @param spaceId + * The id of the space the apps are on + * @param appIds + * The ids of the apps in the new order + */ + public void updateOrder(int spaceId, List appIds) { + getResourceFactory().getApiResource("/app/space/" + spaceId + "/order") + .entity(appIds, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Returns the apps available to the user. + * + * @return The list of apps the user has access to + */ + public List getApps() { + return getResourceFactory().getApiResource("/app/v2/").get( + new GenericType>() { + }); + } + + /** + * Returns the apps that the given app depends on. + * + * @param appId + * The id of the app the dependecies should be returned for + * @return The applications that the given app depends on + */ + public Dependencies getDependencies(int appId) { + return getResourceFactory().getApiResource( + "/app/" + appId + "/dependencies/").get(Dependencies.class); + } + + /** + * Deactivates the app with the given id. This removes the app from the app + * navigator, and disables insertion of new items. + * + * @param appId + * The id of the app to deactivate + */ + public void deactivateApp(int appId) { + getResourceFactory().getApiResource("/app/" + appId + "/deactivate") + .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Activates a deactivated app. This puts the app back in the app navigator + * and allows insertion of new items. + * + * @param appId + * The id of the app to activate + */ + public void activateApp(int appId) { + getResourceFactory().getApiResource("/app/" + appId + "/activate") + .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Deletes the app with the given id. This will delete all items, widgets, + * filters and shares on the app. This operating is not reversible. + * + * @param appId + * The id of the app to delete + */ + public void deleteApp(int appId) { + getResourceFactory().getApiResource("/app/" + appId).delete(); + } +} diff --git a/src/main/java/com/podio/app/Application.java b/src/main/java/com/podio/app/Application.java index e4e6a26..bbf486f 100644 --- a/src/main/java/com/podio/app/Application.java +++ b/src/main/java/com/podio/app/Application.java @@ -1,111 +1,126 @@ -package com.podio.app; - -import java.io.Serializable; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonAutoDetect; -import org.codehaus.jackson.annotate.JsonProperty; - -@JsonAutoDetect() -public class Application implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the app - */ - private int id; - - /** - * The original app that this app was a copy of - */ - private Integer original; - - /** - * The revision of the original app at the time of copy - */ - private Integer originalRevision; - - /** - * The id of the space on which the app is placed - */ - private int spaceId; - - /** - * The owner of the app, which has special access to the app - */ - private int ownerId; - - /** - * The configuration of the app - */ - private ApplicationConfiguration configuration; - - private List fields; - - @JsonProperty("app_id") - public int getId() { - return id; - } - - @JsonProperty("app_id") - public void setId(int id) { - this.id = id; - } - - public Integer getOriginal() { - return original; - } - - public void setOriginal(Integer original) { - this.original = original; - } - - @JsonProperty("original_revision") - public Integer getOriginalRevision() { - return originalRevision; - } - - @JsonProperty("original_revision") - public void setOriginalRevision(Integer originalRevision) { - this.originalRevision = originalRevision; - } - - @JsonProperty("space_id") - public int getSpaceId() { - return spaceId; - } - - @JsonProperty("space_id") - public void setSpaceId(int spaceId) { - this.spaceId = spaceId; - } - - @JsonProperty("owner_id") - public int getOwnerId() { - return ownerId; - } - - @JsonProperty("owner_id") - public void setOwnerId(int ownerId) { - this.ownerId = ownerId; - } - - @JsonProperty("config") - public ApplicationConfiguration getConfiguration() { - return configuration; - } - - @JsonProperty("config") - public void setConfiguration(ApplicationConfiguration configuration) { - this.configuration = configuration; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } -} +package com.podio.app; + +import java.io.Serializable; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.codehaus.jackson.annotate.JsonProperty; + +@JsonAutoDetect() +public class Application implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the app + */ + private int id; + + /** + * The original app that this app was a copy of + */ + private Integer original; + + /** + * The revision of the original app at the time of copy + */ + private Integer originalRevision; + + /** + * The id of the space on which the app is placed + */ + private int spaceId; + + /** + * The owner of the app, which has special access to the app + */ + private int ownerId; + + /** + * The direct url of the app + */ + private String url; + + /** + * The configuration of the app + */ + private ApplicationConfiguration configuration; + + private List fields; + + @JsonProperty("app_id") + public int getId() { + return id; + } + + @JsonProperty("app_id") + public void setId(int id) { + this.id = id; + } + + public Integer getOriginal() { + return original; + } + + public void setOriginal(Integer original) { + this.original = original; + } + + @JsonProperty("original_revision") + public Integer getOriginalRevision() { + return originalRevision; + } + + @JsonProperty("original_revision") + public void setOriginalRevision(Integer originalRevision) { + this.originalRevision = originalRevision; + } + + @JsonProperty("space_id") + public int getSpaceId() { + return spaceId; + } + + @JsonProperty("space_id") + public void setSpaceId(int spaceId) { + this.spaceId = spaceId; + } + + @JsonProperty("owner_id") + public int getOwnerId() { + return ownerId; + } + + @JsonProperty("owner_id") + public void setOwnerId(int ownerId) { + this.ownerId = ownerId; + } + + @JsonProperty("config") + public ApplicationConfiguration getConfiguration() { + return configuration; + } + + @JsonProperty("config") + public void setConfiguration(ApplicationConfiguration configuration) { + this.configuration = configuration; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public String getUrl() + { + return url; + } + + public void setUrl( String url ) + { + this.url = url; + } +} diff --git a/src/main/java/com/podio/app/ApplicationConfiguration.java b/src/main/java/com/podio/app/ApplicationConfiguration.java index 4a303a8..5231d8f 100644 --- a/src/main/java/com/podio/app/ApplicationConfiguration.java +++ b/src/main/java/com/podio/app/ApplicationConfiguration.java @@ -1,40 +1,40 @@ -package com.podio.app; - -import java.util.List; - -public class ApplicationConfiguration extends ApplicationConfigurationBase { - - private static final long serialVersionUID = 1L; - - /** - * A comma separated list of the tasks that will automatically be created - * when a new item is added - */ - private List tasks; - - public ApplicationConfiguration() { - super(); - } - - public ApplicationConfiguration(String name, String itemName, - String description, String usage, String externalId, String icon, - boolean allowEdit, ApplicationViewType defaultView, - boolean allowAttachments, boolean allowComments, boolean fivestar, - String fivestarLabel, boolean approved, boolean thumbs, - String thumbsLabel, boolean rsvp, String rsvpLabel, boolean yesno, - String yesnoLabel, List tasks) { - super(name, itemName, description, usage, externalId, icon, allowEdit, - defaultView, allowAttachments, allowComments, fivestar, - fivestarLabel, approved, thumbs, thumbsLabel, rsvp, rsvpLabel, - yesno, yesnoLabel); - this.tasks = tasks; - } - - public List getTasks() { - return tasks; - } - - public void setTasks(List tasks) { - this.tasks = tasks; - } -} +package com.podio.app; + +import java.util.List; + +public class ApplicationConfiguration extends ApplicationConfigurationBase { + + private static final long serialVersionUID = 1L; + + /** + * A comma separated list of the tasks that will automatically be created + * when a new item is added + */ + private List tasks; + + public ApplicationConfiguration() { + super(); + } + + public ApplicationConfiguration(String name, String itemName, + String description, String usage, String externalId, String icon, + boolean allowEdit, ApplicationViewType defaultView, + boolean allowAttachments, boolean allowComments, boolean fivestar, + String fivestarLabel, boolean approved, boolean thumbs, + String thumbsLabel, boolean rsvp, String rsvpLabel, boolean yesno, + String yesnoLabel, List tasks) { + super(name, itemName, description, usage, externalId, icon, allowEdit, + defaultView, allowAttachments, allowComments, fivestar, + fivestarLabel, approved, thumbs, thumbsLabel, rsvp, rsvpLabel, + yesno, yesnoLabel); + this.tasks = tasks; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } +} diff --git a/src/main/java/com/podio/app/ApplicationConfigurationBase.java b/src/main/java/com/podio/app/ApplicationConfigurationBase.java index 35222b3..3335677 100644 --- a/src/main/java/com/podio/app/ApplicationConfigurationBase.java +++ b/src/main/java/com/podio/app/ApplicationConfigurationBase.java @@ -1,317 +1,317 @@ -package com.podio.app; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public abstract class ApplicationConfigurationBase implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The name of the app - */ - private String name; - - /** - * The name of each item in an app - */ - private String itemName; - - /** - * The description of the app - */ - private String description; - - /** - * Description of how the app should be used - */ - private String usage; - - /** - * The external id of the app. This can be used to store an id from an - * external system on the app - */ - private String externalId; - - /** - * The name of the icon used to represent the app - */ - private String icon; - - /** - * True if other members are allowed to edit items from the app, false - * otherwise - */ - private boolean allowEdit; - - /** - * The default view of the app items on the app main page (see area for more - * information), - */ - private ApplicationViewType defaultView; - - /** - * True if attachment of files to an item is allowed, false otherwise - */ - private boolean allowAttachments; - - /** - * True if members can make comments on an item, false otherwise - */ - private boolean allowComments; - - /** - * True if fivestar rating is enabled on an item, false otherwise - */ - private boolean fivestar; - - /** - * If fivestar rating is enabled, this is the label that will be presented - * to the users - */ - private String fivestarLabel; - - /** - * True if an item can be approved, false otherwise - */ - private boolean approved; - - /** - * True if an item can have a thumbs up or thumbs down, false otherwise - */ - private boolean thumbs; - - /** - * If thumbs ratings are enabled, this is the label that will be presented - * to the users - */ - private String thumbsLabel; - - /** - * True if RSVP is enabled, false otherwise - */ - private boolean rsvp; - - /** - * If RSVP is enabled, this is the label that will be presented to the users - */ - private String rsvpLabel; - - /** - * True if yes/no rating is enabled, false otherwise - */ - private boolean yesno; - - /** - * If yes/no is enabled, this is the label that will be presented to the - * users - */ - private String yesnoLabel; - - public ApplicationConfigurationBase() { - super(); - } - - public ApplicationConfigurationBase(String name, String itemName, - String description, String usage, String externalId, String icon, - boolean allowEdit, ApplicationViewType defaultView, - boolean allowAttachments, boolean allowComments, boolean fivestar, - String fivestarLabel, boolean approved, boolean thumbs, - String thumbsLabel, boolean rsvp, String rsvpLabel, boolean yesno, - String yesnoLabel) { - super(); - this.name = name; - this.itemName = itemName; - this.description = description; - this.usage = usage; - this.externalId = externalId; - this.icon = icon; - this.allowEdit = allowEdit; - this.defaultView = defaultView; - this.allowAttachments = allowAttachments; - this.allowComments = allowComments; - this.fivestar = fivestar; - this.fivestarLabel = fivestarLabel; - this.approved = approved; - this.thumbs = thumbs; - this.thumbsLabel = thumbsLabel; - this.rsvp = rsvp; - this.rsvpLabel = rsvpLabel; - this.yesno = yesno; - this.yesnoLabel = yesnoLabel; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @JsonProperty("item_name") - public String getItemName() { - return itemName; - } - - @JsonProperty("item_name") - public void setItemName(String itemName) { - this.itemName = itemName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUsage() { - return usage; - } - - public void setUsage(String usage) { - this.usage = usage; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - @JsonProperty("allow_edit") - public boolean isAllowEdit() { - return allowEdit; - } - - @JsonProperty("allow_edit") - public void setAllowEdit(boolean allowEdit) { - this.allowEdit = allowEdit; - } - - @JsonProperty("default_view") - public ApplicationViewType getDefaultView() { - return defaultView; - } - - @JsonProperty("default_view") - public void setDefaultView(ApplicationViewType defaultView) { - this.defaultView = defaultView; - } - - @JsonProperty("allow_attachments") - public boolean isAllowAttachments() { - return allowAttachments; - } - - @JsonProperty("allow_attachments") - public void setAllowAttachments(boolean allowAttachments) { - this.allowAttachments = allowAttachments; - } - - @JsonProperty("allow_comments") - public boolean isAllowComments() { - return allowComments; - } - - @JsonProperty("allow_comments") - public void setAllowComments(boolean allowComments) { - this.allowComments = allowComments; - } - - public boolean isFivestar() { - return fivestar; - } - - public void setFivestar(boolean fivestar) { - this.fivestar = fivestar; - } - - @JsonProperty("fivestar_label") - public String getFivestarLabel() { - return fivestarLabel; - } - - @JsonProperty("fivestar_label") - public void setFivestarLabel(String fivestarLabel) { - this.fivestarLabel = fivestarLabel; - } - - public boolean isApproved() { - return approved; - } - - public void setApproved(boolean approved) { - this.approved = approved; - } - - public boolean isThumbs() { - return thumbs; - } - - public void setThumbs(boolean thumbs) { - this.thumbs = thumbs; - } - - @JsonProperty("thumbs_label") - public String getThumbsLabel() { - return thumbsLabel; - } - - @JsonProperty("thumbs_label") - public void setThumbsLabel(String thumbsLabel) { - this.thumbsLabel = thumbsLabel; - } - - public boolean isRsvp() { - return rsvp; - } - - public void setRsvp(boolean rsvp) { - this.rsvp = rsvp; - } - - @JsonProperty("rsvp_label") - public String getRsvpLabel() { - return rsvpLabel; - } - - @JsonProperty("rsvp_label") - public void setRsvpLabel(String rsvpLabel) { - this.rsvpLabel = rsvpLabel; - } - - public boolean isYesno() { - return yesno; - } - - public void setYesno(boolean yesno) { - this.yesno = yesno; - } - - @JsonProperty("yesno_label") - public String getYesnoLabel() { - return yesnoLabel; - } - - @JsonProperty("yesno_label") - public void setYesnoLabel(String yesnoLabel) { - this.yesnoLabel = yesnoLabel; - } - -} +package com.podio.app; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public abstract class ApplicationConfigurationBase implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The name of the app + */ + private String name; + + /** + * The name of each item in an app + */ + private String itemName; + + /** + * The description of the app + */ + private String description; + + /** + * Description of how the app should be used + */ + private String usage; + + /** + * The external id of the app. This can be used to store an id from an + * external system on the app + */ + private String externalId; + + /** + * The name of the icon used to represent the app + */ + private String icon; + + /** + * True if other members are allowed to edit items from the app, false + * otherwise + */ + private boolean allowEdit; + + /** + * The default view of the app items on the app main page (see area for more + * information), + */ + private ApplicationViewType defaultView; + + /** + * True if attachment of files to an item is allowed, false otherwise + */ + private boolean allowAttachments; + + /** + * True if members can make comments on an item, false otherwise + */ + private boolean allowComments; + + /** + * True if fivestar rating is enabled on an item, false otherwise + */ + private boolean fivestar; + + /** + * If fivestar rating is enabled, this is the label that will be presented + * to the users + */ + private String fivestarLabel; + + /** + * True if an item can be approved, false otherwise + */ + private boolean approved; + + /** + * True if an item can have a thumbs up or thumbs down, false otherwise + */ + private boolean thumbs; + + /** + * If thumbs ratings are enabled, this is the label that will be presented + * to the users + */ + private String thumbsLabel; + + /** + * True if RSVP is enabled, false otherwise + */ + private boolean rsvp; + + /** + * If RSVP is enabled, this is the label that will be presented to the users + */ + private String rsvpLabel; + + /** + * True if yes/no rating is enabled, false otherwise + */ + private boolean yesno; + + /** + * If yes/no is enabled, this is the label that will be presented to the + * users + */ + private String yesnoLabel; + + public ApplicationConfigurationBase() { + super(); + } + + public ApplicationConfigurationBase(String name, String itemName, + String description, String usage, String externalId, String icon, + boolean allowEdit, ApplicationViewType defaultView, + boolean allowAttachments, boolean allowComments, boolean fivestar, + String fivestarLabel, boolean approved, boolean thumbs, + String thumbsLabel, boolean rsvp, String rsvpLabel, boolean yesno, + String yesnoLabel) { + super(); + this.name = name; + this.itemName = itemName; + this.description = description; + this.usage = usage; + this.externalId = externalId; + this.icon = icon; + this.allowEdit = allowEdit; + this.defaultView = defaultView; + this.allowAttachments = allowAttachments; + this.allowComments = allowComments; + this.fivestar = fivestar; + this.fivestarLabel = fivestarLabel; + this.approved = approved; + this.thumbs = thumbs; + this.thumbsLabel = thumbsLabel; + this.rsvp = rsvp; + this.rsvpLabel = rsvpLabel; + this.yesno = yesno; + this.yesnoLabel = yesnoLabel; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @JsonProperty("item_name") + public String getItemName() { + return itemName; + } + + @JsonProperty("item_name") + public void setItemName(String itemName) { + this.itemName = itemName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getUsage() { + return usage; + } + + public void setUsage(String usage) { + this.usage = usage; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + @JsonProperty("allow_edit") + public boolean isAllowEdit() { + return allowEdit; + } + + @JsonProperty("allow_edit") + public void setAllowEdit(boolean allowEdit) { + this.allowEdit = allowEdit; + } + + @JsonProperty("default_view") + public ApplicationViewType getDefaultView() { + return defaultView; + } + + @JsonProperty("default_view") + public void setDefaultView(ApplicationViewType defaultView) { + this.defaultView = defaultView; + } + + @JsonProperty("allow_attachments") + public boolean isAllowAttachments() { + return allowAttachments; + } + + @JsonProperty("allow_attachments") + public void setAllowAttachments(boolean allowAttachments) { + this.allowAttachments = allowAttachments; + } + + @JsonProperty("allow_comments") + public boolean isAllowComments() { + return allowComments; + } + + @JsonProperty("allow_comments") + public void setAllowComments(boolean allowComments) { + this.allowComments = allowComments; + } + + public boolean isFivestar() { + return fivestar; + } + + public void setFivestar(boolean fivestar) { + this.fivestar = fivestar; + } + + @JsonProperty("fivestar_label") + public String getFivestarLabel() { + return fivestarLabel; + } + + @JsonProperty("fivestar_label") + public void setFivestarLabel(String fivestarLabel) { + this.fivestarLabel = fivestarLabel; + } + + public boolean isApproved() { + return approved; + } + + public void setApproved(boolean approved) { + this.approved = approved; + } + + public boolean isThumbs() { + return thumbs; + } + + public void setThumbs(boolean thumbs) { + this.thumbs = thumbs; + } + + @JsonProperty("thumbs_label") + public String getThumbsLabel() { + return thumbsLabel; + } + + @JsonProperty("thumbs_label") + public void setThumbsLabel(String thumbsLabel) { + this.thumbsLabel = thumbsLabel; + } + + public boolean isRsvp() { + return rsvp; + } + + public void setRsvp(boolean rsvp) { + this.rsvp = rsvp; + } + + @JsonProperty("rsvp_label") + public String getRsvpLabel() { + return rsvpLabel; + } + + @JsonProperty("rsvp_label") + public void setRsvpLabel(String rsvpLabel) { + this.rsvpLabel = rsvpLabel; + } + + public boolean isYesno() { + return yesno; + } + + public void setYesno(boolean yesno) { + this.yesno = yesno; + } + + @JsonProperty("yesno_label") + public String getYesnoLabel() { + return yesnoLabel; + } + + @JsonProperty("yesno_label") + public void setYesnoLabel(String yesnoLabel) { + this.yesnoLabel = yesnoLabel; + } + +} diff --git a/src/main/java/com/podio/app/ApplicationConfigurationCreate.java b/src/main/java/com/podio/app/ApplicationConfigurationCreate.java index c8d992e..2a39cf3 100644 --- a/src/main/java/com/podio/app/ApplicationConfigurationCreate.java +++ b/src/main/java/com/podio/app/ApplicationConfigurationCreate.java @@ -1,42 +1,42 @@ -package com.podio.app; - -import java.util.List; - -public class ApplicationConfigurationCreate extends - ApplicationConfigurationBase { - - private static final long serialVersionUID = 1L; - - /** - * A comma separated list of the tasks that will automatically be created - * when a new item is added - */ - private List tasks; - - public ApplicationConfigurationCreate() { - super(); - } - - public ApplicationConfigurationCreate(String name, String itemName, - String description, String usage, String externalId, String icon, - boolean allowEdit, ApplicationViewType defaultView, - boolean allowAttachments, boolean allowComments, boolean fivestar, - String fivestarLabel, boolean approved, boolean thumbs, - String thumbsLabel, boolean rsvp, String rsvpLabel, boolean yesno, - String yesnoLabel, List tasks) { - super(name, itemName, description, usage, externalId, icon, allowEdit, - defaultView, allowAttachments, allowComments, fivestar, - fivestarLabel, approved, thumbs, thumbsLabel, rsvp, rsvpLabel, - yesno, yesnoLabel); - this.tasks = tasks; - } - - public List getTasks() { - return tasks; - } - - public void setTasks(List tasks) { - this.tasks = tasks; - } - -} +package com.podio.app; + +import java.util.List; + +public class ApplicationConfigurationCreate extends + ApplicationConfigurationBase { + + private static final long serialVersionUID = 1L; + + /** + * A comma separated list of the tasks that will automatically be created + * when a new item is added + */ + private List tasks; + + public ApplicationConfigurationCreate() { + super(); + } + + public ApplicationConfigurationCreate(String name, String itemName, + String description, String usage, String externalId, String icon, + boolean allowEdit, ApplicationViewType defaultView, + boolean allowAttachments, boolean allowComments, boolean fivestar, + String fivestarLabel, boolean approved, boolean thumbs, + String thumbsLabel, boolean rsvp, String rsvpLabel, boolean yesno, + String yesnoLabel, List tasks) { + super(name, itemName, description, usage, externalId, icon, allowEdit, + defaultView, allowAttachments, allowComments, fivestar, + fivestarLabel, approved, thumbs, thumbsLabel, rsvp, rsvpLabel, + yesno, yesnoLabel); + this.tasks = tasks; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } + +} diff --git a/src/main/java/com/podio/app/ApplicationCreate.java b/src/main/java/com/podio/app/ApplicationCreate.java index ef0b56b..b02b8b8 100644 --- a/src/main/java/com/podio/app/ApplicationCreate.java +++ b/src/main/java/com/podio/app/ApplicationCreate.java @@ -1,63 +1,63 @@ -package com.podio.app; - -import java.io.Serializable; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationCreate implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the space on which the app is placed - */ - private int spaceId; - - /** - * The new configuration of the app - */ - private ApplicationConfigurationCreate configuration; - - private List fields; - - public ApplicationCreate() { - super(); - } - - public ApplicationCreate(int spaceId, - ApplicationConfigurationCreate configuration, - List fields) { - this.spaceId = spaceId; - this.configuration = configuration; - this.fields = fields; - } - - @JsonProperty("space_id") - public int getSpaceId() { - return spaceId; - } - - @JsonProperty("space_id") - public void setSpaceId(int spaceId) { - this.spaceId = spaceId; - } - - @JsonProperty("config") - public ApplicationConfigurationCreate getConfiguration() { - return configuration; - } - - @JsonProperty("config") - public void setConfiguration(ApplicationConfigurationCreate configuration) { - this.configuration = configuration; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } -} +package com.podio.app; + +import java.io.Serializable; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationCreate implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the space on which the app is placed + */ + private int spaceId; + + /** + * The new configuration of the app + */ + private ApplicationConfigurationCreate configuration; + + private List fields; + + public ApplicationCreate() { + super(); + } + + public ApplicationCreate(int spaceId, + ApplicationConfigurationCreate configuration, + List fields) { + this.spaceId = spaceId; + this.configuration = configuration; + this.fields = fields; + } + + @JsonProperty("space_id") + public int getSpaceId() { + return spaceId; + } + + @JsonProperty("space_id") + public void setSpaceId(int spaceId) { + this.spaceId = spaceId; + } + + @JsonProperty("config") + public ApplicationConfigurationCreate getConfiguration() { + return configuration; + } + + @JsonProperty("config") + public void setConfiguration(ApplicationConfigurationCreate configuration) { + this.configuration = configuration; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/src/main/java/com/podio/app/ApplicationCreateResponse.java b/src/main/java/com/podio/app/ApplicationCreateResponse.java index f1666df..64fafef 100644 --- a/src/main/java/com/podio/app/ApplicationCreateResponse.java +++ b/src/main/java/com/podio/app/ApplicationCreateResponse.java @@ -1,25 +1,25 @@ -package com.podio.app; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationCreateResponse implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the created app - */ - private int id; - - @JsonProperty("app_id") - public int getId() { - return id; - } - - @JsonProperty("app_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.app; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationCreateResponse implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the created app + */ + private int id; + + @JsonProperty("app_id") + public int getId() { + return id; + } + + @JsonProperty("app_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/app/ApplicationField.java b/src/main/java/com/podio/app/ApplicationField.java index 3a6a315..4502dcd 100644 --- a/src/main/java/com/podio/app/ApplicationField.java +++ b/src/main/java/com/podio/app/ApplicationField.java @@ -1,52 +1,52 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationField extends ApplicationFieldCreate { - - private static final long serialVersionUID = 1L; - - /** - * The id of the field - */ - private int id; - - /** - * The external id of the field - */ - private String externalId; - - /** - * Indicates if the field was deleted in Podio - values include "active" and "deleted". - */ - private ApplicationFieldStatus status; - - @JsonProperty("field_id") - public int getId() { - return id; - } - - @JsonProperty("field_id") - public void setId(int id) { - this.id = id; - } - - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - @JsonProperty("status") - public ApplicationFieldStatus getStatus() { - return status; - } - - @JsonProperty("status") - public void setStatus(ApplicationFieldStatus status) { - this.status = status; - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationField extends ApplicationFieldCreate { + + private static final long serialVersionUID = 1L; + + /** + * The id of the field + */ + private int id; + + /** + * The external id of the field + */ + private String externalId; + + /** + * Indicates if the field was deleted in Podio - values include "active" and "deleted". + */ + private ApplicationFieldStatus status; + + @JsonProperty("field_id") + public int getId() { + return id; + } + + @JsonProperty("field_id") + public void setId(int id) { + this.id = id; + } + + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + @JsonProperty("status") + public ApplicationFieldStatus getStatus() { + return status; + } + + @JsonProperty("status") + public void setStatus(ApplicationFieldStatus status) { + this.status = status; + } +} diff --git a/src/main/java/com/podio/app/ApplicationFieldConfiguration.java b/src/main/java/com/podio/app/ApplicationFieldConfiguration.java index 2df8d60..173d71d 100644 --- a/src/main/java/com/podio/app/ApplicationFieldConfiguration.java +++ b/src/main/java/com/podio/app/ApplicationFieldConfiguration.java @@ -1,90 +1,90 @@ -package com.podio.app; - -import java.io.Serializable; - -public class ApplicationFieldConfiguration implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The label of the field, which is what the users will see - */ - private String label; - - /** - * The description of the field, which is a help to users inserting/updating - * an item - */ - private String description; - - /** - * An integer indicating the order of the field compared to other fields - */ - private int delta; - - /** - * The settings of the field which depends on the type of the field (see - * area for more information) - */ - private ApplicationFieldSettings settings; - - /** - * True if the field is required when creating and editing items, false - * otherwise - */ - private boolean required; - - public ApplicationFieldConfiguration() { - super(); - } - - public ApplicationFieldConfiguration(String label, String description, - int delta, ApplicationFieldSettings settings, boolean required) { - super(); - this.label = label; - this.description = description; - this.delta = delta; - this.settings = settings; - this.required = required; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public int getDelta() { - return delta; - } - - public void setDelta(int delta) { - this.delta = delta; - } - - public ApplicationFieldSettings getSettings() { - return settings; - } - - public void setSettings(ApplicationFieldSettings settings) { - this.settings = settings; - } - - public boolean isRequired() { - return required; - } - - public void setRequired(boolean required) { - this.required = required; - } -} +package com.podio.app; + +import java.io.Serializable; + +public class ApplicationFieldConfiguration implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The label of the field, which is what the users will see + */ + private String label; + + /** + * The description of the field, which is a help to users inserting/updating + * an item + */ + private String description; + + /** + * An integer indicating the order of the field compared to other fields + */ + private int delta; + + /** + * The settings of the field which depends on the type of the field (see + * area for more information) + */ + private ApplicationFieldSettings settings; + + /** + * True if the field is required when creating and editing items, false + * otherwise + */ + private boolean required; + + public ApplicationFieldConfiguration() { + super(); + } + + public ApplicationFieldConfiguration(String label, String description, + int delta, ApplicationFieldSettings settings, boolean required) { + super(); + this.label = label; + this.description = description; + this.delta = delta; + this.settings = settings; + this.required = required; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getDelta() { + return delta; + } + + public void setDelta(int delta) { + this.delta = delta; + } + + public ApplicationFieldSettings getSettings() { + return settings; + } + + public void setSettings(ApplicationFieldSettings settings) { + this.settings = settings; + } + + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } +} diff --git a/src/main/java/com/podio/app/ApplicationFieldCreate.java b/src/main/java/com/podio/app/ApplicationFieldCreate.java index 6b6e1f2..36a890f 100644 --- a/src/main/java/com/podio/app/ApplicationFieldCreate.java +++ b/src/main/java/com/podio/app/ApplicationFieldCreate.java @@ -1,49 +1,49 @@ -package com.podio.app; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationFieldCreate implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The type of the field (see area for more information) - */ - private ApplicationFieldType type; - - /** - * The configuration of the field - */ - private ApplicationFieldConfiguration configuration; - - public ApplicationFieldCreate() { - super(); - } - - public ApplicationFieldCreate(ApplicationFieldType type, - ApplicationFieldConfiguration configuration) { - super(); - this.type = type; - this.configuration = configuration; - } - - public ApplicationFieldType getType() { - return type; - } - - public void setType(ApplicationFieldType type) { - this.type = type; - } - - @JsonProperty("config") - public ApplicationFieldConfiguration getConfiguration() { - return configuration; - } - - @JsonProperty("config") - public void setConfiguration(ApplicationFieldConfiguration configuration) { - this.configuration = configuration; - } -} +package com.podio.app; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationFieldCreate implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The type of the field (see area for more information) + */ + private ApplicationFieldType type; + + /** + * The configuration of the field + */ + private ApplicationFieldConfiguration configuration; + + public ApplicationFieldCreate() { + super(); + } + + public ApplicationFieldCreate(ApplicationFieldType type, + ApplicationFieldConfiguration configuration) { + super(); + this.type = type; + this.configuration = configuration; + } + + public ApplicationFieldType getType() { + return type; + } + + public void setType(ApplicationFieldType type) { + this.type = type; + } + + @JsonProperty("config") + public ApplicationFieldConfiguration getConfiguration() { + return configuration; + } + + @JsonProperty("config") + public void setConfiguration(ApplicationFieldConfiguration configuration) { + this.configuration = configuration; + } +} diff --git a/src/main/java/com/podio/app/ApplicationFieldCreateResponse.java b/src/main/java/com/podio/app/ApplicationFieldCreateResponse.java index 7900d25..616a16b 100644 --- a/src/main/java/com/podio/app/ApplicationFieldCreateResponse.java +++ b/src/main/java/com/podio/app/ApplicationFieldCreateResponse.java @@ -1,25 +1,25 @@ -package com.podio.app; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationFieldCreateResponse implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the created field - */ - private int id; - - @JsonProperty("field_id") - public int getId() { - return id; - } - - @JsonProperty("field_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.app; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationFieldCreateResponse implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the created field + */ + private int id; + + @JsonProperty("field_id") + public int getId() { + return id; + } + + @JsonProperty("field_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/app/ApplicationFieldSettings.java b/src/main/java/com/podio/app/ApplicationFieldSettings.java index 0d1a967..f924088 100644 --- a/src/main/java/com/podio/app/ApplicationFieldSettings.java +++ b/src/main/java/com/podio/app/ApplicationFieldSettings.java @@ -1,177 +1,177 @@ -package com.podio.app; - -import java.io.Serializable; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationFieldSettings implements Serializable { - - private static final long serialVersionUID = 1L; - - private TextFieldSize size; - - private List allowedValues; - - private List referenceableTypes; - - private List allowedCurrencies; - - private List options; - - private Boolean multiple; - - private String color; - - private Boolean showInCalendars; - - private DateFieldEndDateType endDate; - - private DateFieldTimeEntryType timeEntry; - - public ApplicationFieldSettings() { - super(); - } - - public ApplicationFieldSettings(TextFieldSize size, - List allowedValues, List referenceableTypes, - List allowedCurrencies, List options, - Boolean multiple) { - super(); - this.size = size; - this.allowedValues = allowedValues; - this.referenceableTypes = referenceableTypes; - this.allowedCurrencies = allowedCurrencies; - this.options = options; - this.multiple = multiple; - } - - @JsonProperty("size") - public TextFieldSize getSize() { - return size; - } - - @JsonProperty("size") - public void setSize(TextFieldSize size) { - this.size = size; - } - - @JsonProperty("allowed_values") - public List getAllowedValues() { - return allowedValues; - } - - @JsonProperty("allowed_values") - public void setAllowedValues(List allowedValues) { - this.allowedValues = allowedValues; - } - - @JsonProperty("referenceable_types") - public List getReferenceableTypes() { - return referenceableTypes; - } - - @JsonProperty("referenceable_types") - public void setReferenceableTypes(List referenceableTypes) { - this.referenceableTypes = referenceableTypes; - } - - @JsonProperty("allowed_currencies") - public List getAllowedCurrencies() { - return allowedCurrencies; - } - - @JsonProperty("allowed_currencies") - public void setAllowedCurrencies(List allowedCurrencies) { - this.allowedCurrencies = allowedCurrencies; - } - - public List getOptions() { - return options; - } - - public void setOptions(List options) { - this.options = options; - } - - public Boolean getMultiple() { - return multiple; - } - - public void setMultiple(Boolean multiple) { - this.multiple = multiple; - } - - @Override - public String toString() { - return "ApplicationFieldSettings [allowedValues=" + allowedValues - + ", referenceableTypes=" + referenceableTypes - + ", allowedCurrencies=" + allowedCurrencies + "]"; - } - - public static ApplicationFieldSettings getState(List allowedValues) { - return new ApplicationFieldSettings(null, allowedValues, null, null, - null, null); - } - - public static ApplicationFieldSettings getApp( - List referenceableTypes) { - return new ApplicationFieldSettings(null, null, referenceableTypes, - null, null, null); - } - - public static ApplicationFieldSettings getText(TextFieldSize size) { - return new ApplicationFieldSettings(size, null, null, null, null, null); - } - - public static ApplicationFieldSettings getMoney( - List allowedCurrencies) { - return new ApplicationFieldSettings(null, null, null, - allowedCurrencies, null, null); - } - - public static ApplicationFieldSettings getCategory( - List options, boolean multiple) { - return new ApplicationFieldSettings(null, null, null, null, options, - multiple); - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - @JsonProperty("calendar") - public Boolean getShowInCalendars() { - return showInCalendars; - } - - @JsonProperty("calendar") - public void setShowInCalendars(Boolean showInCalendars) { - this.showInCalendars = showInCalendars; - } - - @JsonProperty("end") - public DateFieldEndDateType getEndDate() { - return endDate; - } - - @JsonProperty("end") - public void setEndDate(DateFieldEndDateType endDate) { - this.endDate = endDate; - } - - @JsonProperty("time") - public DateFieldTimeEntryType getTimeEntry() { - return timeEntry; - } - - @JsonProperty("time") - public void setTimeEntry(DateFieldTimeEntryType timeEntry) { - this.timeEntry = timeEntry; - } - -} +package com.podio.app; + +import java.io.Serializable; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationFieldSettings implements Serializable { + + private static final long serialVersionUID = 1L; + + private TextFieldSize size; + + private List allowedValues; + + private List referenceableTypes; + + private List allowedCurrencies; + + private List options; + + private Boolean multiple; + + private String color; + + private Boolean showInCalendars; + + private DateFieldEndDateType endDate; + + private DateFieldTimeEntryType timeEntry; + + public ApplicationFieldSettings() { + super(); + } + + public ApplicationFieldSettings(TextFieldSize size, + List allowedValues, List referenceableTypes, + List allowedCurrencies, List options, + Boolean multiple) { + super(); + this.size = size; + this.allowedValues = allowedValues; + this.referenceableTypes = referenceableTypes; + this.allowedCurrencies = allowedCurrencies; + this.options = options; + this.multiple = multiple; + } + + @JsonProperty("size") + public TextFieldSize getSize() { + return size; + } + + @JsonProperty("size") + public void setSize(TextFieldSize size) { + this.size = size; + } + + @JsonProperty("allowed_values") + public List getAllowedValues() { + return allowedValues; + } + + @JsonProperty("allowed_values") + public void setAllowedValues(List allowedValues) { + this.allowedValues = allowedValues; + } + + @JsonProperty("referenceable_types") + public List getReferenceableTypes() { + return referenceableTypes; + } + + @JsonProperty("referenceable_types") + public void setReferenceableTypes(List referenceableTypes) { + this.referenceableTypes = referenceableTypes; + } + + @JsonProperty("allowed_currencies") + public List getAllowedCurrencies() { + return allowedCurrencies; + } + + @JsonProperty("allowed_currencies") + public void setAllowedCurrencies(List allowedCurrencies) { + this.allowedCurrencies = allowedCurrencies; + } + + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + + public Boolean getMultiple() { + return multiple; + } + + public void setMultiple(Boolean multiple) { + this.multiple = multiple; + } + + @Override + public String toString() { + return "ApplicationFieldSettings [allowedValues=" + allowedValues + + ", referenceableTypes=" + referenceableTypes + + ", allowedCurrencies=" + allowedCurrencies + "]"; + } + + public static ApplicationFieldSettings getState(List allowedValues) { + return new ApplicationFieldSettings(null, allowedValues, null, null, + null, null); + } + + public static ApplicationFieldSettings getApp( + List referenceableTypes) { + return new ApplicationFieldSettings(null, null, referenceableTypes, + null, null, null); + } + + public static ApplicationFieldSettings getText(TextFieldSize size) { + return new ApplicationFieldSettings(size, null, null, null, null, null); + } + + public static ApplicationFieldSettings getMoney( + List allowedCurrencies) { + return new ApplicationFieldSettings(null, null, null, + allowedCurrencies, null, null); + } + + public static ApplicationFieldSettings getCategory( + List options, boolean multiple) { + return new ApplicationFieldSettings(null, null, null, null, options, + multiple); + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + @JsonProperty("calendar") + public Boolean getShowInCalendars() { + return showInCalendars; + } + + @JsonProperty("calendar") + public void setShowInCalendars(Boolean showInCalendars) { + this.showInCalendars = showInCalendars; + } + + @JsonProperty("end") + public DateFieldEndDateType getEndDate() { + return endDate; + } + + @JsonProperty("end") + public void setEndDate(DateFieldEndDateType endDate) { + this.endDate = endDate; + } + + @JsonProperty("time") + public DateFieldTimeEntryType getTimeEntry() { + return timeEntry; + } + + @JsonProperty("time") + public void setTimeEntry(DateFieldTimeEntryType timeEntry) { + this.timeEntry = timeEntry; + } + +} diff --git a/src/main/java/com/podio/app/ApplicationFieldStatus.java b/src/main/java/com/podio/app/ApplicationFieldStatus.java index d5cb787..3d778e2 100644 --- a/src/main/java/com/podio/app/ApplicationFieldStatus.java +++ b/src/main/java/com/podio/app/ApplicationFieldStatus.java @@ -1,28 +1,28 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum ApplicationFieldStatus { - - /** - * The field is active. - */ - ACTIVE, - - /** - * The field has been deleted. - */ - DELETED; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator() - public static ApplicationFieldStatus getByName(String value) { - return ApplicationFieldStatus.valueOf(value.toUpperCase()); - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum ApplicationFieldStatus { + + /** + * The field is active. + */ + ACTIVE, + + /** + * The field has been deleted. + */ + DELETED; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator() + public static ApplicationFieldStatus getByName(String value) { + return ApplicationFieldStatus.valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/app/ApplicationFieldType.java b/src/main/java/com/podio/app/ApplicationFieldType.java index cfeb50b..b1d6e0a 100644 --- a/src/main/java/com/podio/app/ApplicationFieldType.java +++ b/src/main/java/com/podio/app/ApplicationFieldType.java @@ -1,110 +1,110 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum ApplicationFieldType { - - /** - * A short text field that can hold a string - */ - TEXT, - - /** - * A field that can hold a single number with decimals. - */ - NUMBER, - - /** - * Holds an image. Can currently only be used internally by Hoist. - */ - IMAGE, - - /** - * A interval presented by a start and optional end date and optional time - */ - DATE, - - /** - * A reference to another app item. - */ - APP, - - /** - * Reference a member in the same space as the app - */ - MEMBER, - - /** - * A currency value - */ - MONEY, - - /** - * The progress of an app item. - */ - PROGRESS, - - /** - * A location in f.ex. Google maps - */ - LOCATION, - - /** - * An uploaded video file. Can currently only be used by Hoist. - */ - VIDEO, - - /** - * A duration field specified in seconds but often displayed in hours, - * minutes, seconds. - */ - DURATION, - - /** - * Holds a reference to a profile, which can be either a member or a contact - */ - CONTACT, - - /** - * A calculation based on fields in the same or related apps - */ - CALCULATION, - - /** - * A list of embeds - */ - EMBED, - - /** - * A category field with multiple values - */ - CATEGORY, - - /** - * A generic file field to hold many kinds of files - */ - FILE, - - /** - * A telephone field to hold telephone numbers properly formatted - */ - PHONE, - - /** - * An Email field to hold email addresses - */ - EMAIL; - - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator() - public static ApplicationFieldType getByName(String value) { - return ApplicationFieldType.valueOf(value.toUpperCase()); - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum ApplicationFieldType { + + /** + * A short text field that can hold a string + */ + TEXT, + + /** + * A field that can hold a single number with decimals. + */ + NUMBER, + + /** + * Holds an image. Can currently only be used internally by Hoist. + */ + IMAGE, + + /** + * A interval presented by a start and optional end date and optional time + */ + DATE, + + /** + * A reference to another app item. + */ + APP, + + /** + * Reference a member in the same space as the app + */ + MEMBER, + + /** + * A currency value + */ + MONEY, + + /** + * The progress of an app item. + */ + PROGRESS, + + /** + * A location in f.ex. Google maps + */ + LOCATION, + + /** + * An uploaded video file. Can currently only be used by Hoist. + */ + VIDEO, + + /** + * A duration field specified in seconds but often displayed in hours, + * minutes, seconds. + */ + DURATION, + + /** + * Holds a reference to a profile, which can be either a member or a contact + */ + CONTACT, + + /** + * A calculation based on fields in the same or related apps + */ + CALCULATION, + + /** + * A list of embeds + */ + EMBED, + + /** + * A category field with multiple values + */ + CATEGORY, + + /** + * A generic file field to hold many kinds of files + */ + FILE, + + /** + * A telephone field to hold telephone numbers properly formatted + */ + PHONE, + + /** + * An Email field to hold email addresses + */ + EMAIL; + + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator() + public static ApplicationFieldType getByName(String value) { + return ApplicationFieldType.valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/app/ApplicationFieldUpdate.java b/src/main/java/com/podio/app/ApplicationFieldUpdate.java index ef4b02f..5e16747 100644 --- a/src/main/java/com/podio/app/ApplicationFieldUpdate.java +++ b/src/main/java/com/podio/app/ApplicationFieldUpdate.java @@ -1,51 +1,51 @@ -package com.podio.app; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationFieldUpdate implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the field - */ - private int id; - - /** - * The configuration of the field - */ - private ApplicationFieldConfiguration configuration; - - public ApplicationFieldUpdate() { - super(); - } - - public ApplicationFieldUpdate(int id, - ApplicationFieldConfiguration configuration) { - super(); - this.id = id; - this.configuration = configuration; - } - - @JsonProperty("field_id") - public int getId() { - return id; - } - - @JsonProperty("field_id") - public void setId(int id) { - this.id = id; - } - - @JsonProperty("config") - public ApplicationFieldConfiguration getConfiguration() { - return configuration; - } - - @JsonProperty("config") - public void setConfiguration(ApplicationFieldConfiguration configuration) { - this.configuration = configuration; - } -} +package com.podio.app; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationFieldUpdate implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the field + */ + private int id; + + /** + * The configuration of the field + */ + private ApplicationFieldConfiguration configuration; + + public ApplicationFieldUpdate() { + super(); + } + + public ApplicationFieldUpdate(int id, + ApplicationFieldConfiguration configuration) { + super(); + this.id = id; + this.configuration = configuration; + } + + @JsonProperty("field_id") + public int getId() { + return id; + } + + @JsonProperty("field_id") + public void setId(int id) { + this.id = id; + } + + @JsonProperty("config") + public ApplicationFieldConfiguration getConfiguration() { + return configuration; + } + + @JsonProperty("config") + public void setConfiguration(ApplicationFieldConfiguration configuration) { + this.configuration = configuration; + } +} diff --git a/src/main/java/com/podio/app/ApplicationInstall.java b/src/main/java/com/podio/app/ApplicationInstall.java index e75f0e3..b2622ca 100644 --- a/src/main/java/com/podio/app/ApplicationInstall.java +++ b/src/main/java/com/podio/app/ApplicationInstall.java @@ -1,32 +1,32 @@ -package com.podio.app; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationInstall implements Serializable { - - private static final long serialVersionUID = 1L; - - private int spaceId; - - public ApplicationInstall() { - super(); - } - - public ApplicationInstall(int spaceId) { - super(); - this.spaceId = spaceId; - } - - @JsonProperty("space_id") - public int getSpaceId() { - return spaceId; - } - - @JsonProperty("space_id") - public void setSpaceId(int spaceId) { - this.spaceId = spaceId; - } - -} +package com.podio.app; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationInstall implements Serializable { + + private static final long serialVersionUID = 1L; + + private int spaceId; + + public ApplicationInstall() { + super(); + } + + public ApplicationInstall(int spaceId) { + super(); + this.spaceId = spaceId; + } + + @JsonProperty("space_id") + public int getSpaceId() { + return spaceId; + } + + @JsonProperty("space_id") + public void setSpaceId(int spaceId) { + this.spaceId = spaceId; + } + +} diff --git a/src/main/java/com/podio/app/ApplicationTask.java b/src/main/java/com/podio/app/ApplicationTask.java index c391751..2e586c4 100644 --- a/src/main/java/com/podio/app/ApplicationTask.java +++ b/src/main/java/com/podio/app/ApplicationTask.java @@ -1,20 +1,20 @@ -package com.podio.app; - -import java.util.List; - -import com.podio.user.UserMini; - -public class ApplicationTask extends ApplicationTaskBase { - - private static final long serialVersionUID = 1L; - - private List responsible; - - public List getResponsible() { - return responsible; - } - - public void setResponsible(List responsible) { - this.responsible = responsible; - } -} +package com.podio.app; + +import java.util.List; + +import com.podio.user.UserMini; + +public class ApplicationTask extends ApplicationTaskBase { + + private static final long serialVersionUID = 1L; + + private List responsible; + + public List getResponsible() { + return responsible; + } + + public void setResponsible(List responsible) { + this.responsible = responsible; + } +} diff --git a/src/main/java/com/podio/app/ApplicationTaskBase.java b/src/main/java/com/podio/app/ApplicationTaskBase.java index 2b50845..e87b688 100644 --- a/src/main/java/com/podio/app/ApplicationTaskBase.java +++ b/src/main/java/com/podio/app/ApplicationTaskBase.java @@ -1,27 +1,27 @@ -package com.podio.app; - -import java.io.Serializable; - -public class ApplicationTaskBase implements Serializable { - - private static final long serialVersionUID = 1L; - - private String text; - - public ApplicationTaskBase() { - super(); - } - - public ApplicationTaskBase(String text) { - super(); - this.text = text; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } -} +package com.podio.app; + +import java.io.Serializable; + +public class ApplicationTaskBase implements Serializable { + + private static final long serialVersionUID = 1L; + + private String text; + + public ApplicationTaskBase() { + super(); + } + + public ApplicationTaskBase(String text) { + super(); + this.text = text; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/src/main/java/com/podio/app/ApplicationTaskCreate.java b/src/main/java/com/podio/app/ApplicationTaskCreate.java index fe728ae..f2b6643 100644 --- a/src/main/java/com/podio/app/ApplicationTaskCreate.java +++ b/src/main/java/com/podio/app/ApplicationTaskCreate.java @@ -1,32 +1,32 @@ -package com.podio.app; - -import java.util.Arrays; -import java.util.List; - -public class ApplicationTaskCreate extends ApplicationTaskBase { - - private static final long serialVersionUID = 1L; - - private List responsible; - - public ApplicationTaskCreate() { - super(); - } - - public ApplicationTaskCreate(String text, Integer... responsible) { - this(text, Arrays.asList(responsible)); - } - - public ApplicationTaskCreate(String text, List responsible) { - super(text); - this.responsible = responsible; - } - - public List getResponsible() { - return responsible; - } - - public void setResponsible(List responsible) { - this.responsible = responsible; - } -} +package com.podio.app; + +import java.util.Arrays; +import java.util.List; + +public class ApplicationTaskCreate extends ApplicationTaskBase { + + private static final long serialVersionUID = 1L; + + private List responsible; + + public ApplicationTaskCreate() { + super(); + } + + public ApplicationTaskCreate(String text, Integer... responsible) { + this(text, Arrays.asList(responsible)); + } + + public ApplicationTaskCreate(String text, List responsible) { + super(text); + this.responsible = responsible; + } + + public List getResponsible() { + return responsible; + } + + public void setResponsible(List responsible) { + this.responsible = responsible; + } +} diff --git a/src/main/java/com/podio/app/ApplicationUpdate.java b/src/main/java/com/podio/app/ApplicationUpdate.java index 133decd..8efc9e0 100644 --- a/src/main/java/com/podio/app/ApplicationUpdate.java +++ b/src/main/java/com/podio/app/ApplicationUpdate.java @@ -1,46 +1,46 @@ -package com.podio.app; - -import java.io.Serializable; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ApplicationUpdate implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The new configuration of the app - */ - private ApplicationConfigurationCreate configuration; - - private List fields; - - public ApplicationUpdate() { - super(); - } - - public ApplicationUpdate(ApplicationConfigurationCreate configuration, - List fields) { - this.configuration = configuration; - this.fields = fields; - } - - @JsonProperty("config") - public ApplicationConfigurationCreate getConfiguration() { - return configuration; - } - - @JsonProperty("config") - public void setConfiguration(ApplicationConfigurationCreate configuration) { - this.configuration = configuration; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } -} +package com.podio.app; + +import java.io.Serializable; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ApplicationUpdate implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The new configuration of the app + */ + private ApplicationConfigurationCreate configuration; + + private List fields; + + public ApplicationUpdate() { + super(); + } + + public ApplicationUpdate(ApplicationConfigurationCreate configuration, + List fields) { + this.configuration = configuration; + this.fields = fields; + } + + @JsonProperty("config") + public ApplicationConfigurationCreate getConfiguration() { + return configuration; + } + + @JsonProperty("config") + public void setConfiguration(ApplicationConfigurationCreate configuration) { + this.configuration = configuration; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/src/main/java/com/podio/app/ApplicationViewType.java b/src/main/java/com/podio/app/ApplicationViewType.java index 262f220..951cb48 100644 --- a/src/main/java/com/podio/app/ApplicationViewType.java +++ b/src/main/java/com/podio/app/ApplicationViewType.java @@ -1,27 +1,27 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum ApplicationViewType { - - BADGE, - TABLE, - LIST, - NODE, - CALENDAR, - GALLERY, - CARD, - STREAM; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static ApplicationViewType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum ApplicationViewType { + + BADGE, + TABLE, + LIST, + NODE, + CALENDAR, + GALLERY, + CARD, + STREAM; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static ApplicationViewType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/app/CategoryOption.java b/src/main/java/com/podio/app/CategoryOption.java index 850c292..52f15a6 100644 --- a/src/main/java/com/podio/app/CategoryOption.java +++ b/src/main/java/com/podio/app/CategoryOption.java @@ -1,64 +1,64 @@ -package com.podio.app; - -import java.io.Serializable; - -public class CategoryOption implements Serializable { - - private static final long serialVersionUID = 1L; - - private int id; - - private CategoryOptionStatus status; - - private String text; - - private String color; - - public CategoryOption() { - super(); - } - - public CategoryOption(int id, CategoryOptionStatus status, String text, - String color) { - super(); - this.id = id; - this.status = status; - this.text = text; - this.color = color; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public CategoryOptionStatus getStatus() { - return status; - } - - public void setStatus(CategoryOptionStatus status) { - this.status = status; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getColor() { - return color; - } - - public void setColor(String color) { - this.color = color; - } - - - -} +package com.podio.app; + +import java.io.Serializable; + +public class CategoryOption implements Serializable { + + private static final long serialVersionUID = 1L; + + private int id; + + private CategoryOptionStatus status; + + private String text; + + private String color; + + public CategoryOption() { + super(); + } + + public CategoryOption(int id, CategoryOptionStatus status, String text, + String color) { + super(); + this.id = id; + this.status = status; + this.text = text; + this.color = color; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public CategoryOptionStatus getStatus() { + return status; + } + + public void setStatus(CategoryOptionStatus status) { + this.status = status; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + + +} diff --git a/src/main/java/com/podio/app/CategoryOptionStatus.java b/src/main/java/com/podio/app/CategoryOptionStatus.java index bf28025..0325f27 100644 --- a/src/main/java/com/podio/app/CategoryOptionStatus.java +++ b/src/main/java/com/podio/app/CategoryOptionStatus.java @@ -1,28 +1,28 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum CategoryOptionStatus { - - /** - * The option is still active - */ - ACTIVE, - - /** - * The option has been deleted - */ - DELETED; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator() - public static CategoryOptionStatus getByName(String value) { - return CategoryOptionStatus.valueOf(value.toUpperCase()); - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum CategoryOptionStatus { + + /** + * The option is still active + */ + ACTIVE, + + /** + * The option has been deleted + */ + DELETED; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator() + public static CategoryOptionStatus getByName(String value) { + return CategoryOptionStatus.valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/app/DateFieldEndDateType.java b/src/main/java/com/podio/app/DateFieldEndDateType.java index a2274bb..6142a77 100644 --- a/src/main/java/com/podio/app/DateFieldEndDateType.java +++ b/src/main/java/com/podio/app/DateFieldEndDateType.java @@ -1,22 +1,22 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum DateFieldEndDateType { - - ENABLED, - DISABLED, - REQUIRED; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static DateFieldEndDateType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum DateFieldEndDateType { + + ENABLED, + DISABLED, + REQUIRED; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static DateFieldEndDateType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/app/DateFieldTimeEntryType.java b/src/main/java/com/podio/app/DateFieldTimeEntryType.java index 8f904d2..826796d 100644 --- a/src/main/java/com/podio/app/DateFieldTimeEntryType.java +++ b/src/main/java/com/podio/app/DateFieldTimeEntryType.java @@ -1,22 +1,22 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum DateFieldTimeEntryType { - - ENABLED, - DISABLED, - REQUIRED; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static DateFieldTimeEntryType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum DateFieldTimeEntryType { + + ENABLED, + DISABLED, + REQUIRED; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static DateFieldTimeEntryType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/app/Dependencies.java b/src/main/java/com/podio/app/Dependencies.java index 1614ecc..447582a 100644 --- a/src/main/java/com/podio/app/Dependencies.java +++ b/src/main/java/com/podio/app/Dependencies.java @@ -1,30 +1,30 @@ -package com.podio.app; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -public class Dependencies implements Serializable { - - private static final long serialVersionUID = 1L; - - private List apps; - - private Map> dependencies; - - public List getApps() { - return apps; - } - - public void setApps(List apps) { - this.apps = apps; - } - - public Map> getDependencies() { - return dependencies; - } - - public void setDependencies(Map> dependencies) { - this.dependencies = dependencies; - } -} +package com.podio.app; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +public class Dependencies implements Serializable { + + private static final long serialVersionUID = 1L; + + private List apps; + + private Map> dependencies; + + public List getApps() { + return apps; + } + + public void setApps(List apps) { + this.apps = apps; + } + + public Map> getDependencies() { + return dependencies; + } + + public void setDependencies(Map> dependencies) { + this.dependencies = dependencies; + } +} diff --git a/src/main/java/com/podio/app/TextFieldSize.java b/src/main/java/com/podio/app/TextFieldSize.java index f9f3b79..3bb3aa4 100644 --- a/src/main/java/com/podio/app/TextFieldSize.java +++ b/src/main/java/com/podio/app/TextFieldSize.java @@ -1,28 +1,28 @@ -package com.podio.app; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum TextFieldSize { - - /** - * A small text field with a single line - */ - SMALL, - - /** - * A large text field with multiple lines - */ - LARGE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator() - public static TextFieldSize getByName(String value) { - return TextFieldSize.valueOf(value.toUpperCase()); - } -} +package com.podio.app; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum TextFieldSize { + + /** + * A small text field with a single line + */ + SMALL, + + /** + * A large text field with multiple lines + */ + LARGE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator() + public static TextFieldSize getByName(String value) { + return TextFieldSize.valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/calendar/CalendarAPI.java b/src/main/java/com/podio/calendar/CalendarAPI.java index de3fb1f..48e0b2f 100644 --- a/src/main/java/com/podio/calendar/CalendarAPI.java +++ b/src/main/java/com/podio/calendar/CalendarAPI.java @@ -1,107 +1,107 @@ -package com.podio.calendar; - -import java.util.List; - -import org.joda.time.LocalDate; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.CSVUtil; -import com.podio.common.ReferenceType; -import com.podio.serialize.DateTimeUtil; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; - -/** - * The calendar is used to get the calendar for a user. The calendar includes - * items with a date field in the interval and tasks with a due date in the - * interval. - * - * Calendar entries are always sorted by date. - */ -public class CalendarAPI extends BaseAPI { - - public CalendarAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - private List getCalendar(String path, LocalDate dateFrom, - LocalDate dateTo, List spaceIds, ReferenceType... types) { - WebResource resource = getResourceFactory().getApiResource( - "/calendar/" + path + "/"); - resource = resource.queryParam("date_from", - DateTimeUtil.formatDate(dateFrom)); - resource = resource.queryParam("date_to", - DateTimeUtil.formatDate(dateTo)); - if (spaceIds != null && spaceIds.size() > 0) { - resource = resource - .queryParam("space_ids", CSVUtil.toCSV(spaceIds)); - } - if (types.length > 0) { - resource = resource.queryParam("types", - CSVUtil.toCSV((Object[]) types)); - } - - return resource.get(new GenericType>() { - }); - } - - /** - * Returns the items and tasks that are related to the given app. - * - * @param appId - * The id of the app - * @param dateFrom - * The from date - * @param dateTo - * The to date - * @param types - * The types of events that should be returned. Leave out to get - * all types of events. - * @return The events in the calendar - */ - public List getApp(int appId, LocalDate dateFrom, LocalDate dateTo, - ReferenceType... types) { - return getCalendar("app/" + appId, dateFrom, dateTo, null, types); - } - - /** - * Returns all items and tasks that the user have access to in the given - * space. Tasks with reference to other spaces are not returned or tasks - * with no reference. - * - * @param spaceId - * The id of the space - * @param dateFrom - * The from date - * @param dateTo - * The to date - * @param types - * The types of events that should be returned. Leave out to get - * all types of events. - * @return The events in the calendar - */ - public List getSpace(int spaceId, LocalDate dateFrom, - LocalDate dateTo, ReferenceType... types) { - return getCalendar("space/" + spaceId, dateFrom, dateTo, null, types); - } - - /** - * Returns all items that the user have access to and all tasks that are - * assigned to the user. The items and tasks can be filtered by a list of - * space ids, but tasks without a reference will always be returned. - * - * @param dateFrom - * The from date - * @param dateTo - * The to date - * @param types - * The types of events that should be returned. Leave out to get - * all types of events. - * @return The events in the calendar - */ - public List getGlobal(LocalDate dateFrom, LocalDate dateTo, - List spaceIds, ReferenceType... types) { - return getCalendar("", dateFrom, dateTo, spaceIds, types); - } -} +package com.podio.calendar; + +import java.util.List; + +import org.joda.time.LocalDate; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.CSVUtil; +import com.podio.common.ReferenceType; +import com.podio.serialize.DateTimeUtil; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; + +/** + * The calendar is used to get the calendar for a user. The calendar includes + * items with a date field in the interval and tasks with a due date in the + * interval. + * + * Calendar entries are always sorted by date. + */ +public class CalendarAPI extends BaseAPI { + + public CalendarAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + private List getCalendar(String path, LocalDate dateFrom, + LocalDate dateTo, List spaceIds, ReferenceType... types) { + WebResource resource = getResourceFactory().getApiResource( + "/calendar/" + path + "/"); + resource = resource.queryParam("date_from", + DateTimeUtil.formatDate(dateFrom)); + resource = resource.queryParam("date_to", + DateTimeUtil.formatDate(dateTo)); + if (spaceIds != null && spaceIds.size() > 0) { + resource = resource + .queryParam("space_ids", CSVUtil.toCSV(spaceIds)); + } + if (types.length > 0) { + resource = resource.queryParam("types", + CSVUtil.toCSV((Object[]) types)); + } + + return resource.get(new GenericType>() { + }); + } + + /** + * Returns the items and tasks that are related to the given app. + * + * @param appId + * The id of the app + * @param dateFrom + * The from date + * @param dateTo + * The to date + * @param types + * The types of events that should be returned. Leave out to get + * all types of events. + * @return The events in the calendar + */ + public List getApp(int appId, LocalDate dateFrom, LocalDate dateTo, + ReferenceType... types) { + return getCalendar("app/" + appId, dateFrom, dateTo, null, types); + } + + /** + * Returns all items and tasks that the user have access to in the given + * space. Tasks with reference to other spaces are not returned or tasks + * with no reference. + * + * @param spaceId + * The id of the space + * @param dateFrom + * The from date + * @param dateTo + * The to date + * @param types + * The types of events that should be returned. Leave out to get + * all types of events. + * @return The events in the calendar + */ + public List getSpace(int spaceId, LocalDate dateFrom, + LocalDate dateTo, ReferenceType... types) { + return getCalendar("space/" + spaceId, dateFrom, dateTo, null, types); + } + + /** + * Returns all items that the user have access to and all tasks that are + * assigned to the user. The items and tasks can be filtered by a list of + * space ids, but tasks without a reference will always be returned. + * + * @param dateFrom + * The from date + * @param dateTo + * The to date + * @param types + * The types of events that should be returned. Leave out to get + * all types of events. + * @return The events in the calendar + */ + public List getGlobal(LocalDate dateFrom, LocalDate dateTo, + List spaceIds, ReferenceType... types) { + return getCalendar("", dateFrom, dateTo, spaceIds, types); + } +} diff --git a/src/main/java/com/podio/calendar/Event.java b/src/main/java/com/podio/calendar/Event.java index e1fbb96..a017ee6 100644 --- a/src/main/java/com/podio/calendar/Event.java +++ b/src/main/java/com/podio/calendar/Event.java @@ -1,184 +1,184 @@ -package com.podio.calendar; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.app.Application; -import com.podio.common.ReferenceType; - -public class Event { - - /** - * The UID of the event - */ - private String uid; - - /** - * The type of the entry, either "task" or "item" - */ - private ReferenceType refType; - - /** - * The id of the entry - */ - private int refId; - - /** - * The title of the entry - */ - private String title; - - /** - * The description of the entry - */ - private String description; - - /** - * The location of the entry - */ - private String location; - - /** - * The active users participation status - */ - private ParticipationStatus status; - - /** - * True if the user is marked as busy, false otherwise - */ - private boolean busy; - - /** - * The version of the event, increments on each change - */ - private int version; - - /** - * The start date - */ - private DateTime start; - - /** - * The end date, if any - */ - private DateTime end; - - /** - * The full link to the object - */ - private String link; - - /** - * The application the event belongs to - */ - private Application application; - - - @JsonProperty("uid") - public String getUID() { - return uid; - } - - public void setUID(String uid) { - this.uid = uid; - } - - @JsonProperty("ref_type") - public ReferenceType getRefType() { - return refType; - } - - public void setRefType(ReferenceType refType) { - this.refType = refType; - } - - @JsonProperty("ref_id") - public int getRefId() { - return refId; - } - - public void setRefId(int refId) { - this.refId = refId; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public ParticipationStatus getStatus() { - return status; - } - - public void setStatus(ParticipationStatus status) { - this.status = status; - } - - public boolean isBusy() { - return busy; - } - - public void setBusy(boolean busy) { - this.busy = busy; - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public DateTime getStart() { - return start; - } - - public void setStart(DateTime start) { - this.start = start; - } - - public DateTime getEnd() { - return end; - } - - public void setEnd(DateTime end) { - this.end = end; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - @JsonProperty("app") - public Application getApplication() { - return application; - } - - public void setApplication(Application application) { - this.application = application; - } -} +package com.podio.calendar; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.app.Application; +import com.podio.common.ReferenceType; + +public class Event { + + /** + * The UID of the event + */ + private String uid; + + /** + * The type of the entry, either "task" or "item" + */ + private ReferenceType refType; + + /** + * The id of the entry + */ + private int refId; + + /** + * The title of the entry + */ + private String title; + + /** + * The description of the entry + */ + private String description; + + /** + * The location of the entry + */ + private String location; + + /** + * The active users participation status + */ + private ParticipationStatus status; + + /** + * True if the user is marked as busy, false otherwise + */ + private boolean busy; + + /** + * The version of the event, increments on each change + */ + private int version; + + /** + * The start date + */ + private DateTime start; + + /** + * The end date, if any + */ + private DateTime end; + + /** + * The full link to the object + */ + private String link; + + /** + * The application the event belongs to + */ + private Application application; + + + @JsonProperty("uid") + public String getUID() { + return uid; + } + + public void setUID(String uid) { + this.uid = uid; + } + + @JsonProperty("ref_type") + public ReferenceType getRefType() { + return refType; + } + + public void setRefType(ReferenceType refType) { + this.refType = refType; + } + + @JsonProperty("ref_id") + public int getRefId() { + return refId; + } + + public void setRefId(int refId) { + this.refId = refId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public ParticipationStatus getStatus() { + return status; + } + + public void setStatus(ParticipationStatus status) { + this.status = status; + } + + public boolean isBusy() { + return busy; + } + + public void setBusy(boolean busy) { + this.busy = busy; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public DateTime getStart() { + return start; + } + + public void setStart(DateTime start) { + this.start = start; + } + + public DateTime getEnd() { + return end; + } + + public void setEnd(DateTime end) { + this.end = end; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + @JsonProperty("app") + public Application getApplication() { + return application; + } + + public void setApplication(Application application) { + this.application = application; + } +} diff --git a/src/main/java/com/podio/calendar/ParticipationStatus.java b/src/main/java/com/podio/calendar/ParticipationStatus.java index 6fe5642..55f809e 100644 --- a/src/main/java/com/podio/calendar/ParticipationStatus.java +++ b/src/main/java/com/podio/calendar/ParticipationStatus.java @@ -1,7 +1,7 @@ -package com.podio.calendar; - -public enum ParticipationStatus { - - INVITED, ACCEPTED, DECLINED, TENTATIVE; - -} +package com.podio.calendar; + +public enum ParticipationStatus { + + INVITED, ACCEPTED, DECLINED, TENTATIVE; + +} diff --git a/src/main/java/com/podio/comment/Comment.java b/src/main/java/com/podio/comment/Comment.java index d782eb8..706450f 100644 --- a/src/main/java/com/podio/comment/Comment.java +++ b/src/main/java/com/podio/comment/Comment.java @@ -1,83 +1,83 @@ -package com.podio.comment; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.common.CreatedBase; -import com.podio.contact.ProfileMini; -import com.podio.file.File; - -public class Comment extends CreatedBase { - - private static final long serialVersionUID = 1L; - - /** - * The id of the comment. Can be used to update and delete the comment - */ - private int id; - - /** - * The actual comment - */ - private String value; - - /** - * The external id set on the comment - */ - private String externalId; - - /** - * The alerts on the comment - */ - private List alerts; - - /** - * The files on the comment - */ - private List files; - - @JsonProperty("comment_id") - public int getId() { - return id; - } - - @JsonProperty("comment_id") - public void setId(int id) { - this.id = id; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public List getAlerts() { - return alerts; - } - - public void setAlerts(List alerts) { - this.alerts = alerts; - } - - public List getFiles() { - return files; - } - - public void setFiles(List files) { - this.files = files; - } -} +package com.podio.comment; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.CreatedBase; +import com.podio.contact.ProfileMini; +import com.podio.file.File; + +public class Comment extends CreatedBase { + + private static final long serialVersionUID = 1L; + + /** + * The id of the comment. Can be used to update and delete the comment + */ + private int id; + + /** + * The actual comment + */ + private String value; + + /** + * The external id set on the comment + */ + private String externalId; + + /** + * The alerts on the comment + */ + private List alerts; + + /** + * The files on the comment + */ + private List files; + + @JsonProperty("comment_id") + public int getId() { + return id; + } + + @JsonProperty("comment_id") + public void setId(int id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public List getAlerts() { + return alerts; + } + + public void setAlerts(List alerts) { + this.alerts = alerts; + } + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } +} diff --git a/src/main/java/com/podio/comment/CommentAPI.java b/src/main/java/com/podio/comment/CommentAPI.java index 4a03125..3cab6f4 100644 --- a/src/main/java/com/podio/comment/CommentAPI.java +++ b/src/main/java/com/podio/comment/CommentAPI.java @@ -1,101 +1,101 @@ -package com.podio.comment; - -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.Reference; -import com.sun.jersey.api.client.GenericType; - -/** - * Comments are made by users on different objects. Objects can f.ex. be items, - * status, etc. Comments is simply a text that can be any length. - * - * Comments are made from the API of the object, see f.ex. Items for more - * details. Comments are however updated and deleted from the comment API. - */ -public class CommentAPI extends BaseAPI { - - public CommentAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Used to retrieve all the comments that have been made on an object of the - * given type and with the given id. It returns a list of all the comments - * sorted in ascending order by time created. - * - * @param reference - * The reference to the object from which the comments should be - * retrieved - * @return The comments on the object - */ - public List getComments(Reference reference) { - return getResourceFactory().getApiResource( - "/comment/" + reference.getType() + "/" + reference.getId()) - .get(new GenericType>() { - }); - } - - /** - * Returns the contents of a comment. It is not possible to see where the - * comment was made, only the comment itself. - * - * @param commentId - * The id of the comment - * @return The comment - */ - public Comment getComment(int commentId) { - return getResourceFactory().getApiResource("/comment/" + commentId) - .get(Comment.class); - } - - /** - * Adds a new comment to the object of the given type and id, f.ex. item 1. - * - * @param reference - * The reference to the object the comment should be added to - * @param comment - * The comment that should be added - * @param silent - * True if the update should be silent, false otherwise - */ - public int addComment(Reference reference, CommentCreate comment, - boolean silent, boolean hook) { - return getResourceFactory() - .getApiResource( - "/comment/" + reference.getType() + "/" - + reference.getId()) - .queryParam("silent", silent ? "1" : "0") - .queryParam("hook", hook ? "1" : "0") - .entity(comment, MediaType.APPLICATION_JSON_TYPE) - .post(CommentCreateResponse.class).getId(); - } - - /** - * Updates an already created comment. This should only be used to correct - * spelling and grammatical mistakes in the comment. - * - * @param commentId - * The id of the comment - * @param comment - * The updated comment definition - */ - public void updateComment(int commentId, CommentUpdate comment) { - getResourceFactory().getApiResource("/comment/" + commentId) - .entity(comment, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Deletes a comment made by a user. This can be used to retract a comment - * that was made and which the user regrets. - * - * @param commentId - * The id of the comment - */ - public void deleteComment(int commentId) { - getResourceFactory().getApiResource("/comment/" + commentId).delete(); - } -} +package com.podio.comment; + +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.Reference; +import com.sun.jersey.api.client.GenericType; + +/** + * Comments are made by users on different objects. Objects can f.ex. be items, + * status, etc. Comments is simply a text that can be any length. + * + * Comments are made from the API of the object, see f.ex. Items for more + * details. Comments are however updated and deleted from the comment API. + */ +public class CommentAPI extends BaseAPI { + + public CommentAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Used to retrieve all the comments that have been made on an object of the + * given type and with the given id. It returns a list of all the comments + * sorted in ascending order by time created. + * + * @param reference + * The reference to the object from which the comments should be + * retrieved + * @return The comments on the object + */ + public List getComments(Reference reference) { + return getResourceFactory().getApiResource( + "/comment/" + reference.getType() + "/" + reference.getId()) + .get(new GenericType>() { + }); + } + + /** + * Returns the contents of a comment. It is not possible to see where the + * comment was made, only the comment itself. + * + * @param commentId + * The id of the comment + * @return The comment + */ + public Comment getComment(int commentId) { + return getResourceFactory().getApiResource("/comment/" + commentId) + .get(Comment.class); + } + + /** + * Adds a new comment to the object of the given type and id, f.ex. item 1. + * + * @param reference + * The reference to the object the comment should be added to + * @param comment + * The comment that should be added + * @param silent + * True if the update should be silent, false otherwise + */ + public int addComment(Reference reference, CommentCreate comment, + boolean silent, boolean hook) { + return getResourceFactory() + .getApiResource( + "/comment/" + reference.getType() + "/" + + reference.getId()) + .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") + .entity(comment, MediaType.APPLICATION_JSON_TYPE) + .post(CommentCreateResponse.class).getId(); + } + + /** + * Updates an already created comment. This should only be used to correct + * spelling and grammatical mistakes in the comment. + * + * @param commentId + * The id of the comment + * @param comment + * The updated comment definition + */ + public void updateComment(int commentId, CommentUpdate comment) { + getResourceFactory().getApiResource("/comment/" + commentId) + .entity(comment, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Deletes a comment made by a user. This can be used to retract a comment + * that was made and which the user regrets. + * + * @param commentId + * The id of the comment + */ + public void deleteComment(int commentId) { + getResourceFactory().getApiResource("/comment/" + commentId).delete(); + } +} diff --git a/src/main/java/com/podio/comment/CommentCreate.java b/src/main/java/com/podio/comment/CommentCreate.java index 36c492d..e7d2505 100644 --- a/src/main/java/com/podio/comment/CommentCreate.java +++ b/src/main/java/com/podio/comment/CommentCreate.java @@ -1,78 +1,78 @@ -package com.podio.comment; - -import java.util.Collections; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class CommentCreate { - - /** - * The comment to be made - */ - private String value; - - /** - * The external id - */ - private String externalId; - - /** - * The users who should be alerted about this comment - */ - private List alerts; - - /** - * Temporary files that have been uploaded and should be attached to this - * comment - */ - private List fileIds; - - public CommentCreate(String value) { - this(value, null, Collections. emptyList(), Collections - . emptyList()); - } - - public CommentCreate(String value, String externalId, List alerts, - List fileIds) { - super(); - this.value = value; - this.externalId = externalId; - this.alerts = alerts; - this.fileIds = fileIds; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public List getAlerts() { - return alerts; - } - - public void setAlerts(List alerts) { - this.alerts = alerts; - } - - @JsonProperty("file_ids") - public List getFileIds() { - return fileIds; - } - - public void setFileIds(List fileIds) { - this.fileIds = fileIds; - } -} +package com.podio.comment; + +import java.util.Collections; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CommentCreate { + + /** + * The comment to be made + */ + private String value; + + /** + * The external id + */ + private String externalId; + + /** + * The users who should be alerted about this comment + */ + private List alerts; + + /** + * Temporary files that have been uploaded and should be attached to this + * comment + */ + private List fileIds; + + public CommentCreate(String value) { + this(value, null, Collections. emptyList(), Collections + . emptyList()); + } + + public CommentCreate(String value, String externalId, List alerts, + List fileIds) { + super(); + this.value = value; + this.externalId = externalId; + this.alerts = alerts; + this.fileIds = fileIds; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public List getAlerts() { + return alerts; + } + + public void setAlerts(List alerts) { + this.alerts = alerts; + } + + @JsonProperty("file_ids") + public List getFileIds() { + return fileIds; + } + + public void setFileIds(List fileIds) { + this.fileIds = fileIds; + } +} diff --git a/src/main/java/com/podio/comment/CommentCreateResponse.java b/src/main/java/com/podio/comment/CommentCreateResponse.java index 0dd8742..5e64cff 100644 --- a/src/main/java/com/podio/comment/CommentCreateResponse.java +++ b/src/main/java/com/podio/comment/CommentCreateResponse.java @@ -1,17 +1,17 @@ -package com.podio.comment; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class CommentCreateResponse { - - private int id; - - public int getId() { - return id; - } - - @JsonProperty("comment_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.comment; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CommentCreateResponse { + + private int id; + + public int getId() { + return id; + } + + @JsonProperty("comment_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/comment/CommentUpdate.java b/src/main/java/com/podio/comment/CommentUpdate.java index 06a3a06..fcde83a 100644 --- a/src/main/java/com/podio/comment/CommentUpdate.java +++ b/src/main/java/com/podio/comment/CommentUpdate.java @@ -1,61 +1,61 @@ -package com.podio.comment; - -import java.util.Collections; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class CommentUpdate { - - /** - * The comment to be made - */ - private String value; - - /** - * The external id of the comment - */ - private String externalId; - - /** - * Temporary files that have been uploaded and should be attached to this - * comment - */ - private List fileIds; - - public CommentUpdate(String value) { - this(value, Collections. emptyList()); - } - - public CommentUpdate(String value, List fileIds) { - super(); - this.value = value; - this.fileIds = fileIds; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - @JsonProperty("file_ids") - public List getFileIds() { - return fileIds; - } - - public void setFileIds(List fileIds) { - this.fileIds = fileIds; - } -} +package com.podio.comment; + +import java.util.Collections; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class CommentUpdate { + + /** + * The comment to be made + */ + private String value; + + /** + * The external id of the comment + */ + private String externalId; + + /** + * Temporary files that have been uploaded and should be attached to this + * comment + */ + private List fileIds; + + public CommentUpdate(String value) { + this(value, Collections. emptyList()); + } + + public CommentUpdate(String value, List fileIds) { + super(); + this.value = value; + this.fileIds = fileIds; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + @JsonProperty("file_ids") + public List getFileIds() { + return fileIds; + } + + public void setFileIds(List fileIds) { + this.fileIds = fileIds; + } +} diff --git a/src/main/java/com/podio/common/AuthorizationEntity.java b/src/main/java/com/podio/common/AuthorizationEntity.java index d931fb0..6082c79 100644 --- a/src/main/java/com/podio/common/AuthorizationEntity.java +++ b/src/main/java/com/podio/common/AuthorizationEntity.java @@ -1,73 +1,73 @@ -package com.podio.common; - -import java.io.Serializable; -import java.net.URL; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class AuthorizationEntity implements Serializable { - - private static final long serialVersionUID = 1L; - - private AuthorizationEntityType type; - - private int id; - - private AvatarType avatarType; - - private Integer avatarId; - - private String name; - - private URL url; - - public AuthorizationEntityType getType() { - return type; - } - - public void setType(AuthorizationEntityType type) { - this.type = type; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public AvatarType getAvatarType() { - return avatarType; - } - - @JsonProperty("avatar_type") - public void setAvatarType(AvatarType avatarType) { - this.avatarType = avatarType; - } - - public Integer getAvatarId() { - return avatarId; - } - - @JsonProperty("avatar_id") - public void setAvatarId(Integer avatarId) { - this.avatarId = avatarId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public URL getUrl() { - return url; - } - - public void setUrl(URL url) { - this.url = url; - } -} +package com.podio.common; + +import java.io.Serializable; +import java.net.URL; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class AuthorizationEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + private AuthorizationEntityType type; + + private int id; + + private AvatarType avatarType; + + private Integer avatarId; + + private String name; + + private URL url; + + public AuthorizationEntityType getType() { + return type; + } + + public void setType(AuthorizationEntityType type) { + this.type = type; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public AvatarType getAvatarType() { + return avatarType; + } + + @JsonProperty("avatar_type") + public void setAvatarType(AvatarType avatarType) { + this.avatarType = avatarType; + } + + public Integer getAvatarId() { + return avatarId; + } + + @JsonProperty("avatar_id") + public void setAvatarId(Integer avatarId) { + this.avatarId = avatarId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public URL getUrl() { + return url; + } + + public void setUrl(URL url) { + this.url = url; + } +} diff --git a/src/main/java/com/podio/common/AuthorizationEntityType.java b/src/main/java/com/podio/common/AuthorizationEntityType.java index 10a5bd0..db20eb5 100644 --- a/src/main/java/com/podio/common/AuthorizationEntityType.java +++ b/src/main/java/com/podio/common/AuthorizationEntityType.java @@ -1,20 +1,20 @@ -package com.podio.common; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum AuthorizationEntityType { - - USER, APP, SYSTEM; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static AuthorizationEntityType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.common; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum AuthorizationEntityType { + + USER, APP, SYSTEM; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static AuthorizationEntityType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/common/AuthorizationInterface.java b/src/main/java/com/podio/common/AuthorizationInterface.java index 07dbd2f..5e18f52 100644 --- a/src/main/java/com/podio/common/AuthorizationInterface.java +++ b/src/main/java/com/podio/common/AuthorizationInterface.java @@ -1,39 +1,39 @@ -package com.podio.common; - -import java.io.Serializable; -import java.net.URL; - -public class AuthorizationInterface implements Serializable { - - private static final long serialVersionUID = 1L; - - private int id; - - private String name; - - private URL url; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public URL getUrl() { - return url; - } - - public void setUrl(URL url) { - this.url = url; - } -} +package com.podio.common; + +import java.io.Serializable; +import java.net.URL; + +public class AuthorizationInterface implements Serializable { + + private static final long serialVersionUID = 1L; + + private int id; + + private String name; + + private URL url; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public URL getUrl() { + return url; + } + + public void setUrl(URL url) { + this.url = url; + } +} diff --git a/src/main/java/com/podio/common/AvatarType.java b/src/main/java/com/podio/common/AvatarType.java index e61dced..38cc56d 100644 --- a/src/main/java/com/podio/common/AvatarType.java +++ b/src/main/java/com/podio/common/AvatarType.java @@ -1,21 +1,21 @@ -package com.podio.common; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum AvatarType { - - FILE, - ICON; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static AvatarType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.common; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum AvatarType { + + FILE, + ICON; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static AvatarType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/common/CSVUtil.java b/src/main/java/com/podio/common/CSVUtil.java index 673dd8c..1b35e5b 100644 --- a/src/main/java/com/podio/common/CSVUtil.java +++ b/src/main/java/com/podio/common/CSVUtil.java @@ -1,25 +1,25 @@ -package com.podio.common; - -import java.util.Arrays; -import java.util.Collection; - -public final class CSVUtil { - - private CSVUtil() { - } - - public static String toCSV(Object... objects) { - return toCSV(Arrays.asList(objects)); - } - - public static String toCSV(Collection objects) { - String out = ""; - for (Object object : objects) { - if (out != "") { - out += "; "; - } - out += object; - } - return out; - } -} +package com.podio.common; + +import java.util.Arrays; +import java.util.Collection; + +public final class CSVUtil { + + private CSVUtil() { + } + + public static String toCSV(Object... objects) { + return toCSV(Arrays.asList(objects)); + } + + public static String toCSV(Collection objects) { + String out = ""; + for (Object object : objects) { + if (out != "") { + out += "; "; + } + out += object; + } + return out; + } +} diff --git a/src/main/java/com/podio/common/CreatedBase.java b/src/main/java/com/podio/common/CreatedBase.java index 62a31ec..88eac6a 100644 --- a/src/main/java/com/podio/common/CreatedBase.java +++ b/src/main/java/com/podio/common/CreatedBase.java @@ -1,56 +1,56 @@ -package com.podio.common; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -public class CreatedBase implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The entity who created the comment - */ - private AuthorizationEntity createdBy; - - /** - * The interface through which the comment was created - */ - private AuthorizationInterface createdVia; - - /** - * The date and time the comment was created - */ - private DateTime createdOn; - - @JsonProperty("created_by") - public AuthorizationEntity getCreatedBy() { - return createdBy; - } - - @JsonProperty("created_by") - public void setCreatedBy(AuthorizationEntity createdBy) { - this.createdBy = createdBy; - } - - @JsonProperty("created_via") - public AuthorizationInterface getCreatedVia() { - return createdVia; - } - - @JsonProperty("created_via") - public void setCreatedVia(AuthorizationInterface createdVia) { - this.createdVia = createdVia; - } - - @JsonProperty("created_on") - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } -} +package com.podio.common; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +public class CreatedBase implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The entity who created the comment + */ + private AuthorizationEntity createdBy; + + /** + * The interface through which the comment was created + */ + private AuthorizationInterface createdVia; + + /** + * The date and time the comment was created + */ + private DateTime createdOn; + + @JsonProperty("created_by") + public AuthorizationEntity getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_by") + public void setCreatedBy(AuthorizationEntity createdBy) { + this.createdBy = createdBy; + } + + @JsonProperty("created_via") + public AuthorizationInterface getCreatedVia() { + return createdVia; + } + + @JsonProperty("created_via") + public void setCreatedVia(AuthorizationInterface createdVia) { + this.createdVia = createdVia; + } + + @JsonProperty("created_on") + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } +} diff --git a/src/main/java/com/podio/common/Empty.java b/src/main/java/com/podio/common/Empty.java index 2e4668f..23e59c1 100644 --- a/src/main/java/com/podio/common/Empty.java +++ b/src/main/java/com/podio/common/Empty.java @@ -1,5 +1,5 @@ -package com.podio.common; - -public class Empty { - -} +package com.podio.common; + +public class Empty { + +} diff --git a/src/main/java/com/podio/common/Reference.java b/src/main/java/com/podio/common/Reference.java index 3b2ee45..0a873c9 100644 --- a/src/main/java/com/podio/common/Reference.java +++ b/src/main/java/com/podio/common/Reference.java @@ -1,59 +1,59 @@ -package com.podio.common; - -public class Reference { - - private ReferenceType type; - - private int id; - - public Reference() { - super(); - } - - public Reference(ReferenceType type, int id) { - super(); - this.type = type; - this.id = id; - } - - @Override - public String toString() { - return type + ":" + id; - } - - public String toURLFragment() { - return toURLFragment(true); - } - - public String toURLFragment(boolean endDash) { - if (endDash) { - return type + "/" + id + "/"; - } else { - return type + "/" + id; - } - } - - public ReferenceType getType() { - return type; - } - - public void setType(ReferenceType type) { - this.type = type; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public static Reference parse(String value) { - String[] split = value.split(":"); - ReferenceType type = ReferenceType.getByName(split[0]); - int id = Integer.parseInt(split[1]); - - return new Reference(type, id); - } -} +package com.podio.common; + +public class Reference { + + private ReferenceType type; + + private int id; + + public Reference() { + super(); + } + + public Reference(ReferenceType type, int id) { + super(); + this.type = type; + this.id = id; + } + + @Override + public String toString() { + return type + ":" + id; + } + + public String toURLFragment() { + return toURLFragment(true); + } + + public String toURLFragment(boolean endDash) { + if (endDash) { + return type + "/" + id + "/"; + } else { + return type + "/" + id; + } + } + + public ReferenceType getType() { + return type; + } + + public void setType(ReferenceType type) { + this.type = type; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public static Reference parse(String value) { + String[] split = value.split(":"); + ReferenceType type = ReferenceType.getByName(split[0]); + int id = Integer.parseInt(split[1]); + + return new Reference(type, id); + } +} diff --git a/src/main/java/com/podio/common/ReferenceType.java b/src/main/java/com/podio/common/ReferenceType.java index c92d016..d408acc 100644 --- a/src/main/java/com/podio/common/ReferenceType.java +++ b/src/main/java/com/podio/common/ReferenceType.java @@ -1,23 +1,23 @@ -package com.podio.common; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum ReferenceType { - - ALERT, APP, APP_FIELD, APP_REVISION, BULLETIN, COMMENT, CONVERSATION, - MESSAGE, FILE, ITEM, ITEM_REVISION, ITEM_VALUE, NOTIFICATION, ORG, PROFILE, - RATING, SPACE, SPACE_MEMBER, STATUS, TASK, USER, WIDGET, QUESTION, QUESTION_ANSWER, - ACTION, MEETING, GRANT, TASK_ACTION, ITEM_PARTICIPATION, VOTE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static ReferenceType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.common; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum ReferenceType { + + ALERT, APP, APP_FIELD, APP_REVISION, BULLETIN, COMMENT, CONVERSATION, + MESSAGE, FILE, ITEM, ITEM_REVISION, ITEM_VALUE, NOTIFICATION, ORG, PROFILE, + RATING, SPACE, SPACE_MEMBER, STATUS, TASK, USER, WIDGET, QUESTION, QUESTION_ANSWER, + ACTION, MEETING, GRANT, TASK_ACTION, ITEM_PARTICIPATION, VOTE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static ReferenceType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/common/Right.java b/src/main/java/com/podio/common/Right.java index 02fa813..cd5f6d3 100644 --- a/src/main/java/com/podio/common/Right.java +++ b/src/main/java/com/podio/common/Right.java @@ -1,23 +1,23 @@ -package com.podio.common; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum Right { - - VIEW, UPDATE, DELETE, SUBSCRIBE, COMMENT, RATE, SHARE, INSTALL, ADD_APP, - ADD_ITEM, ADD_FILE, ADD_TASK, ADD_SPACE, ADD_STATUS, ADD_CONVERSATION, REPLY, - ADD_FILTER, ADD_WIDGET, STATISTICS, ADD_CONTACT, ADD_HOOK, ADD_ANSWER, - ADD_QUESTION, ADD_MEETING, GRANT, DOWNLOAD; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static Right getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.common; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum Right { + + VIEW, UPDATE, DELETE, SUBSCRIBE, COMMENT, RATE, SHARE, INSTALL, ADD_APP, + ADD_ITEM, ADD_FILE, ADD_TASK, ADD_SPACE, ADD_STATUS, ADD_CONVERSATION, REPLY, + ADD_FILTER, ADD_WIDGET, STATISTICS, ADD_CONTACT, ADD_HOOK, ADD_ANSWER, + ADD_QUESTION, ADD_MEETING, GRANT, DOWNLOAD; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static Right getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/common/Role.java b/src/main/java/com/podio/common/Role.java index 5e1d2d0..16e2b3d 100644 --- a/src/main/java/com/podio/common/Role.java +++ b/src/main/java/com/podio/common/Role.java @@ -1,22 +1,22 @@ -package com.podio.common; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum Role { - - LIGHT, - REGULAR, - ADMIN; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static Role getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.common; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum Role { + + LIGHT, + REGULAR, + ADMIN; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static Role getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/common/ToStringUtil.java b/src/main/java/com/podio/common/ToStringUtil.java index 2ec8bac..84dedb7 100644 --- a/src/main/java/com/podio/common/ToStringUtil.java +++ b/src/main/java/com/podio/common/ToStringUtil.java @@ -1,19 +1,19 @@ -package com.podio.common; - -import java.util.Collection; - -public final class ToStringUtil { - - private ToStringUtil() { - } - - public static String toString(Collection objects, CharSequence delimiter) { - StringBuilder sb = new StringBuilder(); - for (Object o : objects) { - sb.append(o.toString()); - sb.append(delimiter); - } - sb.setLength(sb.length() - delimiter.length()); - return sb.toString(); - } -} +package com.podio.common; + +import java.util.Collection; + +public final class ToStringUtil { + + private ToStringUtil() { + } + + public static String toString(Collection objects, CharSequence delimiter) { + StringBuilder sb = new StringBuilder(); + for (Object o : objects) { + sb.append(o.toString()); + sb.append(delimiter); + } + sb.setLength(sb.length() - delimiter.length()); + return sb.toString(); + } +} diff --git a/src/main/java/com/podio/connection/ConnectionType.java b/src/main/java/com/podio/connection/ConnectionType.java index 3a302ce..7f7110b 100644 --- a/src/main/java/com/podio/connection/ConnectionType.java +++ b/src/main/java/com/podio/connection/ConnectionType.java @@ -1,20 +1,20 @@ -package com.podio.connection; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum ConnectionType { - - GOOGLE, OUTLOOK, VCARD; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static ConnectionType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.connection; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum ConnectionType { + + GOOGLE, OUTLOOK, VCARD; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static ConnectionType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/contact/ConnectionContactTotal.java b/src/main/java/com/podio/contact/ConnectionContactTotal.java index 48aa53f..4124d5b 100644 --- a/src/main/java/com/podio/contact/ConnectionContactTotal.java +++ b/src/main/java/com/podio/contact/ConnectionContactTotal.java @@ -1,16 +1,16 @@ -package com.podio.contact; - -public class ConnectionContactTotal { - - // private Connection connection; - - private int count; - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } -} +package com.podio.contact; + +public class ConnectionContactTotal { + + // private Connection connection; + + private int count; + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/src/main/java/com/podio/contact/ConnectionTypeContactTotal.java b/src/main/java/com/podio/contact/ConnectionTypeContactTotal.java index fb04479..90697d0 100644 --- a/src/main/java/com/podio/contact/ConnectionTypeContactTotal.java +++ b/src/main/java/com/podio/contact/ConnectionTypeContactTotal.java @@ -1,38 +1,38 @@ -package com.podio.contact; - -import java.util.List; - -import com.podio.connection.ConnectionType; - -public class ConnectionTypeContactTotal { - - private ConnectionType type; - - private int count; - - private List connections; - - public ConnectionType getType() { - return type; - } - - public void setType(ConnectionType type) { - this.type = type; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } - - public List getConnections() { - return connections; - } - - public void setConnections(List connections) { - this.connections = connections; - } -} +package com.podio.contact; + +import java.util.List; + +import com.podio.connection.ConnectionType; + +public class ConnectionTypeContactTotal { + + private ConnectionType type; + + private int count; + + private List connections; + + public ConnectionType getType() { + return type; + } + + public void setType(ConnectionType type) { + this.type = type; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public List getConnections() { + return connections; + } + + public void setConnections(List connections) { + this.connections = connections; + } +} diff --git a/src/main/java/com/podio/contact/ConnectionsContactTotal.java b/src/main/java/com/podio/contact/ConnectionsContactTotal.java index 7797ca8..ef6922d 100644 --- a/src/main/java/com/podio/contact/ConnectionsContactTotal.java +++ b/src/main/java/com/podio/contact/ConnectionsContactTotal.java @@ -1,16 +1,16 @@ -package com.podio.contact; - -import java.util.List; - -public class ConnectionsContactTotal { - - private List types; - - public List getTypes() { - return types; - } - - public void setTypes(List types) { - this.types = types; - } -} +package com.podio.contact; + +import java.util.List; + +public class ConnectionsContactTotal { + + private List types; + + public List getTypes() { + return types; + } + + public void setTypes(List types) { + this.types = types; + } +} diff --git a/src/main/java/com/podio/contact/ContactAPI.java b/src/main/java/com/podio/contact/ContactAPI.java index 0dfa289..3233469 100644 --- a/src/main/java/com/podio/contact/ContactAPI.java +++ b/src/main/java/com/podio/contact/ContactAPI.java @@ -1,275 +1,275 @@ -package com.podio.contact; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; - -/** - * Each user have a profile attached, that holds all the personal details of the - * user. This includes very basic information like the name and mail addresses, - * but can also include more advanced fields like billing address and IM - * addresses. Fields can have either one or multiple values. There can f.ex. - * only be one name, but multiple mail addresses. The value of a field can - * either be a string, a number or a date. - */ -public class ContactAPI extends BaseAPI { - - public ContactAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Adds a new contact to the given space. - * - * @param spaceId - * The id of the space the contact should be added to - * @param create - * The data for the new contact - * @param silent - * True if the create should be silent, false otherwise - * @return The id of the newly created contact - */ - public int addSpaceContact(int spaceId, ContactCreate create, boolean silent) { - return getResourceFactory().getApiResource("/contact/space/" + spaceId + "/") - .queryParam("silent", silent ? "1" : "0") - .entity(create, MediaType.APPLICATION_JSON_TYPE) - .post(ContactCreateResponse.class).getId(); - } - - /** - * Updates the entire space contact. Only fields which have values specified - * will be updated. To delete the contents of a field, pass an empty array - * for the value. - * - * @param profileId - * The id of the space contact to be updated - * @param update - * The data for the update - * @param silent - * True if the update should be silent, false otherwise - * @param hook - * True if hooks should be executed for the change, false otherwise - */ - public void updateSpaceContact(int profileId, ContactUpdate update, boolean silent, boolean hook) { - getResourceFactory().getApiResource("/contact/" + profileId) - .queryParam("silent", silent ? "1" : "0") - .queryParam("hook", hook ? "1" : "0") - .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Deletes a space contact. - * - * @param profileId - * The id of the space contact to be deleted - * @param silent - * True if the deletion should be silent, false otherwise - */ - public void deleteSpaceContact(int profileId, boolean silent) { - getResourceFactory().getApiResource("/contact/" + profileId) - .queryParam("silent", silent ? "1" : "0") - .delete(); - } - - /** - * Returns all the contact details about the user with the given id. - * - * @param profileId - * The profile id of the user - * @return The contact profile - */ - public Profile getContact(int profileId) { - return getResourceFactory().getApiResource("/contact/" + profileId + "/v2").get( - Profile.class); - } - - /** - * Returns the value of a contact with the specific field - * - * @param userId - * The id of the user - * @param field - * The field for which data should be returned - * @return The list of values for the given field - */ - public List getContactField(int userId, ProfileField field) { - List values = getResourceFactory().getApiResource( - "/contact/" + userId + "/" + field.getName()) - - .get(new GenericType>() { - }); - - List formatted = new ArrayList(); - for (R value : values) { - formatted.add(field.parse(value)); - } - - return formatted; - } - - /** - * Returns the total number of contacts by organization. - * - * @return The list of contact totals by organization - */ - public ContactTotal getContactTotal() { - return getResourceFactory().getApiResource("/contact/totals/").get( - ContactTotal.class); - } - - /** - * Used to get a list of contacts for the user. - * - * @param key - * The profile field if the contacts should be filtered - * @param value - * The value for the field if the contacts should be filtered - * @param limit - * The maximum number of contacts to return - * @param offset - * The offset into the list of contacts - * @param type - * The format in which the contacts should be returned - * @param order - * How the contacts should be ordered - * @param contactType - * The type of contacts to be returned - * @return The list of contacts - */ - public List getContacts(ProfileField key, F value, - Integer limit, Integer offset, ProfileType type, - ContactOrder order, ContactType contactType) { - WebResource resource = getResourceFactory().getApiResource("/contact/"); - - return getContactsCommon(resource, key, value, limit, offset, type, - order, contactType); - } - - /** - * Returns all the profiles of the users contacts on the given organization - * - * @param organizationId - * The id of the organization the contacts should be returned - * from - * @param key - * The profile field if the contacts should be filtered - * @param value - * The value for the field if the contacts should be filtered - * @param limit - * The maximum number of contacts to return - * @param offset - * The offset into the list of contacts - * @param type - * The format in which the contacts should be returned - * @param order - * How the contacts should be ordered - * @param contactType - * The type of contacts to be returned - * @return The list of contacts - */ - public List getOrganizationContacts(int organizationId, - ProfileField key, F value, Integer limit, Integer offset, - ProfileType type, ContactOrder order, ContactType contactType) { - WebResource resource = getResourceFactory().getApiResource( - "/contact/org/" + organizationId); - - return getContactsCommon(resource, key, value, limit, offset, type, - order, contactType); - } - - /** - * Returns all the profiles of the users contacts on the given space - * - * @param spaceId - * The id of the space the contacts should be returned from - * @param key - * The profile field if the contacts should be filtered - * @param value - * The value for the field if the contacts should be filtered - * @param limit - * The maximum number of contacts to return - * @param offset - * The offset into the list of contacts - * @param type - * The format in which the contacts should be returned - * @param order - * How the contacts should be ordered - * @param contactType - * The type of contacts to be returned - * @return The list of contacts - */ - public List getSpaceContacts(int spaceId, - ProfileField key, F value, Integer limit, Integer offset, - ProfileType type, ContactOrder order, ContactType contactType) { - WebResource resource = getResourceFactory().getApiResource( - "/contact/space/" + spaceId); - - return getContactsCommon(resource, key, value, limit, offset, type, - order, contactType); - } - - /** - * Returns the total number of contacts on the space - * - * @param spaceId - * The id of the space the number of contacts should be - * returned from - * @return The total number of space contacts - */ - public SpaceContactTotals getSpaceContactTotals(int spaceId) { - return getResourceFactory().getApiResource( - "/contact/space/" + spaceId + "/totals/space/").get( - SpaceContactTotals.class); - } - - private List getContactsCommon(WebResource resource, - ProfileField key, F value, Integer limit, Integer offset, - final ProfileType type, ContactOrder order, ContactType contactType) { - if (key != null && value != null) { - resource = resource.queryParam("key", key.getName().toLowerCase()) - .queryParam("value", key.format(value).toString()); - } - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - if (offset != null) { - resource = resource.queryParam("offset", offset.toString()); - } - resource = resource.queryParam("type", type.getName()); - if (order != null) { - resource = resource.queryParam("order", order.name().toLowerCase()); - } - if (contactType != null) { - resource = resource.queryParam("contact_type", contactType.name().toLowerCase()); - } - - return resource.get(getGenericType(type)); - } - - private GenericType> getGenericType(final ProfileType type) { - return new GenericType>(new ParameterizedType() { - @Override - public Type getRawType() { - return List.class; - } - - @Override - public Type getOwnerType() { - return null; - } - - @Override - public Type[] getActualTypeArguments() { - return new Type[] { type.getType() }; - } - }); - } -} +package com.podio.contact; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; + +/** + * Each user have a profile attached, that holds all the personal details of the + * user. This includes very basic information like the name and mail addresses, + * but can also include more advanced fields like billing address and IM + * addresses. Fields can have either one or multiple values. There can f.ex. + * only be one name, but multiple mail addresses. The value of a field can + * either be a string, a number or a date. + */ +public class ContactAPI extends BaseAPI { + + public ContactAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Adds a new contact to the given space. + * + * @param spaceId + * The id of the space the contact should be added to + * @param create + * The data for the new contact + * @param silent + * True if the create should be silent, false otherwise + * @return The id of the newly created contact + */ + public int addSpaceContact(int spaceId, ContactCreate create, boolean silent) { + return getResourceFactory().getApiResource("/contact/space/" + spaceId + "/") + .queryParam("silent", silent ? "1" : "0") + .entity(create, MediaType.APPLICATION_JSON_TYPE) + .post(ContactCreateResponse.class).getId(); + } + + /** + * Updates the entire space contact. Only fields which have values specified + * will be updated. To delete the contents of a field, pass an empty array + * for the value. + * + * @param profileId + * The id of the space contact to be updated + * @param update + * The data for the update + * @param silent + * True if the update should be silent, false otherwise + * @param hook + * True if hooks should be executed for the change, false otherwise + */ + public void updateSpaceContact(int profileId, ContactUpdate update, boolean silent, boolean hook) { + getResourceFactory().getApiResource("/contact/" + profileId) + .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") + .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Deletes a space contact. + * + * @param profileId + * The id of the space contact to be deleted + * @param silent + * True if the deletion should be silent, false otherwise + */ + public void deleteSpaceContact(int profileId, boolean silent) { + getResourceFactory().getApiResource("/contact/" + profileId) + .queryParam("silent", silent ? "1" : "0") + .delete(); + } + + /** + * Returns all the contact details about the user with the given id. + * + * @param profileId + * The profile id of the user + * @return The contact profile + */ + public Profile getContact(int profileId) { + return getResourceFactory().getApiResource("/contact/" + profileId + "/v2").get( + Profile.class); + } + + /** + * Returns the value of a contact with the specific field + * + * @param userId + * The id of the user + * @param field + * The field for which data should be returned + * @return The list of values for the given field + */ + public List getContactField(int userId, ProfileField field) { + List values = getResourceFactory().getApiResource( + "/contact/" + userId + "/" + field.getName()) + + .get(new GenericType>() { + }); + + List formatted = new ArrayList(); + for (R value : values) { + formatted.add(field.parse(value)); + } + + return formatted; + } + + /** + * Returns the total number of contacts by organization. + * + * @return The list of contact totals by organization + */ + public ContactTotal getContactTotal() { + return getResourceFactory().getApiResource("/contact/totals/").get( + ContactTotal.class); + } + + /** + * Used to get a list of contacts for the user. + * + * @param key + * The profile field if the contacts should be filtered + * @param value + * The value for the field if the contacts should be filtered + * @param limit + * The maximum number of contacts to return + * @param offset + * The offset into the list of contacts + * @param type + * The format in which the contacts should be returned + * @param order + * How the contacts should be ordered + * @param contactType + * The type of contacts to be returned + * @return The list of contacts + */ + public List getContacts(ProfileField key, F value, + Integer limit, Integer offset, ProfileType type, + ContactOrder order, ContactType contactType) { + WebResource resource = getResourceFactory().getApiResource("/contact/"); + + return getContactsCommon(resource, key, value, limit, offset, type, + order, contactType); + } + + /** + * Returns all the profiles of the users contacts on the given organization + * + * @param organizationId + * The id of the organization the contacts should be returned + * from + * @param key + * The profile field if the contacts should be filtered + * @param value + * The value for the field if the contacts should be filtered + * @param limit + * The maximum number of contacts to return + * @param offset + * The offset into the list of contacts + * @param type + * The format in which the contacts should be returned + * @param order + * How the contacts should be ordered + * @param contactType + * The type of contacts to be returned + * @return The list of contacts + */ + public List getOrganizationContacts(int organizationId, + ProfileField key, F value, Integer limit, Integer offset, + ProfileType type, ContactOrder order, ContactType contactType) { + WebResource resource = getResourceFactory().getApiResource( + "/contact/org/" + organizationId); + + return getContactsCommon(resource, key, value, limit, offset, type, + order, contactType); + } + + /** + * Returns all the profiles of the users contacts on the given space + * + * @param spaceId + * The id of the space the contacts should be returned from + * @param key + * The profile field if the contacts should be filtered + * @param value + * The value for the field if the contacts should be filtered + * @param limit + * The maximum number of contacts to return + * @param offset + * The offset into the list of contacts + * @param type + * The format in which the contacts should be returned + * @param order + * How the contacts should be ordered + * @param contactType + * The type of contacts to be returned + * @return The list of contacts + */ + public List getSpaceContacts(int spaceId, + ProfileField key, F value, Integer limit, Integer offset, + ProfileType type, ContactOrder order, ContactType contactType) { + WebResource resource = getResourceFactory().getApiResource( + "/contact/space/" + spaceId); + + return getContactsCommon(resource, key, value, limit, offset, type, + order, contactType); + } + + /** + * Returns the total number of contacts on the space + * + * @param spaceId + * The id of the space the number of contacts should be + * returned from + * @return The total number of space contacts + */ + public SpaceContactTotals getSpaceContactTotals(int spaceId) { + return getResourceFactory().getApiResource( + "/contact/space/" + spaceId + "/totals/space/").get( + SpaceContactTotals.class); + } + + private List getContactsCommon(WebResource resource, + ProfileField key, F value, Integer limit, Integer offset, + final ProfileType type, ContactOrder order, ContactType contactType) { + if (key != null && value != null) { + resource = resource.queryParam("key", key.getName().toLowerCase()) + .queryParam("value", key.format(value).toString()); + } + if (limit != null) { + resource = resource.queryParam("limit", limit.toString()); + } + if (offset != null) { + resource = resource.queryParam("offset", offset.toString()); + } + resource = resource.queryParam("type", type.getName()); + if (order != null) { + resource = resource.queryParam("order", order.name().toLowerCase()); + } + if (contactType != null) { + resource = resource.queryParam("contact_type", contactType.name().toLowerCase()); + } + + return resource.get(getGenericType(type)); + } + + private GenericType> getGenericType(final ProfileType type) { + return new GenericType>(new ParameterizedType() { + @Override + public Type getRawType() { + return List.class; + } + + @Override + public Type getOwnerType() { + return null; + } + + @Override + public Type[] getActualTypeArguments() { + return new Type[] { type.getType() }; + } + }); + } +} diff --git a/src/main/java/com/podio/contact/ContactCreate.java b/src/main/java/com/podio/contact/ContactCreate.java index 03d86e1..9648650 100644 --- a/src/main/java/com/podio/contact/ContactCreate.java +++ b/src/main/java/com/podio/contact/ContactCreate.java @@ -1,323 +1,323 @@ -package com.podio.contact; - -import java.util.Collections; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.LocalDate; - -public class ContactCreate { - - /** - * The full name - */ - private String name; - - /** - * The file id of the avatar - */ - private Integer avatar; - - /** - * The birthdate - */ - private LocalDate birthdate; - - /** - * The organization or company the person is associated with - */ - private String organization; - - /** - * The department of the organization  - */ - private String department; - - /** - * The username for Skype  - */ - private String skype; - - /** - * Short text about the person - */ - private String about; - - /** - * The address where the person lives or work  - */ - private List addresses; - - /** - * The zip code of the address  - */ - private String zip; - - /** - * The name of the city - */ - private String city; - - /** - * The name of the state, only applicable in some countries - */ - private String state; - - /** - * The name of the country  - */ - private String country; - - /** - * The location of the person - */ - private List locations; - - /** - * Email address - */ - private List mails; - - /** - * The phone number  - */ - private List phones; - - /** - * The persons title, usually the work title - */ - private List titles; - - /** - * The full URL of the users LinkedIn profile - */ - private String linkedin; - - /** - * The name of the users Twitter profile - */ - private String twitter; - - /** - * An URL to the persons homepage or the homepage of the company  - */ - private List urls; - - /** - * The skill of the user - */ - private List skills; - - public ContactCreate(String name) { - this(name, null, null, null, null, null, null, Collections.emptyList(), - null, null, null, null, Collections.emptyList(), - Collections.emptyList(), Collections.emptyList(), - Collections.emptyList(), null, null, - Collections.emptyList(), Collections.emptyList()); - } - - public ContactCreate(String name, Integer avatar, LocalDate birthdate, - String organization, String department, String skype, String about, - List addresses, String zip, String city, String state, - String country, List locations, List mails, - List phones, List titles, String linkedin, - String twitter, List urls, List skills) { - super(); - - this.name = name; - this.avatar = avatar; - this.birthdate = birthdate; - this.organization = organization; - this.department = department; - this.skype = skype; - this.about = about; - this.addresses = addresses; - this.zip = zip; - this.city = city; - this.state = state; - this.country = country; - this.locations = locations; - this.mails = mails; - this.phones = phones; - this.titles = titles; - this.linkedin = linkedin; - this.twitter = twitter; - this.urls = urls; - this.skills = skills; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getAvatar() { - return avatar; - } - - public void setAvatar(Integer avatar) { - this.avatar = avatar; - } - - public LocalDate getBirthdate() { - return birthdate; - } - - public void setBirthdate(LocalDate birthdate) { - this.birthdate = birthdate; - } - - public String getOrganization() { - return organization; - } - - public void setOrganization(String organization) { - this.organization = organization; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public String getSkype() { - return skype; - } - - public void setSkype(String skype) { - this.skype = skype; - } - - public String getAbout() { - return about; - } - - public void setAbout(String about) { - this.about = about; - } - - @JsonProperty("adress") - public List getAddresses() { - return addresses; - } - - @JsonProperty("adress") - public void setAddresses(List addresses) { - this.addresses = addresses; - } - - public String getZip() { - return zip; - } - - public void setZip(String zip) { - this.zip = zip; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - @JsonProperty("location") - public List getLocations() { - return locations; - } - - @JsonProperty("location") - public void setLocations(List locations) { - this.locations = locations; - } - - @JsonProperty("mail") - public List getMails() { - return mails; - } - - @JsonProperty("mail") - public void setMails(List mails) { - this.mails = mails; - } - - @JsonProperty("phone") - public List getPhones() { - return phones; - } - - @JsonProperty("phone") - public void setPhones(List phones) { - this.phones = phones; - } - - @JsonProperty("title") - public List getTitles() { - return titles; - } - - @JsonProperty("title") - public void setTitles(List titles) { - this.titles = titles; - } - - public String getLinkedin() { - return linkedin; - } - - public void setLinkedin(String linkedin) { - this.linkedin = linkedin; - } - - public String getTwitter() { - return twitter; - } - - public void setTwitter(String twitter) { - this.twitter = twitter; - } - - @JsonProperty("url") - public List getUrls() { - return urls; - } - - @JsonProperty("url") - public void setUrls(List urls) { - this.urls = urls; - } - - @JsonProperty("skill") - public List getSkills() { - return skills; - } - - @JsonProperty("skill") - public void setSkills(List skills) { - this.skills = skills; - } - -} +package com.podio.contact; + +import java.util.Collections; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.LocalDate; + +public class ContactCreate { + + /** + * The full name + */ + private String name; + + /** + * The file id of the avatar + */ + private Integer avatar; + + /** + * The birthdate + */ + private LocalDate birthdate; + + /** + * The organization or company the person is associated with + */ + private String organization; + + /** + * The department of the organization  + */ + private String department; + + /** + * The username for Skype  + */ + private String skype; + + /** + * Short text about the person + */ + private String about; + + /** + * The address where the person lives or work  + */ + private List addresses; + + /** + * The zip code of the address  + */ + private String zip; + + /** + * The name of the city + */ + private String city; + + /** + * The name of the state, only applicable in some countries + */ + private String state; + + /** + * The name of the country  + */ + private String country; + + /** + * The location of the person + */ + private List locations; + + /** + * Email address + */ + private List mails; + + /** + * The phone number  + */ + private List phones; + + /** + * The persons title, usually the work title + */ + private List titles; + + /** + * The full URL of the users LinkedIn profile + */ + private String linkedin; + + /** + * The name of the users Twitter profile + */ + private String twitter; + + /** + * An URL to the persons homepage or the homepage of the company  + */ + private List urls; + + /** + * The skill of the user + */ + private List skills; + + public ContactCreate(String name) { + this(name, null, null, null, null, null, null, Collections.emptyList(), + null, null, null, null, Collections.emptyList(), + Collections.emptyList(), Collections.emptyList(), + Collections.emptyList(), null, null, + Collections.emptyList(), Collections.emptyList()); + } + + public ContactCreate(String name, Integer avatar, LocalDate birthdate, + String organization, String department, String skype, String about, + List addresses, String zip, String city, String state, + String country, List locations, List mails, + List phones, List titles, String linkedin, + String twitter, List urls, List skills) { + super(); + + this.name = name; + this.avatar = avatar; + this.birthdate = birthdate; + this.organization = organization; + this.department = department; + this.skype = skype; + this.about = about; + this.addresses = addresses; + this.zip = zip; + this.city = city; + this.state = state; + this.country = country; + this.locations = locations; + this.mails = mails; + this.phones = phones; + this.titles = titles; + this.linkedin = linkedin; + this.twitter = twitter; + this.urls = urls; + this.skills = skills; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAvatar() { + return avatar; + } + + public void setAvatar(Integer avatar) { + this.avatar = avatar; + } + + public LocalDate getBirthdate() { + return birthdate; + } + + public void setBirthdate(LocalDate birthdate) { + this.birthdate = birthdate; + } + + public String getOrganization() { + return organization; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getSkype() { + return skype; + } + + public void setSkype(String skype) { + this.skype = skype; + } + + public String getAbout() { + return about; + } + + public void setAbout(String about) { + this.about = about; + } + + @JsonProperty("adress") + public List getAddresses() { + return addresses; + } + + @JsonProperty("adress") + public void setAddresses(List addresses) { + this.addresses = addresses; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + @JsonProperty("location") + public List getLocations() { + return locations; + } + + @JsonProperty("location") + public void setLocations(List locations) { + this.locations = locations; + } + + @JsonProperty("mail") + public List getMails() { + return mails; + } + + @JsonProperty("mail") + public void setMails(List mails) { + this.mails = mails; + } + + @JsonProperty("phone") + public List getPhones() { + return phones; + } + + @JsonProperty("phone") + public void setPhones(List phones) { + this.phones = phones; + } + + @JsonProperty("title") + public List getTitles() { + return titles; + } + + @JsonProperty("title") + public void setTitles(List titles) { + this.titles = titles; + } + + public String getLinkedin() { + return linkedin; + } + + public void setLinkedin(String linkedin) { + this.linkedin = linkedin; + } + + public String getTwitter() { + return twitter; + } + + public void setTwitter(String twitter) { + this.twitter = twitter; + } + + @JsonProperty("url") + public List getUrls() { + return urls; + } + + @JsonProperty("url") + public void setUrls(List urls) { + this.urls = urls; + } + + @JsonProperty("skill") + public List getSkills() { + return skills; + } + + @JsonProperty("skill") + public void setSkills(List skills) { + this.skills = skills; + } + +} diff --git a/src/main/java/com/podio/contact/ContactCreateResponse.java b/src/main/java/com/podio/contact/ContactCreateResponse.java index e08b186..4a4295e 100644 --- a/src/main/java/com/podio/contact/ContactCreateResponse.java +++ b/src/main/java/com/podio/contact/ContactCreateResponse.java @@ -1,18 +1,18 @@ -package com.podio.contact; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ContactCreateResponse { - - private int id; - - public int getId() { - return id; - } - - @JsonProperty("profile_id") - public void setId(int id) { - this.id = id; - } - -} +package com.podio.contact; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ContactCreateResponse { + + private int id; + + public int getId() { + return id; + } + + @JsonProperty("profile_id") + public void setId(int id) { + this.id = id; + } + +} diff --git a/src/main/java/com/podio/contact/ContactOrder.java b/src/main/java/com/podio/contact/ContactOrder.java index d9f29f4..1c733cf 100644 --- a/src/main/java/com/podio/contact/ContactOrder.java +++ b/src/main/java/com/podio/contact/ContactOrder.java @@ -1,31 +1,31 @@ -package com.podio.contact; - -public enum ContactOrder { - - /** - * How often the active user assigns tasks to the contact - */ - TASK, - - /** - * How often the active user receives messages from the contact - */ - MESSAGE_IN, - - /** - * How often the active user sends messages to the contact - */ - MESSAGE_OUT, - - /** - * How often the active user sets the contact as the reference on an item - * field. - */ - REFERENCE, - - /** - * How often the active user have alerted the contact in a status or - * comment. - */ - ALERT; -} +package com.podio.contact; + +public enum ContactOrder { + + /** + * How often the active user assigns tasks to the contact + */ + TASK, + + /** + * How often the active user receives messages from the contact + */ + MESSAGE_IN, + + /** + * How often the active user sends messages to the contact + */ + MESSAGE_OUT, + + /** + * How often the active user sets the contact as the reference on an item + * field. + */ + REFERENCE, + + /** + * How often the active user have alerted the contact in a status or + * comment. + */ + ALERT; +} diff --git a/src/main/java/com/podio/contact/ContactTotal.java b/src/main/java/com/podio/contact/ContactTotal.java index 5d117bc..c1c2bca 100644 --- a/src/main/java/com/podio/contact/ContactTotal.java +++ b/src/main/java/com/podio/contact/ContactTotal.java @@ -1,25 +1,25 @@ -package com.podio.contact; - -public class ContactTotal { - - private UserContactTotal user; - - private ConnectionsContactTotal connection; - - public UserContactTotal getUser() { - return user; - } - - public void setUser(UserContactTotal user) { - this.user = user; - } - - public ConnectionsContactTotal getConnection() { - return connection; - } - - public void setConnection(ConnectionsContactTotal connection) { - this.connection = connection; - } - -} +package com.podio.contact; + +public class ContactTotal { + + private UserContactTotal user; + + private ConnectionsContactTotal connection; + + public UserContactTotal getUser() { + return user; + } + + public void setUser(UserContactTotal user) { + this.user = user; + } + + public ConnectionsContactTotal getConnection() { + return connection; + } + + public void setConnection(ConnectionsContactTotal connection) { + this.connection = connection; + } + +} diff --git a/src/main/java/com/podio/contact/ContactType.java b/src/main/java/com/podio/contact/ContactType.java index 5e7a1e5..fb91ea3 100644 --- a/src/main/java/com/podio/contact/ContactType.java +++ b/src/main/java/com/podio/contact/ContactType.java @@ -1,14 +1,14 @@ -package com.podio.contact; - -public enum ContactType { - - /** - * Contact of type user - */ - USER, - - /** - * A space contact - */ - SPACE; -} +package com.podio.contact; + +public enum ContactType { + + /** + * Contact of type user + */ + USER, + + /** + * A space contact + */ + SPACE; +} diff --git a/src/main/java/com/podio/contact/ContactUpdate.java b/src/main/java/com/podio/contact/ContactUpdate.java index 3d70fa9..6fa4233 100644 --- a/src/main/java/com/podio/contact/ContactUpdate.java +++ b/src/main/java/com/podio/contact/ContactUpdate.java @@ -1,323 +1,323 @@ -package com.podio.contact; - -import java.util.Collections; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.LocalDate; - -public class ContactUpdate { - - /** - * The full name - */ - private String name; - - /** - * The file id of the avatar - */ - private Integer avatar; - - /** - * The birthdate - */ - private LocalDate birthdate; - - /** - * The organization or company the person is associated with - */ - private String organization; - - /** - * The department of the organization  - */ - private String department; - - /** - * The username for Skype  - */ - private String skype; - - /** - * Short text about the person - */ - private String about; - - /** - * The address where the person lives or work  - */ - private List addresses; - - /** - * The zip code of the address  - */ - private String zip; - - /** - * The name of the city - */ - private String city; - - /** - * The name of the state, only applicable in some countries - */ - private String state; - - /** - * The name of the country  - */ - private String country; - - /** - * The location of the person - */ - private List locations; - - /** - * Email address - */ - private List mails; - - /** - * The phone number  - */ - private List phones; - - /** - * The persons title, usually the work title - */ - private List titles; - - /** - * The full URL of the users LinkedIn profile - */ - private String linkedin; - - /** - * The name of the users Twitter profile - */ - private String twitter; - - /** - * An URL to the persons homepage or the homepage of the company  - */ - private List urls; - - /** - * The skill of the user - */ - private List skills; - - public ContactUpdate() { - this(null, null, null, null, null, null, null, Collections.emptyList(), - null, null, null, null, Collections.emptyList(), - Collections.emptyList(), Collections.emptyList(), - Collections.emptyList(), null, null, - Collections.emptyList(), Collections.emptyList()); - } - - public ContactUpdate(String name, Integer avatar, LocalDate birthdate, - String organization, String department, String skype, String about, - List addresses, String zip, String city, String state, - String country, List locations, List mails, - List phones, List titles, String linkedin, - String twitter, List urls, List skills) { - super(); - - this.name = name; - this.avatar = avatar; - this.birthdate = birthdate; - this.organization = organization; - this.department = department; - this.skype = skype; - this.about = about; - this.addresses = addresses; - this.zip = zip; - this.city = city; - this.state = state; - this.country = country; - this.locations = locations; - this.mails = mails; - this.phones = phones; - this.titles = titles; - this.linkedin = linkedin; - this.twitter = twitter; - this.urls = urls; - this.skills = skills; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getAvatar() { - return avatar; - } - - public void setAvatar(Integer avatar) { - this.avatar = avatar; - } - - public LocalDate getBirthdate() { - return birthdate; - } - - public void setBirthdate(LocalDate birthdate) { - this.birthdate = birthdate; - } - - public String getOrganization() { - return organization; - } - - public void setOrganization(String organization) { - this.organization = organization; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public String getSkype() { - return skype; - } - - public void setSkype(String skype) { - this.skype = skype; - } - - public String getAbout() { - return about; - } - - public void setAbout(String about) { - this.about = about; - } - - @JsonProperty("adress") - public List getAddresses() { - return addresses; - } - - @JsonProperty("adress") - public void setAddresses(List addresses) { - this.addresses = addresses; - } - - public String getZip() { - return zip; - } - - public void setZip(String zip) { - this.zip = zip; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - @JsonProperty("location") - public List getLocations() { - return locations; - } - - @JsonProperty("location") - public void setLocations(List locations) { - this.locations = locations; - } - - @JsonProperty("mail") - public List getMails() { - return mails; - } - - @JsonProperty("mail") - public void setMails(List mails) { - this.mails = mails; - } - - @JsonProperty("phone") - public List getPhones() { - return phones; - } - - @JsonProperty("phone") - public void setPhones(List phones) { - this.phones = phones; - } - - @JsonProperty("title") - public List getTitles() { - return titles; - } - - @JsonProperty("title") - public void setTitles(List titles) { - this.titles = titles; - } - - public String getLinkedin() { - return linkedin; - } - - public void setLinkedin(String linkedin) { - this.linkedin = linkedin; - } - - public String getTwitter() { - return twitter; - } - - public void setTwitter(String twitter) { - this.twitter = twitter; - } - - @JsonProperty("url") - public List getUrls() { - return urls; - } - - @JsonProperty("url") - public void setUrls(List urls) { - this.urls = urls; - } - - @JsonProperty("skill") - public List getSkills() { - return skills; - } - - @JsonProperty("skill") - public void setSkills(List skills) { - this.skills = skills; - } - -} +package com.podio.contact; + +import java.util.Collections; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.LocalDate; + +public class ContactUpdate { + + /** + * The full name + */ + private String name; + + /** + * The file id of the avatar + */ + private Integer avatar; + + /** + * The birthdate + */ + private LocalDate birthdate; + + /** + * The organization or company the person is associated with + */ + private String organization; + + /** + * The department of the organization  + */ + private String department; + + /** + * The username for Skype  + */ + private String skype; + + /** + * Short text about the person + */ + private String about; + + /** + * The address where the person lives or work  + */ + private List addresses; + + /** + * The zip code of the address  + */ + private String zip; + + /** + * The name of the city + */ + private String city; + + /** + * The name of the state, only applicable in some countries + */ + private String state; + + /** + * The name of the country  + */ + private String country; + + /** + * The location of the person + */ + private List locations; + + /** + * Email address + */ + private List mails; + + /** + * The phone number  + */ + private List phones; + + /** + * The persons title, usually the work title + */ + private List titles; + + /** + * The full URL of the users LinkedIn profile + */ + private String linkedin; + + /** + * The name of the users Twitter profile + */ + private String twitter; + + /** + * An URL to the persons homepage or the homepage of the company  + */ + private List urls; + + /** + * The skill of the user + */ + private List skills; + + public ContactUpdate() { + this(null, null, null, null, null, null, null, Collections.emptyList(), + null, null, null, null, Collections.emptyList(), + Collections.emptyList(), Collections.emptyList(), + Collections.emptyList(), null, null, + Collections.emptyList(), Collections.emptyList()); + } + + public ContactUpdate(String name, Integer avatar, LocalDate birthdate, + String organization, String department, String skype, String about, + List addresses, String zip, String city, String state, + String country, List locations, List mails, + List phones, List titles, String linkedin, + String twitter, List urls, List skills) { + super(); + + this.name = name; + this.avatar = avatar; + this.birthdate = birthdate; + this.organization = organization; + this.department = department; + this.skype = skype; + this.about = about; + this.addresses = addresses; + this.zip = zip; + this.city = city; + this.state = state; + this.country = country; + this.locations = locations; + this.mails = mails; + this.phones = phones; + this.titles = titles; + this.linkedin = linkedin; + this.twitter = twitter; + this.urls = urls; + this.skills = skills; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAvatar() { + return avatar; + } + + public void setAvatar(Integer avatar) { + this.avatar = avatar; + } + + public LocalDate getBirthdate() { + return birthdate; + } + + public void setBirthdate(LocalDate birthdate) { + this.birthdate = birthdate; + } + + public String getOrganization() { + return organization; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getSkype() { + return skype; + } + + public void setSkype(String skype) { + this.skype = skype; + } + + public String getAbout() { + return about; + } + + public void setAbout(String about) { + this.about = about; + } + + @JsonProperty("adress") + public List getAddresses() { + return addresses; + } + + @JsonProperty("adress") + public void setAddresses(List addresses) { + this.addresses = addresses; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + @JsonProperty("location") + public List getLocations() { + return locations; + } + + @JsonProperty("location") + public void setLocations(List locations) { + this.locations = locations; + } + + @JsonProperty("mail") + public List getMails() { + return mails; + } + + @JsonProperty("mail") + public void setMails(List mails) { + this.mails = mails; + } + + @JsonProperty("phone") + public List getPhones() { + return phones; + } + + @JsonProperty("phone") + public void setPhones(List phones) { + this.phones = phones; + } + + @JsonProperty("title") + public List getTitles() { + return titles; + } + + @JsonProperty("title") + public void setTitles(List titles) { + this.titles = titles; + } + + public String getLinkedin() { + return linkedin; + } + + public void setLinkedin(String linkedin) { + this.linkedin = linkedin; + } + + public String getTwitter() { + return twitter; + } + + public void setTwitter(String twitter) { + this.twitter = twitter; + } + + @JsonProperty("url") + public List getUrls() { + return urls; + } + + @JsonProperty("url") + public void setUrls(List urls) { + this.urls = urls; + } + + @JsonProperty("skill") + public List getSkills() { + return skills; + } + + @JsonProperty("skill") + public void setSkills(List skills) { + this.skills = skills; + } + +} diff --git a/src/main/java/com/podio/contact/OrganizationContactTotal.java b/src/main/java/com/podio/contact/OrganizationContactTotal.java index e54705a..b150bda 100644 --- a/src/main/java/com/podio/contact/OrganizationContactTotal.java +++ b/src/main/java/com/podio/contact/OrganizationContactTotal.java @@ -1,38 +1,38 @@ -package com.podio.contact; - -import java.util.List; - -import com.podio.org.Organization; - -public class OrganizationContactTotal { - - private Organization org; - - private int count; - - private List spaces; - - public Organization getOrg() { - return org; - } - - public void setOrg(Organization org) { - this.org = org; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } - - public List getSpaces() { - return spaces; - } - - public void setSpaces(List spaces) { - this.spaces = spaces; - } -} +package com.podio.contact; + +import java.util.List; + +import com.podio.org.Organization; + +public class OrganizationContactTotal { + + private Organization org; + + private int count; + + private List spaces; + + public Organization getOrg() { + return org; + } + + public void setOrg(Organization org) { + this.org = org; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public List getSpaces() { + return spaces; + } + + public void setSpaces(List spaces) { + this.spaces = spaces; + } +} diff --git a/src/main/java/com/podio/contact/Profile.java b/src/main/java/com/podio/contact/Profile.java index e61575e..9dd0679 100644 --- a/src/main/java/com/podio/contact/Profile.java +++ b/src/main/java/com/podio/contact/Profile.java @@ -1,47 +1,47 @@ -package com.podio.contact; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -public class Profile extends ProfileUpdate { - - /** - * The id of the profile - */ - private int profileId; - - /** - * The id of the user - */ - private Integer userId; - - /** - * The last time the user was seen - */ - private DateTime lastSeenOn; - - @JsonProperty("profile_id") - public int getProfileId() { - return profileId; - } - - @JsonProperty("profile_id") - public void setProfileId(int profileId) { - this.profileId = profileId; - } - - @JsonProperty("user_id") - public Integer getUserId() { - return userId; - } - - @JsonProperty("user_id") - public void setUserId(Integer userId) { - this.userId = userId; - } - - @JsonProperty("last_seen_on") - public DateTime getLastSeenOn() { - return lastSeenOn; - } -} +package com.podio.contact; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +public class Profile extends ProfileUpdate { + + /** + * The id of the profile + */ + private int profileId; + + /** + * The id of the user + */ + private Integer userId; + + /** + * The last time the user was seen + */ + private DateTime lastSeenOn; + + @JsonProperty("profile_id") + public int getProfileId() { + return profileId; + } + + @JsonProperty("profile_id") + public void setProfileId(int profileId) { + this.profileId = profileId; + } + + @JsonProperty("user_id") + public Integer getUserId() { + return userId; + } + + @JsonProperty("user_id") + public void setUserId(Integer userId) { + this.userId = userId; + } + + @JsonProperty("last_seen_on") + public DateTime getLastSeenOn() { + return lastSeenOn; + } +} diff --git a/src/main/java/com/podio/contact/ProfileBase.java b/src/main/java/com/podio/contact/ProfileBase.java index c71e492..e2aa451 100644 --- a/src/main/java/com/podio/contact/ProfileBase.java +++ b/src/main/java/com/podio/contact/ProfileBase.java @@ -1,63 +1,63 @@ -package com.podio.contact; - -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ProfileBase implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the profile - */ - private int profileId; - - /** - * The id of the user - */ - private Integer userId; - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + profileId; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ProfileBase other = (ProfileBase) obj; - if (profileId != other.profileId) - return false; - return true; - } - - @JsonProperty("profile_id") - public int getProfileId() { - return profileId; - } - - @JsonProperty("profile_id") - public void setProfileId(int profileId) { - this.profileId = profileId; - } - - @JsonProperty("user_id") - public Integer getUserId() { - return userId; - } - - @JsonProperty("user_id") - public void setUserId(Integer userId) { - this.userId = userId; - } - -} +package com.podio.contact; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ProfileBase implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the profile + */ + private int profileId; + + /** + * The id of the user + */ + private Integer userId; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + profileId; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ProfileBase other = (ProfileBase) obj; + if (profileId != other.profileId) + return false; + return true; + } + + @JsonProperty("profile_id") + public int getProfileId() { + return profileId; + } + + @JsonProperty("profile_id") + public void setProfileId(int profileId) { + this.profileId = profileId; + } + + @JsonProperty("user_id") + public Integer getUserId() { + return userId; + } + + @JsonProperty("user_id") + public void setUserId(Integer userId) { + this.userId = userId; + } + +} diff --git a/src/main/java/com/podio/contact/ProfileField.java b/src/main/java/com/podio/contact/ProfileField.java index 95a6a76..1435f64 100644 --- a/src/main/java/com/podio/contact/ProfileField.java +++ b/src/main/java/com/podio/contact/ProfileField.java @@ -1,182 +1,182 @@ -package com.podio.contact; - -import java.util.HashMap; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; -import org.joda.time.LocalDate; - -import com.podio.serialize.DateTimeUtil; - -public abstract class ProfileField { - - private static final Map> MAP = new HashMap>(); - - /** - * The full name - */ - public static final ProfileField NAME = new StringProfileField( - "name", true); - - /** - * The file id of the avatar - */ - public static final ProfileField AVATAR = new IntegerProfileField( - "avatar", true); - - /** - * The birthdate - */ - public static final ProfileField BIRTHDATE = new DateProfileField( - "birthdate", true); - - /** - * The organization or company the person is associated with - */ - public static final ProfileField ORGANIZATION = new StringProfileField( - "organization", true); - - /** - * The username for Skype - */ - public static final ProfileField SKYPE = new StringProfileField( - "skype", true); - - /** - * Short text about the person - */ - public static final ProfileField ABOUT = new StringProfileField( - "about", true); - - /** - * Email address - */ - public static final ProfileField MAIL = new StringProfileField( - "mail", false); - - /** - * The address where the person lives or work - */ - public static final ProfileField ADDRESS = new StringProfileField( - "address", false); - - /** - * Any instant messaging address - */ - public static final ProfileField IM = new StringProfileField( - "im", false); - - /** - * The location of the person - */ - public static final ProfileField LOCATION = new StringProfileField( - "location", false); - - /** - * The phone number - */ - public static final ProfileField PHONE = new StringProfileField( - "phone", false); - - /** - * The persons title, usually the work title - */ - public static final ProfileField TITLE = new StringProfileField( - "title", false); - - /** - * An URL to the persons homepage or the homepage of the company - */ - public static final ProfileField URL = new StringProfileField( - "url", false); - - private final String name; - - private final boolean single; - - public ProfileField(String name, boolean single) { - super(); - this.name = name; - this.single = single; - - MAP.put(name, this); - } - - @JsonValue - public String getName() { - return name; - } - - public boolean isSingle() { - return single; - } - - @Override - public String toString() { - return getName(); - } - - public abstract F parse(R object); - - public abstract R format(F object); - - private static class StringProfileField extends - ProfileField { - - public StringProfileField(String name, boolean single) { - super(name, single); - } - - @Override - public String parse(String object) { - return object; - } - - @Override - public String format(String object) { - return object; - } - } - - private static class IntegerProfileField extends - ProfileField { - - public IntegerProfileField(String name, boolean single) { - super(name, single); - } - - @Override - public Integer parse(Integer object) { - return object; - } - - @Override - public Integer format(Integer object) { - return object; - } - } - - private static class DateProfileField extends - ProfileField { - - public DateProfileField(String name, boolean single) { - super(name, single); - } - - @Override - public LocalDate parse(String object) { - return DateTimeUtil.parseDate(object); - } - - @Override - public String format(LocalDate object) { - return DateTimeUtil.formatDate(object); - } - } - - @JsonCreator - public static ProfileField getByName(String value) { - return MAP.get(value); - } -} +package com.podio.contact; + +import java.util.HashMap; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; +import org.joda.time.LocalDate; + +import com.podio.serialize.DateTimeUtil; + +public abstract class ProfileField { + + private static final Map> MAP = new HashMap>(); + + /** + * The full name + */ + public static final ProfileField NAME = new StringProfileField( + "name", true); + + /** + * The file id of the avatar + */ + public static final ProfileField AVATAR = new IntegerProfileField( + "avatar", true); + + /** + * The birthdate + */ + public static final ProfileField BIRTHDATE = new DateProfileField( + "birthdate", true); + + /** + * The organization or company the person is associated with + */ + public static final ProfileField ORGANIZATION = new StringProfileField( + "organization", true); + + /** + * The username for Skype + */ + public static final ProfileField SKYPE = new StringProfileField( + "skype", true); + + /** + * Short text about the person + */ + public static final ProfileField ABOUT = new StringProfileField( + "about", true); + + /** + * Email address + */ + public static final ProfileField MAIL = new StringProfileField( + "mail", false); + + /** + * The address where the person lives or work + */ + public static final ProfileField ADDRESS = new StringProfileField( + "address", false); + + /** + * Any instant messaging address + */ + public static final ProfileField IM = new StringProfileField( + "im", false); + + /** + * The location of the person + */ + public static final ProfileField LOCATION = new StringProfileField( + "location", false); + + /** + * The phone number + */ + public static final ProfileField PHONE = new StringProfileField( + "phone", false); + + /** + * The persons title, usually the work title + */ + public static final ProfileField TITLE = new StringProfileField( + "title", false); + + /** + * An URL to the persons homepage or the homepage of the company + */ + public static final ProfileField URL = new StringProfileField( + "url", false); + + private final String name; + + private final boolean single; + + public ProfileField(String name, boolean single) { + super(); + this.name = name; + this.single = single; + + MAP.put(name, this); + } + + @JsonValue + public String getName() { + return name; + } + + public boolean isSingle() { + return single; + } + + @Override + public String toString() { + return getName(); + } + + public abstract F parse(R object); + + public abstract R format(F object); + + private static class StringProfileField extends + ProfileField { + + public StringProfileField(String name, boolean single) { + super(name, single); + } + + @Override + public String parse(String object) { + return object; + } + + @Override + public String format(String object) { + return object; + } + } + + private static class IntegerProfileField extends + ProfileField { + + public IntegerProfileField(String name, boolean single) { + super(name, single); + } + + @Override + public Integer parse(Integer object) { + return object; + } + + @Override + public Integer format(Integer object) { + return object; + } + } + + private static class DateProfileField extends + ProfileField { + + public DateProfileField(String name, boolean single) { + super(name, single); + } + + @Override + public LocalDate parse(String object) { + return DateTimeUtil.parseDate(object); + } + + @Override + public String format(LocalDate object) { + return DateTimeUtil.formatDate(object); + } + } + + @JsonCreator + public static ProfileField getByName(String value) { + return MAP.get(value); + } +} diff --git a/src/main/java/com/podio/contact/ProfileFieldValues.java b/src/main/java/com/podio/contact/ProfileFieldValues.java index 9c404ed..087f60f 100644 --- a/src/main/java/com/podio/contact/ProfileFieldValues.java +++ b/src/main/java/com/podio/contact/ProfileFieldValues.java @@ -1,51 +1,51 @@ -package com.podio.contact; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonValue; - -public final class ProfileFieldValues { - - private Map, Object> values = new HashMap, Object>(); - - @JsonValue - public Map, Object> getValues() { - return values; - } - - public void setValues(Map, Object> values) { - this.values = values; - } - - public void setValue(ProfileField field, F value) { - if (field.isSingle()) { - values.put(field, value); - } else { - values.put(field, Collections.singletonList(value)); - } - } - - public F getValue(ProfileField field) { - if (field.isSingle()) { - return (F) values.get(field); - } else { - List list = (List) values.get(field); - if (list == null || list.isEmpty()) { - return null; - } - - return (F) list.get(0); - } - } - - public void setValues(ProfileField field, List values) { - this.values.put(field, values); - } - - public List getValues(ProfileField field) { - return (List) values.get(field); - } +package com.podio.contact; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonValue; + +public final class ProfileFieldValues { + + private Map, Object> values = new HashMap, Object>(); + + @JsonValue + public Map, Object> getValues() { + return values; + } + + public void setValues(Map, Object> values) { + this.values = values; + } + + public void setValue(ProfileField field, F value) { + if (field.isSingle()) { + values.put(field, value); + } else { + values.put(field, Collections.singletonList(value)); + } + } + + public F getValue(ProfileField field) { + if (field.isSingle()) { + return (F) values.get(field); + } else { + List list = (List) values.get(field); + if (list == null || list.isEmpty()) { + return null; + } + + return (F) list.get(0); + } + } + + public void setValues(ProfileField field, List values) { + this.values.put(field, values); + } + + public List getValues(ProfileField field) { + return (List) values.get(field); + } } \ No newline at end of file diff --git a/src/main/java/com/podio/contact/ProfileMini.java b/src/main/java/com/podio/contact/ProfileMini.java index 80cdf6b..b4a0b6d 100644 --- a/src/main/java/com/podio/contact/ProfileMini.java +++ b/src/main/java/com/podio/contact/ProfileMini.java @@ -1,33 +1,33 @@ -package com.podio.contact; - - -public class ProfileMini extends ProfileBase { - - private static final long serialVersionUID = 1L; - - private Integer avatar; - - private String name; - - @Override - public String toString() { - return "ProfileMini [profileId=" + getProfileId() + ", avatar=" - + avatar + ", name=" + name + "]"; - } - - public Integer getAvatar() { - return avatar; - } - - public void setAvatar(Integer avatar) { - this.avatar = avatar; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} +package com.podio.contact; + + +public class ProfileMini extends ProfileBase { + + private static final long serialVersionUID = 1L; + + private Integer avatar; + + private String name; + + @Override + public String toString() { + return "ProfileMini [profileId=" + getProfileId() + ", avatar=" + + avatar + ", name=" + name + "]"; + } + + public Integer getAvatar() { + return avatar; + } + + public void setAvatar(Integer avatar) { + this.avatar = avatar; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/podio/contact/ProfileType.java b/src/main/java/com/podio/contact/ProfileType.java index 2fac4fc..1051901 100644 --- a/src/main/java/com/podio/contact/ProfileType.java +++ b/src/main/java/com/podio/contact/ProfileType.java @@ -1,27 +1,27 @@ -package com.podio.contact; - -public class ProfileType { - - public static final ProfileType FULL = new ProfileType( - "full", Profile.class); - public static final ProfileType MINI = new ProfileType( - "mini", ProfileMini.class); - - private final String name; - - private final Class type; - - public ProfileType(String name, Class type) { - super(); - this.name = name; - this.type = type; - } - - public String getName() { - return name; - } - - public Class getType() { - return type; - } -} +package com.podio.contact; + +public class ProfileType { + + public static final ProfileType FULL = new ProfileType( + "full", Profile.class); + public static final ProfileType MINI = new ProfileType( + "mini", ProfileMini.class); + + private final String name; + + private final Class type; + + public ProfileType(String name, Class type) { + super(); + this.name = name; + this.type = type; + } + + public String getName() { + return name; + } + + public Class getType() { + return type; + } +} diff --git a/src/main/java/com/podio/contact/ProfileUpdate.java b/src/main/java/com/podio/contact/ProfileUpdate.java index c66b4bc..55e4497 100644 --- a/src/main/java/com/podio/contact/ProfileUpdate.java +++ b/src/main/java/com/podio/contact/ProfileUpdate.java @@ -1,259 +1,259 @@ -package com.podio.contact; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.LocalDate; - -import com.podio.file.File; - -public class ProfileUpdate { - - /** - * The full name - */ - private String name; - - /** - * The file id of the avatar - */ - private Integer avatar; - - /** - * The image details for the user - */ - private File image; - - /** - * The birthdate - */ - private LocalDate birthdate; - - /** - * The organization or company the person is associated with - */ - private String organization; - - /** - * The username for Skype - */ - private String skype; - - /** - * Short text about the person - */ - private String about; - - /** - * The zip code of the address - */ - private String zip; - - /** - * The name of the city - */ - private String city; - - /** - * The name of the state, only applicable in some countries - */ - private String state; - - /** - * The name of the country - */ - private String country; - - /** - * The addresses where the person lives or work - */ - private List addresses; - - /** - * Any instant messaging address - */ - private List ims; - - /** - * The locations of the person - */ - private List locations; - - /** - * Email addresses - */ - private List mails; - - /** - * The phone numbers - */ - private List phones; - - /** - * The persons title, usually the work title - */ - private List titles; - - /** - * An URL to the persons homepage or the homepage of the company - */ - private List urls; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getAvatar() { - return avatar; - } - - public void setAvatar(Integer avatar) { - this.avatar = avatar; - } - - public File getImage() { - return image; - } - - public void setImage(File image) { - this.image = image; - } - - public LocalDate getBirthdate() { - return birthdate; - } - - public void setBirthdate(LocalDate birthdate) { - this.birthdate = birthdate; - } - - public String getOrganization() { - return organization; - } - - public void setOrganization(String organization) { - this.organization = organization; - } - - public String getSkype() { - return skype; - } - - public void setSkype(String skype) { - this.skype = skype; - } - - public String getAbout() { - return about; - } - - public void setAbout(String about) { - this.about = about; - } - - public String getZip() { - return zip; - } - - public void setZip(String zip) { - this.zip = zip; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - @JsonProperty("address") - public List getAddresses() { - return addresses; - } - - @JsonProperty("address") - public void setAddresses(List addresses) { - this.addresses = addresses; - } - - @JsonProperty("im") - public List getIms() { - return ims; - } - - @JsonProperty("im") - public void setIms(List ims) { - this.ims = ims; - } - - @JsonProperty("location") - public List getLocations() { - return locations; - } - - @JsonProperty("location") - public void setLocations(List locations) { - this.locations = locations; - } - - @JsonProperty("mail") - public List getMails() { - return mails; - } - - @JsonProperty("mail") - public void setMails(List mails) { - this.mails = mails; - } - - @JsonProperty("phone") - public List getPhones() { - return phones; - } - - @JsonProperty("phone") - public void setPhones(List phones) { - this.phones = phones; - } - - @JsonProperty("title") - public List getTitles() { - return titles; - } - - @JsonProperty("title") - public void setTitles(List titles) { - this.titles = titles; - } - - @JsonProperty("url") - public List getUrls() { - return urls; - } - - @JsonProperty("url") - public void setUrls(List urls) { - this.urls = urls; - } -} +package com.podio.contact; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.LocalDate; + +import com.podio.file.File; + +public class ProfileUpdate { + + /** + * The full name + */ + private String name; + + /** + * The file id of the avatar + */ + private Integer avatar; + + /** + * The image details for the user + */ + private File image; + + /** + * The birthdate + */ + private LocalDate birthdate; + + /** + * The organization or company the person is associated with + */ + private String organization; + + /** + * The username for Skype + */ + private String skype; + + /** + * Short text about the person + */ + private String about; + + /** + * The zip code of the address + */ + private String zip; + + /** + * The name of the city + */ + private String city; + + /** + * The name of the state, only applicable in some countries + */ + private String state; + + /** + * The name of the country + */ + private String country; + + /** + * The addresses where the person lives or work + */ + private List addresses; + + /** + * Any instant messaging address + */ + private List ims; + + /** + * The locations of the person + */ + private List locations; + + /** + * Email addresses + */ + private List mails; + + /** + * The phone numbers + */ + private List phones; + + /** + * The persons title, usually the work title + */ + private List titles; + + /** + * An URL to the persons homepage or the homepage of the company + */ + private List urls; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAvatar() { + return avatar; + } + + public void setAvatar(Integer avatar) { + this.avatar = avatar; + } + + public File getImage() { + return image; + } + + public void setImage(File image) { + this.image = image; + } + + public LocalDate getBirthdate() { + return birthdate; + } + + public void setBirthdate(LocalDate birthdate) { + this.birthdate = birthdate; + } + + public String getOrganization() { + return organization; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public String getSkype() { + return skype; + } + + public void setSkype(String skype) { + this.skype = skype; + } + + public String getAbout() { + return about; + } + + public void setAbout(String about) { + this.about = about; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + @JsonProperty("address") + public List getAddresses() { + return addresses; + } + + @JsonProperty("address") + public void setAddresses(List addresses) { + this.addresses = addresses; + } + + @JsonProperty("im") + public List getIms() { + return ims; + } + + @JsonProperty("im") + public void setIms(List ims) { + this.ims = ims; + } + + @JsonProperty("location") + public List getLocations() { + return locations; + } + + @JsonProperty("location") + public void setLocations(List locations) { + this.locations = locations; + } + + @JsonProperty("mail") + public List getMails() { + return mails; + } + + @JsonProperty("mail") + public void setMails(List mails) { + this.mails = mails; + } + + @JsonProperty("phone") + public List getPhones() { + return phones; + } + + @JsonProperty("phone") + public void setPhones(List phones) { + this.phones = phones; + } + + @JsonProperty("title") + public List getTitles() { + return titles; + } + + @JsonProperty("title") + public void setTitles(List titles) { + this.titles = titles; + } + + @JsonProperty("url") + public List getUrls() { + return urls; + } + + @JsonProperty("url") + public void setUrls(List urls) { + this.urls = urls; + } +} diff --git a/src/main/java/com/podio/contact/SpaceContactTotal.java b/src/main/java/com/podio/contact/SpaceContactTotal.java index aaeb616..c7e4d33 100644 --- a/src/main/java/com/podio/contact/SpaceContactTotal.java +++ b/src/main/java/com/podio/contact/SpaceContactTotal.java @@ -1,26 +1,26 @@ -package com.podio.contact; - -import com.podio.space.Space; - -public class SpaceContactTotal { - - private Space space; - - private int count; - - public Space getSpace() { - return space; - } - - public void setSpace(Space space) { - this.space = space; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } -} +package com.podio.contact; + +import com.podio.space.Space; + +public class SpaceContactTotal { + + private Space space; + + private int count; + + public Space getSpace() { + return space; + } + + public void setSpace(Space space) { + this.space = space; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/src/main/java/com/podio/contact/SpaceContactTotals.java b/src/main/java/com/podio/contact/SpaceContactTotals.java index dea928d..21ae0c7 100644 --- a/src/main/java/com/podio/contact/SpaceContactTotals.java +++ b/src/main/java/com/podio/contact/SpaceContactTotals.java @@ -1,14 +1,14 @@ -package com.podio.contact; - -public class SpaceContactTotals { - - private int total; - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } -} +package com.podio.contact; + +public class SpaceContactTotals { + + private int total; + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } +} diff --git a/src/main/java/com/podio/contact/UserContactTotal.java b/src/main/java/com/podio/contact/UserContactTotal.java index b8a639b..185e342 100644 --- a/src/main/java/com/podio/contact/UserContactTotal.java +++ b/src/main/java/com/podio/contact/UserContactTotal.java @@ -1,26 +1,26 @@ -package com.podio.contact; - -import java.util.List; - -public class UserContactTotal { - - private List organizations; - - private int count; - - public List getOrganizations() { - return organizations; - } - - public void setOrganizations(List organizations) { - this.organizations = organizations; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } -} +package com.podio.contact; + +import java.util.List; + +public class UserContactTotal { + + private List organizations; + + private int count; + + public List getOrganizations() { + return organizations; + } + + public void setOrganizations(List organizations) { + this.organizations = organizations; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/src/main/java/com/podio/conversation/Conversation.java b/src/main/java/com/podio/conversation/Conversation.java index bf5e262..d725009 100644 --- a/src/main/java/com/podio/conversation/Conversation.java +++ b/src/main/java/com/podio/conversation/Conversation.java @@ -1,51 +1,51 @@ -package com.podio.conversation; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.contact.ProfileMini; - -public class Conversation { - - /** - * The id of the conversation - */ - private int id; - - /** - * The subject of the conversation - */ - private String subject; - - /** - * The list of participants in the conversation - */ - private List participants; - - @JsonProperty("conversation_id") - public int getId() { - return id; - } - - @JsonProperty("conversation_id") - public void setId(int id) { - this.id = id; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public List getParticipants() { - return participants; - } - - public void setParticipants(List participants) { - this.participants = participants; - } -} +package com.podio.conversation; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.contact.ProfileMini; + +public class Conversation { + + /** + * The id of the conversation + */ + private int id; + + /** + * The subject of the conversation + */ + private String subject; + + /** + * The list of participants in the conversation + */ + private List participants; + + @JsonProperty("conversation_id") + public int getId() { + return id; + } + + @JsonProperty("conversation_id") + public void setId(int id) { + this.id = id; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public List getParticipants() { + return participants; + } + + public void setParticipants(List participants) { + this.participants = participants; + } +} diff --git a/src/main/java/com/podio/conversation/ConversationAPI.java b/src/main/java/com/podio/conversation/ConversationAPI.java index 1b0a6ec..7df82bd 100644 --- a/src/main/java/com/podio/conversation/ConversationAPI.java +++ b/src/main/java/com/podio/conversation/ConversationAPI.java @@ -1,113 +1,113 @@ -package com.podio.conversation; - -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.Reference; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; - -public class ConversationAPI extends BaseAPI { - - public ConversationAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Creates a new conversation with a list of users. Once a conversation is - * started, the participants cannot (yet) be changed. - * - * @param subject - * The subject of the conversation - * @param text - * The text of the first message in the conversation - * @param participants - * List of participants in the conversation (not including the - * sender) - * @return The id of the newly created conversation - */ - public int createConversation(String subject, String text, - List participants) { - return createConversation(subject, text, participants, null); - } - - /** - * Creates a new conversation with a list of users. Once a conversation is - * started, the participants cannot (yet) be changed. - * - * @param subject - * The subject of the conversation - * @param text - * The text of the first message in the conversation - * @param participants - * List of participants in the conversation (not including the - * sender) - * @param reference - * The object the conversation should be created on, if any - * @return The id of the newly created conversation - */ - public int createConversation(String subject, String text, - List participants, Reference reference) { - WebResource resource; - if (reference != null) { - resource = getResourceFactory().getApiResource( - "/conversation/" + reference.toURLFragment()); - } else { - resource = getResourceFactory().getApiResource("/conversation/"); - } - - return resource - .entity(new ConversationCreate(subject, text, participants), - MediaType.APPLICATION_JSON_TYPE) - .post(ConversationCreateResponse.class).getConversationId(); - } - - /** - * Gets the conversation including participants and messages with the the - * given id. Only participants in the conversation is allowed to view the - * conversation. - * - * @param conversationId - * The id of the conversation to get - * @return The conversation requested - */ - public Conversation getConversation(int conversationId) { - return getResourceFactory().getApiResource( - "/conversation/" + conversationId).get(Conversation.class); - } - - /** - * Returns a list of all the conversations on the object that the active - * user is part of. - * - * @param object - * The object to get conversations on - * @return The list of conversations - */ - public List getConversationsOnObject(Reference object) { - return getResourceFactory().getApiResource( - "/conversation/" + object.toURLFragment()).get( - new GenericType>() { - }); - } - - /** - * Creates a reply to the conversation. - * - * @param conversationId - * The id of the conversation to reply to - * @param text - * The text of the reply - * @return The id of the new message - */ - public int addReply(int conversationId, String text) { - return getResourceFactory() - .getApiResource("/conversation/" + conversationId + "/reply") - .entity(new MessageCreate(text), - MediaType.APPLICATION_JSON_TYPE) - .get(MessageCreateResponse.class).getMessageId(); - } -} +package com.podio.conversation; + +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.Reference; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; + +public class ConversationAPI extends BaseAPI { + + public ConversationAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Creates a new conversation with a list of users. Once a conversation is + * started, the participants cannot (yet) be changed. + * + * @param subject + * The subject of the conversation + * @param text + * The text of the first message in the conversation + * @param participants + * List of participants in the conversation (not including the + * sender) + * @return The id of the newly created conversation + */ + public int createConversation(String subject, String text, + List participants) { + return createConversation(subject, text, participants, null); + } + + /** + * Creates a new conversation with a list of users. Once a conversation is + * started, the participants cannot (yet) be changed. + * + * @param subject + * The subject of the conversation + * @param text + * The text of the first message in the conversation + * @param participants + * List of participants in the conversation (not including the + * sender) + * @param reference + * The object the conversation should be created on, if any + * @return The id of the newly created conversation + */ + public int createConversation(String subject, String text, + List participants, Reference reference) { + WebResource resource; + if (reference != null) { + resource = getResourceFactory().getApiResource( + "/conversation/" + reference.toURLFragment()); + } else { + resource = getResourceFactory().getApiResource("/conversation/"); + } + + return resource + .entity(new ConversationCreate(subject, text, participants), + MediaType.APPLICATION_JSON_TYPE) + .post(ConversationCreateResponse.class).getConversationId(); + } + + /** + * Gets the conversation including participants and messages with the the + * given id. Only participants in the conversation is allowed to view the + * conversation. + * + * @param conversationId + * The id of the conversation to get + * @return The conversation requested + */ + public Conversation getConversation(int conversationId) { + return getResourceFactory().getApiResource( + "/conversation/" + conversationId).get(Conversation.class); + } + + /** + * Returns a list of all the conversations on the object that the active + * user is part of. + * + * @param object + * The object to get conversations on + * @return The list of conversations + */ + public List getConversationsOnObject(Reference object) { + return getResourceFactory().getApiResource( + "/conversation/" + object.toURLFragment()).get( + new GenericType>() { + }); + } + + /** + * Creates a reply to the conversation. + * + * @param conversationId + * The id of the conversation to reply to + * @param text + * The text of the reply + * @return The id of the new message + */ + public int addReply(int conversationId, String text) { + return getResourceFactory() + .getApiResource("/conversation/" + conversationId + "/reply") + .entity(new MessageCreate(text), + MediaType.APPLICATION_JSON_TYPE) + .get(MessageCreateResponse.class).getMessageId(); + } +} diff --git a/src/main/java/com/podio/conversation/ConversationCreate.java b/src/main/java/com/podio/conversation/ConversationCreate.java index c094fed..aa6fe73 100644 --- a/src/main/java/com/podio/conversation/ConversationCreate.java +++ b/src/main/java/com/podio/conversation/ConversationCreate.java @@ -1,32 +1,32 @@ -package com.podio.conversation; - -import java.util.List; - -public class ConversationCreate { - - private final String subject; - - private final String text; - - private final List participants; - - public ConversationCreate(String subject, String text, - List participants) { - super(); - this.subject = subject; - this.text = text; - this.participants = participants; - } - - public String getSubject() { - return subject; - } - - public String getText() { - return text; - } - - public List getParticipants() { - return participants; - } -} +package com.podio.conversation; + +import java.util.List; + +public class ConversationCreate { + + private final String subject; + + private final String text; + + private final List participants; + + public ConversationCreate(String subject, String text, + List participants) { + super(); + this.subject = subject; + this.text = text; + this.participants = participants; + } + + public String getSubject() { + return subject; + } + + public String getText() { + return text; + } + + public List getParticipants() { + return participants; + } +} diff --git a/src/main/java/com/podio/conversation/ConversationCreateResponse.java b/src/main/java/com/podio/conversation/ConversationCreateResponse.java index a820d54..18df265 100644 --- a/src/main/java/com/podio/conversation/ConversationCreateResponse.java +++ b/src/main/java/com/podio/conversation/ConversationCreateResponse.java @@ -1,28 +1,28 @@ -package com.podio.conversation; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ConversationCreateResponse { - - private int conversationId; - - private int messageId; - - public int getConversationId() { - return conversationId; - } - - @JsonProperty("conversation_id") - public void setConversationId(int conversationId) { - this.conversationId = conversationId; - } - - public int getMessageId() { - return messageId; - } - - @JsonProperty("message_id") - public void setMessageId(int messageId) { - this.messageId = messageId; - } -} +package com.podio.conversation; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ConversationCreateResponse { + + private int conversationId; + + private int messageId; + + public int getConversationId() { + return conversationId; + } + + @JsonProperty("conversation_id") + public void setConversationId(int conversationId) { + this.conversationId = conversationId; + } + + public int getMessageId() { + return messageId; + } + + @JsonProperty("message_id") + public void setMessageId(int messageId) { + this.messageId = messageId; + } +} diff --git a/src/main/java/com/podio/conversation/Message.java b/src/main/java/com/podio/conversation/Message.java index a072702..fe4c258 100644 --- a/src/main/java/com/podio/conversation/Message.java +++ b/src/main/java/com/podio/conversation/Message.java @@ -1,67 +1,67 @@ -package com.podio.conversation; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.contact.ProfileMini; - -public class Message { - - /** - * The id of the message - */ - private int id; - - /** - * The text of the message - */ - private String text; - - /** - * The date the message was sent - */ - private DateTime createdOn; - - /** - * The user who sent the message - */ - private ProfileMini createdBy; - - @JsonProperty("message_id") - public int getId() { - return id; - } - - @JsonProperty("message_id") - public void setId(int id) { - this.id = id; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - @JsonProperty("created_on") - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } - - @JsonProperty("created_by") - public ProfileMini getCreatedBy() { - return createdBy; - } - - @JsonProperty("created_by") - public void setCreatedBy(ProfileMini createdBy) { - this.createdBy = createdBy; - } -} +package com.podio.conversation; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.contact.ProfileMini; + +public class Message { + + /** + * The id of the message + */ + private int id; + + /** + * The text of the message + */ + private String text; + + /** + * The date the message was sent + */ + private DateTime createdOn; + + /** + * The user who sent the message + */ + private ProfileMini createdBy; + + @JsonProperty("message_id") + public int getId() { + return id; + } + + @JsonProperty("message_id") + public void setId(int id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + @JsonProperty("created_on") + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } + + @JsonProperty("created_by") + public ProfileMini getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_by") + public void setCreatedBy(ProfileMini createdBy) { + this.createdBy = createdBy; + } +} diff --git a/src/main/java/com/podio/conversation/MessageCreate.java b/src/main/java/com/podio/conversation/MessageCreate.java index 5903875..5b3a37b 100644 --- a/src/main/java/com/podio/conversation/MessageCreate.java +++ b/src/main/java/com/podio/conversation/MessageCreate.java @@ -1,15 +1,15 @@ -package com.podio.conversation; - -public class MessageCreate { - - private final String text; - - public MessageCreate(String text) { - super(); - this.text = text; - } - - public String getText() { - return text; - } -} +package com.podio.conversation; + +public class MessageCreate { + + private final String text; + + public MessageCreate(String text) { + super(); + this.text = text; + } + + public String getText() { + return text; + } +} diff --git a/src/main/java/com/podio/conversation/MessageCreateResponse.java b/src/main/java/com/podio/conversation/MessageCreateResponse.java index 0824925..a38cba0 100644 --- a/src/main/java/com/podio/conversation/MessageCreateResponse.java +++ b/src/main/java/com/podio/conversation/MessageCreateResponse.java @@ -1,17 +1,17 @@ -package com.podio.conversation; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class MessageCreateResponse { - - private int messageId; - - public int getMessageId() { - return messageId; - } - - @JsonProperty("message_id") - public void setMessageId(int messageId) { - this.messageId = messageId; - } -} +package com.podio.conversation; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class MessageCreateResponse { + + private int messageId; + + public int getMessageId() { + return messageId; + } + + @JsonProperty("message_id") + public void setMessageId(int messageId) { + this.messageId = messageId; + } +} diff --git a/src/main/java/com/podio/device/DeviceAPI.java b/src/main/java/com/podio/device/DeviceAPI.java index ec51313..2f3d48b 100644 --- a/src/main/java/com/podio/device/DeviceAPI.java +++ b/src/main/java/com/podio/device/DeviceAPI.java @@ -1,12 +1,12 @@ -package com.podio.device; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; - - -public class DeviceAPI extends BaseAPI { - - public DeviceAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } -} +package com.podio.device; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; + + +public class DeviceAPI extends BaseAPI { + + public DeviceAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } +} diff --git a/src/main/java/com/podio/device/PushSubscription.java b/src/main/java/com/podio/device/PushSubscription.java index 7ce49f2..5374c63 100644 --- a/src/main/java/com/podio/device/PushSubscription.java +++ b/src/main/java/com/podio/device/PushSubscription.java @@ -1,34 +1,34 @@ -package com.podio.device; - -public class PushSubscription { - - private long timestamp; - - private String channel; - - private String signature; - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getChannel() { - return channel; - } - - public void setChannel(String channel) { - this.channel = channel; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } -} +package com.podio.device; + +public class PushSubscription { + + private long timestamp; + + private String channel; + + private String signature; + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getChannel() { + return channel; + } + + public void setChannel(String channel) { + this.channel = channel; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } +} diff --git a/src/main/java/com/podio/embed/Embed.java b/src/main/java/com/podio/embed/Embed.java index 1f11dd1..7ee7d8e 100644 --- a/src/main/java/com/podio/embed/Embed.java +++ b/src/main/java/com/podio/embed/Embed.java @@ -1,139 +1,139 @@ -package com.podio.embed; - -import java.io.Serializable; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.file.File; - -public class Embed implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the embed - */ - private int id; - - /** - * The url for the embed - */ - private String url; - - /** - * The type of embed - */ - private EmbedType type; - - /** - * The title of the linked content - */ - private String title; - - /** - * An descriptive excerpt of the linked content - */ - private String description; - - /** - * HTML object extracted from the link that can be embedded as is - */ - private String embedHtml; - - /** - * Width of the embedded object - */ - private Integer embedWidth; - - /** - * Height of the embedded object - */ - private Integer embedHeight; - - /** - * Files that can be used as thumbnails for the embed (last is always - * favicon) - */ - private List files; - - public int getId() { - return id; - } - - @JsonProperty("embed_id") - public void setId(int id) { - this.id = id; - } - - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public EmbedType getType() { - return type; - } - - public void setType(EmbedType type) { - this.type = type; - } - - public String getTitle() { - return title; - } - - @JsonProperty("title") - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - @JsonProperty("description") - public void setDescription(String description) { - this.description = description; - } - - public String getEmbedHtml() { - return embedHtml; - } - - @JsonProperty("embed_html") - public void setEmbedHtml(String embedHtml) { - this.embedHtml = embedHtml; - } - - public Integer getEmbedWidth() { - return embedWidth; - } - - @JsonProperty("embed_width") - public void setEmbedWidth(Integer embedWidth) { - this.embedWidth = embedWidth; - } - - public Integer getEmbedHeight() { - return embedHeight; - } - - @JsonProperty("embed_height") - public void setEmbedHeight(Integer embedHeight) { - this.embedHeight = embedHeight; - } - - public List getFiles() { - return files; - } - - public void setFiles(List files) { - this.files = files; - } - -} +package com.podio.embed; + +import java.io.Serializable; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.file.File; + +public class Embed implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the embed + */ + private int id; + + /** + * The url for the embed + */ + private String url; + + /** + * The type of embed + */ + private EmbedType type; + + /** + * The title of the linked content + */ + private String title; + + /** + * An descriptive excerpt of the linked content + */ + private String description; + + /** + * HTML object extracted from the link that can be embedded as is + */ + private String embedHtml; + + /** + * Width of the embedded object + */ + private Integer embedWidth; + + /** + * Height of the embedded object + */ + private Integer embedHeight; + + /** + * Files that can be used as thumbnails for the embed (last is always + * favicon) + */ + private List files; + + public int getId() { + return id; + } + + @JsonProperty("embed_id") + public void setId(int id) { + this.id = id; + } + + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public EmbedType getType() { + return type; + } + + public void setType(EmbedType type) { + this.type = type; + } + + public String getTitle() { + return title; + } + + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + public String getEmbedHtml() { + return embedHtml; + } + + @JsonProperty("embed_html") + public void setEmbedHtml(String embedHtml) { + this.embedHtml = embedHtml; + } + + public Integer getEmbedWidth() { + return embedWidth; + } + + @JsonProperty("embed_width") + public void setEmbedWidth(Integer embedWidth) { + this.embedWidth = embedWidth; + } + + public Integer getEmbedHeight() { + return embedHeight; + } + + @JsonProperty("embed_height") + public void setEmbedHeight(Integer embedHeight) { + this.embedHeight = embedHeight; + } + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + +} diff --git a/src/main/java/com/podio/embed/EmbedAPI.java b/src/main/java/com/podio/embed/EmbedAPI.java index 63c526a..ef9af3a 100644 --- a/src/main/java/com/podio/embed/EmbedAPI.java +++ b/src/main/java/com/podio/embed/EmbedAPI.java @@ -1,31 +1,31 @@ -package com.podio.embed; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; - -/** - * Embeds are links shared by users in statuses, conversations and comments. One - * or more embeds are also referred when creating items with an embed file type. - */ -public class EmbedAPI extends BaseAPI { - - public EmbedAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Grabs metadata and returns metadata for the given url such as title, - * description and thumbnails. - * - * @param url - * The URL of the embed - * @return The full embed data - */ - public Embed createEmbed(String url) { - return getResourceFactory().getApiResource("/embed/") - .entity(new EmbedCreate(url), MediaType.APPLICATION_JSON_TYPE) - .post(Embed.class); - } -} +package com.podio.embed; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; + +/** + * Embeds are links shared by users in statuses, conversations and comments. One + * or more embeds are also referred when creating items with an embed file type. + */ +public class EmbedAPI extends BaseAPI { + + public EmbedAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Grabs metadata and returns metadata for the given url such as title, + * description and thumbnails. + * + * @param url + * The URL of the embed + * @return The full embed data + */ + public Embed createEmbed(String url) { + return getResourceFactory().getApiResource("/embed/") + .entity(new EmbedCreate(url), MediaType.APPLICATION_JSON_TYPE) + .post(Embed.class); + } +} diff --git a/src/main/java/com/podio/embed/EmbedCreate.java b/src/main/java/com/podio/embed/EmbedCreate.java index 53f7942..59a93e1 100644 --- a/src/main/java/com/podio/embed/EmbedCreate.java +++ b/src/main/java/com/podio/embed/EmbedCreate.java @@ -1,15 +1,15 @@ -package com.podio.embed; - -public class EmbedCreate { - - private final String url; - - public EmbedCreate(String url) { - super(); - this.url = url; - } - - public String getUrl() { - return url; - } -} +package com.podio.embed; + +public class EmbedCreate { + + private final String url; + + public EmbedCreate(String url) { + super(); + this.url = url; + } + + public String getUrl() { + return url; + } +} diff --git a/src/main/java/com/podio/embed/EmbedType.java b/src/main/java/com/podio/embed/EmbedType.java index 48fda80..5711eee 100644 --- a/src/main/java/com/podio/embed/EmbedType.java +++ b/src/main/java/com/podio/embed/EmbedType.java @@ -1,56 +1,56 @@ -package com.podio.embed; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum EmbedType { - - /** - * A direct link to a public image - */ - IMAGE("image"), - - /** - * A link to a video service provider such as YouTube - */ - VIDEO("video"), - - /** - * A link to a service provider that can be displayed inline, but is not - * video (such as SlideShare) - */ - RICH("rich"), - - /** - * A link to a plain web page - */ - LINK("link"), - - /** - * An invalid or inaccessible link - */ - UNRESOLVED("unresolved"); - - private final String externalName; - - private EmbedType(String externalName) { - this.externalName = externalName; - } - - @Override - @JsonValue - public String toString() { - return externalName; - } - - @JsonCreator - public static EmbedType getByName(String value) { - for (EmbedType type : values()) { - if (type.externalName.equals(value)) { - return type; - } - } - - return null; - } -} +package com.podio.embed; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum EmbedType { + + /** + * A direct link to a public image + */ + IMAGE("image"), + + /** + * A link to a video service provider such as YouTube + */ + VIDEO("video"), + + /** + * A link to a service provider that can be displayed inline, but is not + * video (such as SlideShare) + */ + RICH("rich"), + + /** + * A link to a plain web page + */ + LINK("link"), + + /** + * An invalid or inaccessible link + */ + UNRESOLVED("unresolved"); + + private final String externalName; + + private EmbedType(String externalName) { + this.externalName = externalName; + } + + @Override + @JsonValue + public String toString() { + return externalName; + } + + @JsonCreator + public static EmbedType getByName(String value) { + for (EmbedType type : values()) { + if (type.externalName.equals(value)) { + return type; + } + } + + return null; + } +} diff --git a/src/main/java/com/podio/file/File.java b/src/main/java/com/podio/file/File.java index adb10eb..0992d33 100644 --- a/src/main/java/com/podio/file/File.java +++ b/src/main/java/com/podio/file/File.java @@ -1,154 +1,154 @@ -package com.podio.file; - -import java.util.List; - -import javax.activation.MimeType; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.common.CreatedBase; - -public class File extends CreatedBase { - - private static final long serialVersionUID = 1L; - - /** - * The id of the file - */ - private int id; - - /** - * The name of the file - */ - private String name; - - /** - * The description of the file - */ - private String description; - - /** - * The type of the file, see the area for allowed types - */ - private MimeType mimetype; - - /** - * The context of the file, either an item, task or status - */ - private FileReference context; - - /** - * The URL where the file can be downloaded. - */ - private String link; - - /** - * The base link to the thumbnail of the file. Can be postfixed with the required size, one of: - * - * tiny - 16x16 - * small - 32x32 - * default - 40x40 - * medium - 80x80 - * large - 160x160 - */ - private String thumbnailLink; - - /** - * The link to the file with information on Podio. - */ - private String permaLink; - - /** - * The size of the file in bytes - */ - private long size; - - /** - * The file this file replaces, if any - */ - private List replaces; - - @JsonProperty("file_id") - public int getId() { - return id; - } - - @JsonProperty("file_id") - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public MimeType getMimetype() { - return mimetype; - } - - public void setMimetype(MimeType mimetype) { - this.mimetype = mimetype; - } - - public FileReference getContext() { - return context; - } - - public void setContext(FileReference context) { - this.context = context; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - @JsonProperty("thumbnail_link") - public String getThumbnailLink() { - return thumbnailLink; - } - - public void setThumbnailLink(String thumbnailLink) { - this.thumbnailLink = thumbnailLink; - } - - @JsonProperty("permalink_link") - public String getPermaLink() { - return permaLink; - } - - public void setPermaLink(String permaLink) { - this.permaLink = permaLink; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public List getReplaces() { - return replaces; - } - - public void setReplaces(List replaces) { - this.replaces = replaces; - } -} +package com.podio.file; + +import java.util.List; + +import javax.activation.MimeType; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.CreatedBase; + +public class File extends CreatedBase { + + private static final long serialVersionUID = 1L; + + /** + * The id of the file + */ + private int id; + + /** + * The name of the file + */ + private String name; + + /** + * The description of the file + */ + private String description; + + /** + * The type of the file, see the area for allowed types + */ + private MimeType mimetype; + + /** + * The context of the file, either an item, task or status + */ + private FileReference context; + + /** + * The URL where the file can be downloaded. + */ + private String link; + + /** + * The base link to the thumbnail of the file. Can be postfixed with the required size, one of: + * + * tiny - 16x16 + * small - 32x32 + * default - 40x40 + * medium - 80x80 + * large - 160x160 + */ + private String thumbnailLink; + + /** + * The link to the file with information on Podio. + */ + private String permaLink; + + /** + * The size of the file in bytes + */ + private long size; + + /** + * The file this file replaces, if any + */ + private List replaces; + + @JsonProperty("file_id") + public int getId() { + return id; + } + + @JsonProperty("file_id") + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public MimeType getMimetype() { + return mimetype; + } + + public void setMimetype(MimeType mimetype) { + this.mimetype = mimetype; + } + + public FileReference getContext() { + return context; + } + + public void setContext(FileReference context) { + this.context = context; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + @JsonProperty("thumbnail_link") + public String getThumbnailLink() { + return thumbnailLink; + } + + public void setThumbnailLink(String thumbnailLink) { + this.thumbnailLink = thumbnailLink; + } + + @JsonProperty("permalink_link") + public String getPermaLink() { + return permaLink; + } + + public void setPermaLink(String permaLink) { + this.permaLink = permaLink; + } + + public long getSize() { + return size; + } + + public void setSize(long size) { + this.size = size; + } + + public List getReplaces() { + return replaces; + } + + public void setReplaces(List replaces) { + this.replaces = replaces; + } +} diff --git a/src/main/java/com/podio/file/FileAPI.java b/src/main/java/com/podio/file/FileAPI.java index 33e2d6f..933edfa 100644 --- a/src/main/java/com/podio/file/FileAPI.java +++ b/src/main/java/com/podio/file/FileAPI.java @@ -1,183 +1,200 @@ -package com.podio.file; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Collections; -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.WebResource.Builder; -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataMultiPart; -import com.sun.jersey.multipart.file.FileDataBodyPart; - -public class FileAPI extends BaseAPI { - - public FileAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Downloads the file and saves it to given file - * - * @param fileId - * The id of the file to download - * @param target - * The target file to save the contents to - * @throws IOException - * If there was an error reading or writing the file - */ - public void downloadFile(int fileId, java.io.File target, FileSize size) - throws IOException { - WebResource builder = getResourceFactory() - .getFileResource("/" + fileId); - if (size != null) { - builder = builder.path("/" + size.name().toLowerCase()); - } - byte[] data = builder.get(byte[].class); - FileUtils.writeByteArrayToFile(target, data); - } - - /** - * Uploads the file to the API - */ - public int uploadFile(String name, java.io.File file) { - FileDataBodyPart filePart = new FileDataBodyPart("source", file); - // Work around for bug in cherrypy - FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition - .name(filePart.getName()); - builder.fileName(file.getName()); - builder.size(file.length()); - filePart.setFormDataContentDisposition(builder.build()); - - FormDataMultiPart multiPart = new FormDataMultiPart(); - multiPart.bodyPart(filePart); - multiPart.field("filename", name); - - Builder resource = getResourceFactory().getApiResource("/file/v2/") - .entity(multiPart, - new MediaType("multipart", "form-data", Collections - .singletonMap("boundary", "AaB03x"))); - return resource.post(File.class).getId(); - } - - public Integer uploadImage(URL url) throws IOException { - return uploadImage(url, null); - } - - public int uploadImage(URL url, String name) throws IOException { - java.io.File file = readURL(url); - try { - String path = url.getPath(); - int lastSlashIdx = path.lastIndexOf('/'); - if (name == null) { - name = path.substring(lastSlashIdx + 1); - } - - return uploadFile(name, file); - } finally { - file.delete(); - } - } - - private static java.io.File readURL(URL url) throws IOException { - InputStream is = url.openStream(); - try { - java.io.File file = java.io.File.createTempFile( - Integer.toString(url.hashCode()), null); - file.deleteOnExit(); - FileOutputStream os = FileUtils.openOutputStream(file); - try { - IOUtils.copy(is, os); - } finally { - os.close(); - } - - return file; - } finally { - is.close(); - } - } - - /** - * Returns the file with the given id - */ - public File getFile(int fileId) { - return getResourceFactory().getApiResource("/file/" + fileId).get( - File.class); - } - - /** - * Used to update the description of the file. - */ - public void updateFile(int fileId, FileUpdate update) { - getResourceFactory().getApiResource("/file/" + fileId) - .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Deletes the file with the given id. - */ - public void deleteFile(int fileId) { - getResourceFactory().getApiResource("/file/" + fileId).delete(); - } - - /** - * Returns all the files related to the items in the application. This - * includes files both on the item itself and in comments on the item. - * - * @param limit - * The maximum number of files to be returned. Defaults to 50 and - * cannot be higher than 100. - * @param offset - * The offset to use when returning files to be used for - * pagination. Defaults to 0 (no offset). - */ - public List getOnApp(int appId, Integer limit, Integer offset) { - WebResource resource = getResourceFactory().getApiResource( - "/file/app/" + appId + "/"); - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - if (offset != null) { - resource = resource.queryParam("offset", offset.toString()); - } - - return resource.get(new GenericType>() { - }); - } - - /** - * Returns all the files on the space order by the file name. - * - * @param limit - * The maximum number of files to be returned. Defaults to 50 and - * cannot be higher than 100. - * @param offset - * The offset to use when returning files to be used for - * pagination. Defaults to 0 (no offset). - */ - public List getOnSpace(int spaceId, Integer limit, Integer offset) { - WebResource resource = getResourceFactory().getApiResource( - "/file/space/" + spaceId + "/"); - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - if (offset != null) { - resource = resource.queryParam("offset", offset.toString()); - } - - return resource.get(new GenericType>() { - }); - } -} +package com.podio.file; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MediaType; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.WebResource.Builder; +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataMultiPart; +import com.sun.jersey.multipart.file.FileDataBodyPart; + +public class FileAPI extends BaseAPI { + + public FileAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Downloads the file and saves it to given file + * + * @param fileId + * The id of the file to download + * @param target + * The target file to save the contents to + * @throws IOException + * If there was an error reading or writing the file + */ + public void downloadFile(int fileId, java.io.File target, FileSize size) + throws IOException { + WebResource builder = getResourceFactory() + .getFileResource("/" + fileId); + if (size != null) { + builder = builder.path("/" + size.name().toLowerCase()); + } + byte[] data = builder.get(byte[].class); + FileUtils.writeByteArrayToFile(target, data); + } + + /** + * Attaches a previously uploaded file to an item + * @param fileId + * @param attributes { "ref_type": "status, item, comment, space, or task", "ref_id": object id } + * @param silent + * @param hook + */ + public void attachFile( int fileId, Map attributes, boolean silent, boolean hook ) + { + getResourceFactory() + .getApiResource("/file/" + fileId + "/attach") + .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") + .entity(attributes, MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Uploads the file to the API + */ + public int uploadFile(String name, java.io.File file) { + FileDataBodyPart filePart = new FileDataBodyPart("source", file); + // Work around for bug in cherrypy + FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition + .name(filePart.getName()); + builder.fileName(file.getName()); + builder.size(file.length()); + filePart.setFormDataContentDisposition(builder.build()); + + FormDataMultiPart multiPart = new FormDataMultiPart(); + multiPart.bodyPart(filePart); + multiPart.field("filename", name); + + Builder resource = getResourceFactory().getApiResource("/file/v2/") + .entity(multiPart, + new MediaType("multipart", "form-data", Collections + .singletonMap("boundary", "AaB03x"))); + return resource.post(File.class).getId(); + } + + public Integer uploadImage(URL url) throws IOException { + return uploadImage(url, null); + } + + public int uploadImage(URL url, String name) throws IOException { + java.io.File file = readURL(url); + try { + String path = url.getPath(); + int lastSlashIdx = path.lastIndexOf('/'); + if (name == null) { + name = path.substring(lastSlashIdx + 1); + } + + return uploadFile(name, file); + } finally { + file.delete(); + } + } + + private static java.io.File readURL(URL url) throws IOException { + InputStream is = url.openStream(); + try { + java.io.File file = java.io.File.createTempFile( + Integer.toString(url.hashCode()), null); + file.deleteOnExit(); + FileOutputStream os = FileUtils.openOutputStream(file); + try { + IOUtils.copy(is, os); + } finally { + os.close(); + } + + return file; + } finally { + is.close(); + } + } + + /** + * Returns the file with the given id + */ + public File getFile(int fileId) { + return getResourceFactory().getApiResource("/file/" + fileId).get( + File.class); + } + + /** + * Used to update the description of the file. + */ + public void updateFile(int fileId, FileUpdate update) { + getResourceFactory().getApiResource("/file/" + fileId) + .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Deletes the file with the given id. + */ + public void deleteFile(int fileId) { + getResourceFactory().getApiResource("/file/" + fileId).delete(); + } + + /** + * Returns all the files related to the items in the application. This + * includes files both on the item itself and in comments on the item. + * + * @param limit + * The maximum number of files to be returned. Defaults to 50 and + * cannot be higher than 100. + * @param offset + * The offset to use when returning files to be used for + * pagination. Defaults to 0 (no offset). + */ + public List getOnApp(int appId, Integer limit, Integer offset) { + WebResource resource = getResourceFactory().getApiResource( + "/file/app/" + appId + "/"); + if (limit != null) { + resource = resource.queryParam("limit", limit.toString()); + } + if (offset != null) { + resource = resource.queryParam("offset", offset.toString()); + } + + return resource.get(new GenericType>() { + }); + } + + /** + * Returns all the files on the space order by the file name. + * + * @param limit + * The maximum number of files to be returned. Defaults to 50 and + * cannot be higher than 100. + * @param offset + * The offset to use when returning files to be used for + * pagination. Defaults to 0 (no offset). + */ + public List getOnSpace(int spaceId, Integer limit, Integer offset) { + WebResource resource = getResourceFactory().getApiResource( + "/file/space/" + spaceId + "/"); + if (limit != null) { + resource = resource.queryParam("limit", limit.toString()); + } + if (offset != null) { + resource = resource.queryParam("offset", offset.toString()); + } + + return resource.get(new GenericType>() { + }); + } +} diff --git a/src/main/java/com/podio/file/FileError.java b/src/main/java/com/podio/file/FileError.java index 57f6d97..caee367 100644 --- a/src/main/java/com/podio/file/FileError.java +++ b/src/main/java/com/podio/file/FileError.java @@ -1,30 +1,30 @@ -package com.podio.file; - -public class FileError { - - private int code; - - private String message; - - @Override - public String toString() { - return "FileError [code=" + code + ", message=" + message + "]"; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - -} +package com.podio.file; + +public class FileError { + + private int code; + + private String message; + + @Override + public String toString() { + return "FileError [code=" + code + ", message=" + message + "]"; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/src/main/java/com/podio/file/FileReference.java b/src/main/java/com/podio/file/FileReference.java index 87da923..b0310f9 100644 --- a/src/main/java/com/podio/file/FileReference.java +++ b/src/main/java/com/podio/file/FileReference.java @@ -1,30 +1,30 @@ -package com.podio.file; - -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class FileReference extends Reference { - - /** - * The title of the reference - */ - private String title; - - public FileReference() { - super(); - } - - public FileReference(ReferenceType type, int id, String title) { - super(type, id); - this.title = title; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - -} +package com.podio.file; + +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class FileReference extends Reference { + + /** + * The title of the reference + */ + private String title; + + public FileReference() { + super(); + } + + public FileReference(ReferenceType type, int id, String title) { + super(type, id); + this.title = title; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + +} diff --git a/src/main/java/com/podio/file/FileSize.java b/src/main/java/com/podio/file/FileSize.java index 7562a37..6e78a4b 100644 --- a/src/main/java/com/podio/file/FileSize.java +++ b/src/main/java/com/podio/file/FileSize.java @@ -1,12 +1,12 @@ -package com.podio.file; - -public enum FileSize { - - PREVIEW, - BADGE, - TINY, - SMALL, - MEDIUM, - LARGE, - EXTRA_LARGE; -} +package com.podio.file; + +public enum FileSize { + + PREVIEW, + BADGE, + TINY, + SMALL, + MEDIUM, + LARGE, + EXTRA_LARGE; +} diff --git a/src/main/java/com/podio/file/FileUpdate.java b/src/main/java/com/podio/file/FileUpdate.java index ab2a197..2b50942 100644 --- a/src/main/java/com/podio/file/FileUpdate.java +++ b/src/main/java/com/podio/file/FileUpdate.java @@ -1,19 +1,19 @@ -package com.podio.file; - -public class FileUpdate { - - private String description; - - public FileUpdate(String description) { - super(); - this.description = description; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} +package com.podio.file; + +public class FileUpdate { + + private String description; + + public FileUpdate(String description) { + super(); + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/podio/file/FileUploadResponse.java b/src/main/java/com/podio/file/FileUploadResponse.java index a20180a..e7e0c1b 100644 --- a/src/main/java/com/podio/file/FileUploadResponse.java +++ b/src/main/java/com/podio/file/FileUploadResponse.java @@ -1,55 +1,55 @@ -package com.podio.file; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class FileUploadResponse { - - private String jsonRpc; - - private FileUploadResult result; - - private FileError error; - - private String id; - - @Override - public String toString() { - return "FileUploadResponse [jsonRpc=" + jsonRpc + ", result=" + result - + ", error=" + error + ", id=" + id + "]"; - } - - @JsonProperty("jsonrpc") - public String getJsonRpc() { - return jsonRpc; - } - - @JsonProperty("jsonrpc") - public void setJsonRpc(String jsonRpc) { - this.jsonRpc = jsonRpc; - } - - public FileError getError() { - return error; - } - - public void setError(FileError error) { - this.error = error; - } - - public FileUploadResult getResult() { - return result; - } - - public void setResult(FileUploadResult result) { - this.result = result; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - -} +package com.podio.file; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class FileUploadResponse { + + private String jsonRpc; + + private FileUploadResult result; + + private FileError error; + + private String id; + + @Override + public String toString() { + return "FileUploadResponse [jsonRpc=" + jsonRpc + ", result=" + result + + ", error=" + error + ", id=" + id + "]"; + } + + @JsonProperty("jsonrpc") + public String getJsonRpc() { + return jsonRpc; + } + + @JsonProperty("jsonrpc") + public void setJsonRpc(String jsonRpc) { + this.jsonRpc = jsonRpc; + } + + public FileError getError() { + return error; + } + + public void setError(FileError error) { + this.error = error; + } + + public FileUploadResult getResult() { + return result; + } + + public void setResult(FileUploadResult result) { + this.result = result; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/src/main/java/com/podio/file/FileUploadResult.java b/src/main/java/com/podio/file/FileUploadResult.java index 5020403..667126f 100644 --- a/src/main/java/com/podio/file/FileUploadResult.java +++ b/src/main/java/com/podio/file/FileUploadResult.java @@ -1,23 +1,23 @@ -package com.podio.file; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class FileUploadResult { - - private int fileId; - - @Override - public String toString() { - return "FileUploadResult [fileId=" + fileId + "]"; - } - - @JsonProperty("file_id") - public int getFileId() { - return fileId; - } - - @JsonProperty("file_id") - public void setFileId(int fileId) { - this.fileId = fileId; - } -} +package com.podio.file; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class FileUploadResult { + + private int fileId; + + @Override + public String toString() { + return "FileUploadResult [fileId=" + fileId + "]"; + } + + @JsonProperty("file_id") + public int getFileId() { + return fileId; + } + + @JsonProperty("file_id") + public void setFileId(int fileId) { + this.fileId = fileId; + } +} diff --git a/src/main/java/com/podio/filter/AbsolutePodioDate.java b/src/main/java/com/podio/filter/AbsolutePodioDate.java index 4ac3489..52bb0d9 100644 --- a/src/main/java/com/podio/filter/AbsolutePodioDate.java +++ b/src/main/java/com/podio/filter/AbsolutePodioDate.java @@ -1,19 +1,19 @@ -package com.podio.filter; - -import org.joda.time.LocalDate; - -public class AbsolutePodioDate implements PodioDate { - - private final LocalDate date; - - public AbsolutePodioDate(LocalDate date) { - super(); - this.date = date; - } - - @Override - public String serialize() { - return this.date.toString("yyyy-MM-dd"); - } - -} +package com.podio.filter; + +import org.joda.time.LocalDate; + +public class AbsolutePodioDate implements PodioDate { + + private final LocalDate date; + + public AbsolutePodioDate(LocalDate date) { + super(); + this.date = date; + } + + @Override + public String serialize() { + return this.date.toString("yyyy-MM-dd"); + } + +} diff --git a/src/main/java/com/podio/filter/AppFieldFilterBy.java b/src/main/java/com/podio/filter/AppFieldFilterBy.java index 5bca167..227a933 100644 --- a/src/main/java/com/podio/filter/AppFieldFilterBy.java +++ b/src/main/java/com/podio/filter/AppFieldFilterBy.java @@ -1,17 +1,17 @@ -package com.podio.filter; - -import java.util.List; - -import com.podio.common.CSVUtil; - -public class AppFieldFilterBy extends FieldFilterBy> { - - public AppFieldFilterBy(int fieldId) { - super(fieldId); - } - - @Override - public final String format(List values) { - return CSVUtil.toCSV(values); - } -} +package com.podio.filter; + +import java.util.List; + +import com.podio.common.CSVUtil; + +public class AppFieldFilterBy extends FieldFilterBy> { + + public AppFieldFilterBy(int fieldId) { + super(fieldId); + } + + @Override + public final String format(List values) { + return CSVUtil.toCSV(values); + } +} diff --git a/src/main/java/com/podio/filter/BaseAuthListFilterBy.java b/src/main/java/com/podio/filter/BaseAuthListFilterBy.java index 4901edc..4eaf483 100644 --- a/src/main/java/com/podio/filter/BaseAuthListFilterBy.java +++ b/src/main/java/com/podio/filter/BaseAuthListFilterBy.java @@ -1,15 +1,15 @@ -package com.podio.filter; - -import java.util.List; - -import com.podio.common.CSVUtil; -import com.podio.common.Reference; - -public abstract class BaseAuthListFilterBy implements FilterBy> { - - @Override - public final String format(List values) { - return CSVUtil.toCSV(values); - } - -} +package com.podio.filter; + +import java.util.List; + +import com.podio.common.CSVUtil; +import com.podio.common.Reference; + +public abstract class BaseAuthListFilterBy implements FilterBy> { + + @Override + public final String format(List values) { + return CSVUtil.toCSV(values); + } + +} diff --git a/src/main/java/com/podio/filter/BaseDateFilterBy.java b/src/main/java/com/podio/filter/BaseDateFilterBy.java index 5bbdc4a..f453cbd 100644 --- a/src/main/java/com/podio/filter/BaseDateFilterBy.java +++ b/src/main/java/com/podio/filter/BaseDateFilterBy.java @@ -1,10 +1,10 @@ -package com.podio.filter; - -public abstract class BaseDateFilterBy implements FilterBy { - - @Override - public final String format(PodioDateInterval value) { - return value.serialize(); - } - -} +package com.podio.filter; + +public abstract class BaseDateFilterBy implements FilterBy { + + @Override + public final String format(PodioDateInterval value) { + return value.serialize(); + } + +} diff --git a/src/main/java/com/podio/filter/BaseIntListFilterBy.java b/src/main/java/com/podio/filter/BaseIntListFilterBy.java index 91c089a..356fe50 100644 --- a/src/main/java/com/podio/filter/BaseIntListFilterBy.java +++ b/src/main/java/com/podio/filter/BaseIntListFilterBy.java @@ -1,13 +1,13 @@ -package com.podio.filter; - -import java.util.List; - -import com.podio.common.CSVUtil; - -public abstract class BaseIntListFilterBy implements FilterBy> { - - @Override - public final String format(List values) { - return CSVUtil.toCSV(values); - } -} +package com.podio.filter; + +import java.util.List; + +import com.podio.common.CSVUtil; + +public abstract class BaseIntListFilterBy implements FilterBy> { + + @Override + public final String format(List values) { + return CSVUtil.toCSV(values); + } +} diff --git a/src/main/java/com/podio/filter/CreatedByFilterBy.java b/src/main/java/com/podio/filter/CreatedByFilterBy.java index cde1f77..243bd9f 100644 --- a/src/main/java/com/podio/filter/CreatedByFilterBy.java +++ b/src/main/java/com/podio/filter/CreatedByFilterBy.java @@ -1,9 +1,9 @@ -package com.podio.filter; - -public class CreatedByFilterBy extends BaseAuthListFilterBy { - - @Override - public String getKey() { - return "created_by"; - } -} +package com.podio.filter; + +public class CreatedByFilterBy extends BaseAuthListFilterBy { + + @Override + public String getKey() { + return "created_by"; + } +} diff --git a/src/main/java/com/podio/filter/CreatedOnFilterBy.java b/src/main/java/com/podio/filter/CreatedOnFilterBy.java index 574e640..2371cbf 100644 --- a/src/main/java/com/podio/filter/CreatedOnFilterBy.java +++ b/src/main/java/com/podio/filter/CreatedOnFilterBy.java @@ -1,10 +1,10 @@ -package com.podio.filter; - -public class CreatedOnFilterBy extends BaseDateFilterBy { - - @Override - public String getKey() { - return "created_on"; - } - -} +package com.podio.filter; + +public class CreatedOnFilterBy extends BaseDateFilterBy { + + @Override + public String getKey() { + return "created_on"; + } + +} diff --git a/src/main/java/com/podio/filter/CreatedViaFilterBy.java b/src/main/java/com/podio/filter/CreatedViaFilterBy.java index 098d8ba..dd3a929 100644 --- a/src/main/java/com/podio/filter/CreatedViaFilterBy.java +++ b/src/main/java/com/podio/filter/CreatedViaFilterBy.java @@ -1,9 +1,9 @@ -package com.podio.filter; - -public class CreatedViaFilterBy extends BaseIntListFilterBy { - - @Override - public String getKey() { - return "created_via"; - } -} +package com.podio.filter; + +public class CreatedViaFilterBy extends BaseIntListFilterBy { + + @Override + public String getKey() { + return "created_via"; + } +} diff --git a/src/main/java/com/podio/filter/DateFieldFilterBy.java b/src/main/java/com/podio/filter/DateFieldFilterBy.java index 61fd571..3e74295 100644 --- a/src/main/java/com/podio/filter/DateFieldFilterBy.java +++ b/src/main/java/com/podio/filter/DateFieldFilterBy.java @@ -1,17 +1,17 @@ -package com.podio.filter; - -public class DateFieldFilterBy extends BaseDateFilterBy { - - private final int fieldId; - - public DateFieldFilterBy(int fieldId) { - super(); - this.fieldId = fieldId; - } - - @Override - public final String getKey() { - return Integer.toString(fieldId); - } - -} +package com.podio.filter; + +public class DateFieldFilterBy extends BaseDateFilterBy { + + private final int fieldId; + + public DateFieldFilterBy(int fieldId) { + super(); + this.fieldId = fieldId; + } + + @Override + public final String getKey() { + return Integer.toString(fieldId); + } + +} diff --git a/src/main/java/com/podio/filter/ExternalIdFilterBy.java b/src/main/java/com/podio/filter/ExternalIdFilterBy.java index 361cfce..cb5cc56 100644 --- a/src/main/java/com/podio/filter/ExternalIdFilterBy.java +++ b/src/main/java/com/podio/filter/ExternalIdFilterBy.java @@ -1,14 +1,14 @@ -package com.podio.filter; - -public class ExternalIdFilterBy implements FilterBy { - - @Override - public String getKey() { - return "external_id"; - } - - @Override - public String format(String value) { - return value; - } -} +package com.podio.filter; + +public class ExternalIdFilterBy implements FilterBy { + + @Override + public String getKey() { + return "external_id"; + } + + @Override + public String format(String value) { + return value; + } +} diff --git a/src/main/java/com/podio/filter/FieldFilterBy.java b/src/main/java/com/podio/filter/FieldFilterBy.java index 179dee3..87513fc 100644 --- a/src/main/java/com/podio/filter/FieldFilterBy.java +++ b/src/main/java/com/podio/filter/FieldFilterBy.java @@ -1,16 +1,16 @@ -package com.podio.filter; - -public abstract class FieldFilterBy implements FilterBy { - - private final int fieldId; - - public FieldFilterBy(int fieldId) { - super(); - this.fieldId = fieldId; - } - - @Override - public final String getKey() { - return Integer.toString(fieldId); - } -} +package com.podio.filter; + +public abstract class FieldFilterBy implements FilterBy { + + private final int fieldId; + + public FieldFilterBy(int fieldId) { + super(); + this.fieldId = fieldId; + } + + @Override + public final String getKey() { + return Integer.toString(fieldId); + } +} diff --git a/src/main/java/com/podio/filter/FieldSortBy.java b/src/main/java/com/podio/filter/FieldSortBy.java index da1472b..5ff484f 100644 --- a/src/main/java/com/podio/filter/FieldSortBy.java +++ b/src/main/java/com/podio/filter/FieldSortBy.java @@ -1,16 +1,16 @@ -package com.podio.filter; - -public class FieldSortBy implements SortBy { - - private final int fieldId; - - public FieldSortBy(int fieldId) { - super(); - this.fieldId = fieldId; - } - - @Override - public String getKey() { - return Integer.toString(fieldId); - } -} +package com.podio.filter; + +public class FieldSortBy implements SortBy { + + private final int fieldId; + + public FieldSortBy(int fieldId) { + super(); + this.fieldId = fieldId; + } + + @Override + public String getKey() { + return Integer.toString(fieldId); + } +} diff --git a/src/main/java/com/podio/filter/FilterBy.java b/src/main/java/com/podio/filter/FilterBy.java index 728cf5f..099b8f5 100644 --- a/src/main/java/com/podio/filter/FilterBy.java +++ b/src/main/java/com/podio/filter/FilterBy.java @@ -1,8 +1,8 @@ -package com.podio.filter; - -public interface FilterBy { - - String getKey(); - - String format(T value); -} +package com.podio.filter; + +public interface FilterBy { + + String getKey(); + + String format(T value); +} diff --git a/src/main/java/com/podio/filter/FilterByValue.java b/src/main/java/com/podio/filter/FilterByValue.java index b20af78..ace52af 100644 --- a/src/main/java/com/podio/filter/FilterByValue.java +++ b/src/main/java/com/podio/filter/FilterByValue.java @@ -1,26 +1,26 @@ -package com.podio.filter; - -public class FilterByValue { - - private final FilterBy by; - - private final T value; - - public FilterByValue(FilterBy by, T value) { - super(); - this.by = by; - this.value = value; - } - - public FilterBy getBy() { - return by; - } - - public T getValue() { - return value; - } - - public String getFormattedValue() { - return by.format(value); - } -} +package com.podio.filter; + +public class FilterByValue { + + private final FilterBy by; + + private final T value; + + public FilterByValue(FilterBy by, T value) { + super(); + this.by = by; + this.value = value; + } + + public FilterBy getBy() { + return by; + } + + public T getValue() { + return value; + } + + public String getFormattedValue() { + return by.format(value); + } +} diff --git a/src/main/java/com/podio/filter/LastEditByFilterBy.java b/src/main/java/com/podio/filter/LastEditByFilterBy.java index 353d659..483ae3e 100644 --- a/src/main/java/com/podio/filter/LastEditByFilterBy.java +++ b/src/main/java/com/podio/filter/LastEditByFilterBy.java @@ -1,9 +1,9 @@ -package com.podio.filter; - -public class LastEditByFilterBy extends BaseAuthListFilterBy { - - @Override - public String getKey() { - return "last_edit_by"; - } -} +package com.podio.filter; + +public class LastEditByFilterBy extends BaseAuthListFilterBy { + + @Override + public String getKey() { + return "last_edit_by"; + } +} diff --git a/src/main/java/com/podio/filter/LastEditOnFilterBy.java b/src/main/java/com/podio/filter/LastEditOnFilterBy.java index 30e71e8..706c249 100644 --- a/src/main/java/com/podio/filter/LastEditOnFilterBy.java +++ b/src/main/java/com/podio/filter/LastEditOnFilterBy.java @@ -1,10 +1,10 @@ -package com.podio.filter; - -public class LastEditOnFilterBy extends BaseDateFilterBy { - - @Override - public String getKey() { - return "last_edit_on"; - } - -} +package com.podio.filter; + +public class LastEditOnFilterBy extends BaseDateFilterBy { + + @Override + public String getKey() { + return "last_edit_on"; + } + +} diff --git a/src/main/java/com/podio/filter/LastEditViaFilterBy.java b/src/main/java/com/podio/filter/LastEditViaFilterBy.java index bced471..0f22f12 100644 --- a/src/main/java/com/podio/filter/LastEditViaFilterBy.java +++ b/src/main/java/com/podio/filter/LastEditViaFilterBy.java @@ -1,9 +1,9 @@ -package com.podio.filter; - -public class LastEditViaFilterBy extends BaseIntListFilterBy { - - @Override - public String getKey() { - return "last_edit_via"; - } -} +package com.podio.filter; + +public class LastEditViaFilterBy extends BaseIntListFilterBy { + + @Override + public String getKey() { + return "last_edit_via"; + } +} diff --git a/src/main/java/com/podio/filter/MemberFieldFilterBy.java b/src/main/java/com/podio/filter/MemberFieldFilterBy.java index c971f66..d67b9ad 100644 --- a/src/main/java/com/podio/filter/MemberFieldFilterBy.java +++ b/src/main/java/com/podio/filter/MemberFieldFilterBy.java @@ -1,17 +1,17 @@ -package com.podio.filter; - -import java.util.List; - -import com.podio.common.CSVUtil; - -public class MemberFieldFilterBy extends FieldFilterBy> { - - public MemberFieldFilterBy(int fieldId) { - super(fieldId); - } - - @Override - public final String format(List values) { - return CSVUtil.toCSV(values); - } -} +package com.podio.filter; + +import java.util.List; + +import com.podio.common.CSVUtil; + +public class MemberFieldFilterBy extends FieldFilterBy> { + + public MemberFieldFilterBy(int fieldId) { + super(fieldId); + } + + @Override + public final String format(List values) { + return CSVUtil.toCSV(values); + } +} diff --git a/src/main/java/com/podio/filter/NumberFieldFilterBy.java b/src/main/java/com/podio/filter/NumberFieldFilterBy.java index 9b0d7d1..e1d60c1 100644 --- a/src/main/java/com/podio/filter/NumberFieldFilterBy.java +++ b/src/main/java/com/podio/filter/NumberFieldFilterBy.java @@ -1,13 +1,13 @@ -package com.podio.filter; - -public class NumberFieldFilterBy extends FieldFilterBy { - - public NumberFieldFilterBy(int fieldId) { - super(fieldId); - } - - @Override - public String format(NumberInterval value) { - return value.getFrom() + "-" + value.getTo(); - } -} +package com.podio.filter; + +public class NumberFieldFilterBy extends FieldFilterBy { + + public NumberFieldFilterBy(int fieldId) { + super(fieldId); + } + + @Override + public String format(NumberInterval value) { + return value.getFrom() + "-" + value.getTo(); + } +} diff --git a/src/main/java/com/podio/filter/NumberInterval.java b/src/main/java/com/podio/filter/NumberInterval.java index 34b4628..601afe4 100644 --- a/src/main/java/com/podio/filter/NumberInterval.java +++ b/src/main/java/com/podio/filter/NumberInterval.java @@ -1,22 +1,22 @@ -package com.podio.filter; - -public final class NumberInterval { - - private final float from; - - private final float to; - - public NumberInterval(float from, float to) { - super(); - this.from = from; - this.to = to; - } - - public float getFrom() { - return from; - } - - public float getTo() { - return to; - } -} +package com.podio.filter; + +public final class NumberInterval { + + private final float from; + + private final float to; + + public NumberInterval(float from, float to) { + super(); + this.from = from; + this.to = to; + } + + public float getFrom() { + return from; + } + + public float getTo() { + return to; + } +} diff --git a/src/main/java/com/podio/filter/PodioDate.java b/src/main/java/com/podio/filter/PodioDate.java index 0186745..d54353b 100644 --- a/src/main/java/com/podio/filter/PodioDate.java +++ b/src/main/java/com/podio/filter/PodioDate.java @@ -1,6 +1,6 @@ -package com.podio.filter; - -public interface PodioDate { - - String serialize(); -} +package com.podio.filter; + +public interface PodioDate { + + String serialize(); +} diff --git a/src/main/java/com/podio/filter/PodioDateInterval.java b/src/main/java/com/podio/filter/PodioDateInterval.java index 9f2769c..15f1dc3 100644 --- a/src/main/java/com/podio/filter/PodioDateInterval.java +++ b/src/main/java/com/podio/filter/PodioDateInterval.java @@ -1,33 +1,33 @@ -package com.podio.filter; - -import org.joda.time.LocalDate; - -public class PodioDateInterval { - - private final PodioDate fromDate; - - private final PodioDate toDate; - - public PodioDateInterval(PodioDate fromDate, PodioDate toDate) { - super(); - this.fromDate = fromDate; - this.toDate = toDate; - } - - public String serialize() { - String result = ""; - if (fromDate != null) { - result += fromDate.serialize(); - } - result += "-"; - if (toDate != null) { - result += toDate.serialize(); - } - return result; - } - - public static final PodioDateInterval absolute(LocalDate fromDate, LocalDate toDate) { - return new PodioDateInterval(new AbsolutePodioDate(fromDate), new AbsolutePodioDate(toDate)); - } - -} +package com.podio.filter; + +import org.joda.time.LocalDate; + +public class PodioDateInterval { + + private final PodioDate fromDate; + + private final PodioDate toDate; + + public PodioDateInterval(PodioDate fromDate, PodioDate toDate) { + super(); + this.fromDate = fromDate; + this.toDate = toDate; + } + + public String serialize() { + String result = ""; + if (fromDate != null) { + result += fromDate.serialize(); + } + result += "-"; + if (toDate != null) { + result += toDate.serialize(); + } + return result; + } + + public static final PodioDateInterval absolute(LocalDate fromDate, LocalDate toDate) { + return new PodioDateInterval(new AbsolutePodioDate(fromDate), new AbsolutePodioDate(toDate)); + } + +} diff --git a/src/main/java/com/podio/filter/ProgressFieldFilterBy.java b/src/main/java/com/podio/filter/ProgressFieldFilterBy.java index 1c55972..52481b1 100644 --- a/src/main/java/com/podio/filter/ProgressFieldFilterBy.java +++ b/src/main/java/com/podio/filter/ProgressFieldFilterBy.java @@ -1,13 +1,13 @@ -package com.podio.filter; - -public class ProgressFieldFilterBy extends FieldFilterBy { - - public ProgressFieldFilterBy(int fieldId) { - super(fieldId); - } - - @Override - public String format(ProgressInterval value) { - return value.getFrom() + "-" + value.getTo(); - } -} +package com.podio.filter; + +public class ProgressFieldFilterBy extends FieldFilterBy { + + public ProgressFieldFilterBy(int fieldId) { + super(fieldId); + } + + @Override + public String format(ProgressInterval value) { + return value.getFrom() + "-" + value.getTo(); + } +} diff --git a/src/main/java/com/podio/filter/ProgressInterval.java b/src/main/java/com/podio/filter/ProgressInterval.java index 5cc7750..b808aae 100644 --- a/src/main/java/com/podio/filter/ProgressInterval.java +++ b/src/main/java/com/podio/filter/ProgressInterval.java @@ -1,32 +1,32 @@ -package com.podio.filter; - -public final class ProgressInterval { - - private final int from; - - private final int to; - - public ProgressInterval(int from, int to) { - super(); - this.from = from; - this.to = to; - - if (from < 0 || from > 100) { - throw new IllegalArgumentException("From must be between 0 and 100"); - } - if (to < 0 || to > 100) { - throw new IllegalArgumentException("To must be between 0 and 100"); - } - if (to < from) { - throw new IllegalArgumentException("To must be larger than from"); - } - } - - public int getFrom() { - return from; - } - - public int getTo() { - return to; - } -} +package com.podio.filter; + +public final class ProgressInterval { + + private final int from; + + private final int to; + + public ProgressInterval(int from, int to) { + super(); + this.from = from; + this.to = to; + + if (from < 0 || from > 100) { + throw new IllegalArgumentException("From must be between 0 and 100"); + } + if (to < 0 || to > 100) { + throw new IllegalArgumentException("To must be between 0 and 100"); + } + if (to < from) { + throw new IllegalArgumentException("To must be larger than from"); + } + } + + public int getFrom() { + return from; + } + + public int getTo() { + return to; + } +} diff --git a/src/main/java/com/podio/filter/RelativePodioDate.java b/src/main/java/com/podio/filter/RelativePodioDate.java index 114ccb9..d927a67 100644 --- a/src/main/java/com/podio/filter/RelativePodioDate.java +++ b/src/main/java/com/podio/filter/RelativePodioDate.java @@ -1,57 +1,57 @@ -package com.podio.filter; - -public class RelativePodioDate implements PodioDate { - - public static enum Unit { - DAY('d'), - WEEK('w'), - MONTH('m'), - YEAR('y'); - - private final char character; - - private Unit(char character) { - this.character = character; - } - - public char getCharacter() { - return character; - } - } - - private final int offset; - - private final Unit unit; - - private final boolean round; - - public RelativePodioDate(int offset, Unit unit, boolean round) { - super(); - this.offset = offset; - this.unit = unit; - this.round = round; - } - - public int getOffset() { - return offset; - } - - public Unit getUnit() { - return unit; - } - - public boolean isRound() { - return round; - } - - @Override - public String serialize() { - String result = Integer.toString(this.offset); - result += this.unit.getCharacter(); - if (this.round) { - result += "r"; - } - return result; - } - -} +package com.podio.filter; + +public class RelativePodioDate implements PodioDate { + + public static enum Unit { + DAY('d'), + WEEK('w'), + MONTH('m'), + YEAR('y'); + + private final char character; + + private Unit(char character) { + this.character = character; + } + + public char getCharacter() { + return character; + } + } + + private final int offset; + + private final Unit unit; + + private final boolean round; + + public RelativePodioDate(int offset, Unit unit, boolean round) { + super(); + this.offset = offset; + this.unit = unit; + this.round = round; + } + + public int getOffset() { + return offset; + } + + public Unit getUnit() { + return unit; + } + + public boolean isRound() { + return round; + } + + @Override + public String serialize() { + String result = Integer.toString(this.offset); + result += this.unit.getCharacter(); + if (this.round) { + result += "r"; + } + return result; + } + +} diff --git a/src/main/java/com/podio/filter/SortBy.java b/src/main/java/com/podio/filter/SortBy.java index 5cd694e..007bbc5 100644 --- a/src/main/java/com/podio/filter/SortBy.java +++ b/src/main/java/com/podio/filter/SortBy.java @@ -1,6 +1,6 @@ -package com.podio.filter; - -public interface SortBy { - - String getKey(); -} +package com.podio.filter; + +public interface SortBy { + + String getKey(); +} diff --git a/src/main/java/com/podio/filter/StandardSortBy.java b/src/main/java/com/podio/filter/StandardSortBy.java index c5908e9..e825e2e 100644 --- a/src/main/java/com/podio/filter/StandardSortBy.java +++ b/src/main/java/com/podio/filter/StandardSortBy.java @@ -1,13 +1,13 @@ -package com.podio.filter; - -public enum StandardSortBy implements SortBy { - - LAST_EDIT_ON, - CREATED_ON, - FIVESTAR; - - @Override - public String getKey() { - return name().toLowerCase(); - } -} +package com.podio.filter; + +public enum StandardSortBy implements SortBy { + + LAST_EDIT_ON, + CREATED_ON, + FIVESTAR; + + @Override + public String getKey() { + return name().toLowerCase(); + } +} diff --git a/src/main/java/com/podio/filter/StateFieldFilterBy.java b/src/main/java/com/podio/filter/StateFieldFilterBy.java index dc6cebe..b6d92d0 100644 --- a/src/main/java/com/podio/filter/StateFieldFilterBy.java +++ b/src/main/java/com/podio/filter/StateFieldFilterBy.java @@ -1,17 +1,17 @@ -package com.podio.filter; - -import java.util.List; - -import com.podio.common.CSVUtil; - -public class StateFieldFilterBy extends FieldFilterBy> { - - public StateFieldFilterBy(int fieldId) { - super(fieldId); - } - - @Override - public String format(List values) { - return CSVUtil.toCSV(values); - } -} +package com.podio.filter; + +import java.util.List; + +import com.podio.common.CSVUtil; + +public class StateFieldFilterBy extends FieldFilterBy> { + + public StateFieldFilterBy(int fieldId) { + super(fieldId); + } + + @Override + public String format(List values) { + return CSVUtil.toCSV(values); + } +} diff --git a/src/main/java/com/podio/filter/TitleFilterBy.java b/src/main/java/com/podio/filter/TitleFilterBy.java index 2ae42af..2c1e69e 100644 --- a/src/main/java/com/podio/filter/TitleFilterBy.java +++ b/src/main/java/com/podio/filter/TitleFilterBy.java @@ -1,14 +1,14 @@ -package com.podio.filter; - -public class TitleFilterBy implements FilterBy { - - @Override - public String getKey() { - return "title"; - } - - @Override - public String format(String value) { - return value; - } -} +package com.podio.filter; + +public class TitleFilterBy implements FilterBy { + + @Override + public String getKey() { + return "title"; + } + + @Override + public String format(String value) { + return value; + } +} diff --git a/src/main/java/com/podio/hook/Hook.java b/src/main/java/com/podio/hook/Hook.java index 3c37dd4..80d1fdd 100644 --- a/src/main/java/com/podio/hook/Hook.java +++ b/src/main/java/com/podio/hook/Hook.java @@ -1,49 +1,49 @@ -package com.podio.hook; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.common.CreatedBase; - -public class Hook extends CreatedBase { - - private int id; - - private HookStatus status; - - private HookType type; - - private String url; - - public int getId() { - return id; - } - - @JsonProperty("hook_id") - public void setId(int id) { - this.id = id; - } - - public HookStatus getStatus() { - return status; - } - - public void setStatus(HookStatus status) { - this.status = status; - } - - public HookType getType() { - return type; - } - - public void setType(HookType type) { - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } -} +package com.podio.hook; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.CreatedBase; + +public class Hook extends CreatedBase { + + private int id; + + private HookStatus status; + + private HookType type; + + private String url; + + public int getId() { + return id; + } + + @JsonProperty("hook_id") + public void setId(int id) { + this.id = id; + } + + public HookStatus getStatus() { + return status; + } + + public void setStatus(HookStatus status) { + this.status = status; + } + + public HookType getType() { + return type; + } + + public void setType(HookType type) { + this.type = type; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/main/java/com/podio/hook/HookAPI.java b/src/main/java/com/podio/hook/HookAPI.java index ea5f66b..0ef3e38 100644 --- a/src/main/java/com/podio/hook/HookAPI.java +++ b/src/main/java/com/podio/hook/HookAPI.java @@ -1,90 +1,90 @@ -package com.podio.hook; - -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.Empty; -import com.podio.common.Reference; -import com.sun.jersey.api.client.GenericType; - -public class HookAPI extends BaseAPI { - - public HookAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Create a new hook on the given object. - * - * @param object - * The reference to the object the hook should be created on - * @param create - * The details for the new hook - * @return The id of the newly created hook - */ - public int create(Reference object, HookCreate create) { - return getResourceFactory() - .getApiResource( - "/hook/" + object.getType() + "/" + object.getId() - + "/") - .entity(create, MediaType.APPLICATION_JSON) - .post(HookCreateResponse.class).getId(); - } - - /** - * Deletes the hook with the given id. - * - * @param id - * The id of the hook - */ - public void delete(int id) { - getResourceFactory().getApiResource("/hook/" + id).delete(); - } - - /** - * Returns the hooks on the object. - * - * @param object - * The reference to the object to get hooks for - * - * @return The list of hooks on the object - */ - public List get(Reference object) { - return getResourceFactory().getApiResource( - "/hook/" + object.getType() + "/" + object.getId() + "/").get( - new GenericType>() { - }); - } - - /** - * Request the hook to be validated. This will cause the hook to send a - * request to the URL with the parameter "type" set to "hook.verify" and - * "code" set to the verification code. The endpoint must then call the - * validate method with the code to complete the verification. - * - * @param id - * The id of the hook to be verified - */ - public void requestVerification(int id) { - getResourceFactory().getApiResource("/hook/" + id + "/verify/request") - .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Validates the hook using the code received from the verify call. On - * successful validation the hook will become active. - * - * @param id - * The id of the hook to be verified - * @param code - * The code received from the call to the endpoint - */ - public void validateVerification(int id, String code) { - getResourceFactory().getApiResource("/hook/" + id + "/verify/validate") - .entity(new HookValidate(code), MediaType.APPLICATION_JSON) - .post(); - } -} +package com.podio.hook; + +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.Empty; +import com.podio.common.Reference; +import com.sun.jersey.api.client.GenericType; + +public class HookAPI extends BaseAPI { + + public HookAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Create a new hook on the given object. + * + * @param object + * The reference to the object the hook should be created on + * @param create + * The details for the new hook + * @return The id of the newly created hook + */ + public int create(Reference object, HookCreate create) { + return getResourceFactory() + .getApiResource( + "/hook/" + object.getType() + "/" + object.getId() + + "/") + .entity(create, MediaType.APPLICATION_JSON) + .post(HookCreateResponse.class).getId(); + } + + /** + * Deletes the hook with the given id. + * + * @param id + * The id of the hook + */ + public void delete(int id) { + getResourceFactory().getApiResource("/hook/" + id).delete(); + } + + /** + * Returns the hooks on the object. + * + * @param object + * The reference to the object to get hooks for + * + * @return The list of hooks on the object + */ + public List get(Reference object) { + return getResourceFactory().getApiResource( + "/hook/" + object.getType() + "/" + object.getId() + "/").get( + new GenericType>() { + }); + } + + /** + * Request the hook to be validated. This will cause the hook to send a + * request to the URL with the parameter "type" set to "hook.verify" and + * "code" set to the verification code. The endpoint must then call the + * validate method with the code to complete the verification. + * + * @param id + * The id of the hook to be verified + */ + public void requestVerification(int id) { + getResourceFactory().getApiResource("/hook/" + id + "/verify/request") + .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Validates the hook using the code received from the verify call. On + * successful validation the hook will become active. + * + * @param id + * The id of the hook to be verified + * @param code + * The code received from the call to the endpoint + */ + public void validateVerification(int id, String code) { + getResourceFactory().getApiResource("/hook/" + id + "/verify/validate") + .entity(new HookValidate(code), MediaType.APPLICATION_JSON) + .post(); + } +} diff --git a/src/main/java/com/podio/hook/HookCreate.java b/src/main/java/com/podio/hook/HookCreate.java index 0791de2..e89d656 100644 --- a/src/main/java/com/podio/hook/HookCreate.java +++ b/src/main/java/com/podio/hook/HookCreate.java @@ -1,36 +1,36 @@ -package com.podio.hook; - -public class HookCreate { - - /** - * The url of endpoint - */ - private String url; - - /** - * The type of events to listen to - */ - private HookType type; - - public HookCreate(String url, HookType type) { - super(); - this.url = url; - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public HookType getType() { - return type; - } - - public void setType(HookType type) { - this.type = type; - } -} +package com.podio.hook; + +public class HookCreate { + + /** + * The url of endpoint + */ + private String url; + + /** + * The type of events to listen to + */ + private HookType type; + + public HookCreate(String url, HookType type) { + super(); + this.url = url; + this.type = type; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public HookType getType() { + return type; + } + + public void setType(HookType type) { + this.type = type; + } +} diff --git a/src/main/java/com/podio/hook/HookCreateResponse.java b/src/main/java/com/podio/hook/HookCreateResponse.java index 74fadce..fab1324 100644 --- a/src/main/java/com/podio/hook/HookCreateResponse.java +++ b/src/main/java/com/podio/hook/HookCreateResponse.java @@ -1,20 +1,20 @@ -package com.podio.hook; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class HookCreateResponse { - - /** - * The id of the hook created - */ - private int id; - - public int getId() { - return id; - } - - @JsonProperty("hook_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.hook; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class HookCreateResponse { + + /** + * The id of the hook created + */ + private int id; + + public int getId() { + return id; + } + + @JsonProperty("hook_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/hook/HookStatus.java b/src/main/java/com/podio/hook/HookStatus.java index 44e0c3f..3aab024 100644 --- a/src/main/java/com/podio/hook/HookStatus.java +++ b/src/main/java/com/podio/hook/HookStatus.java @@ -1,20 +1,20 @@ -package com.podio.hook; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum HookStatus { - - INACTIVE, ACTIVE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static HookStatus getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.hook; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum HookStatus { + + INACTIVE, ACTIVE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static HookStatus getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/hook/HookType.java b/src/main/java/com/podio/hook/HookType.java index 5c244aa..4ac8323 100644 --- a/src/main/java/com/podio/hook/HookType.java +++ b/src/main/java/com/podio/hook/HookType.java @@ -1,39 +1,39 @@ -package com.podio.hook; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum HookType { - - ITEM_CREATE("item.create"), - ITEM_UPDATE("item.update"), - ITEM_DELETE("item.delete"), - COMMENT_CREATE("comment.create"), - COMMENT_DELETE("comment.delete"), - FILE_CHANGE("file.change"), - APP_UPDATE("app.update"), - APP_DELETE("app.delete"); - - private final String externalName; - - private HookType(String externalName) { - this.externalName = externalName; - } - - @Override - @JsonValue - public String toString() { - return externalName; - } - - @JsonCreator - public static HookType getByName(String value) { - for (HookType type : values()) { - if (type.externalName.equals(value)) { - return type; - } - } - - return null; - } -} +package com.podio.hook; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum HookType { + + ITEM_CREATE("item.create"), + ITEM_UPDATE("item.update"), + ITEM_DELETE("item.delete"), + COMMENT_CREATE("comment.create"), + COMMENT_DELETE("comment.delete"), + FILE_CHANGE("file.change"), + APP_UPDATE("app.update"), + APP_DELETE("app.delete"); + + private final String externalName; + + private HookType(String externalName) { + this.externalName = externalName; + } + + @Override + @JsonValue + public String toString() { + return externalName; + } + + @JsonCreator + public static HookType getByName(String value) { + for (HookType type : values()) { + if (type.externalName.equals(value)) { + return type; + } + } + + return null; + } +} diff --git a/src/main/java/com/podio/hook/HookValidate.java b/src/main/java/com/podio/hook/HookValidate.java index 2dd6786..c19c3a5 100644 --- a/src/main/java/com/podio/hook/HookValidate.java +++ b/src/main/java/com/podio/hook/HookValidate.java @@ -1,19 +1,19 @@ -package com.podio.hook; - -public class HookValidate { - - private String code; - - public HookValidate(String code) { - super(); - this.code = code; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } -} +package com.podio.hook; + +public class HookValidate { + + private String code; + + public HookValidate(String code) { + super(); + this.code = code; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } +} diff --git a/src/main/java/com/podio/item/AppActivities.java b/src/main/java/com/podio/item/AppActivities.java index f706772..c17899f 100644 --- a/src/main/java/com/podio/item/AppActivities.java +++ b/src/main/java/com/podio/item/AppActivities.java @@ -1,29 +1,29 @@ -package com.podio.item; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class AppActivities { - - private List today; - - private List lastWeek; - - public List getToday() { - return today; - } - - public void setToday(List today) { - this.today = today; - } - - public List getLastWeek() { - return lastWeek; - } - - @JsonProperty("last_week") - public void setLastWeek(List lastWeek) { - this.lastWeek = lastWeek; - } -} +package com.podio.item; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class AppActivities { + + private List today; + + private List lastWeek; + + public List getToday() { + return today; + } + + public void setToday(List today) { + this.today = today; + } + + public List getLastWeek() { + return lastWeek; + } + + @JsonProperty("last_week") + public void setLastWeek(List lastWeek) { + this.lastWeek = lastWeek; + } +} diff --git a/src/main/java/com/podio/item/AppActivity.java b/src/main/java/com/podio/item/AppActivity.java index 7b82f08..6ad2fb0 100644 --- a/src/main/java/com/podio/item/AppActivity.java +++ b/src/main/java/com/podio/item/AppActivity.java @@ -1,91 +1,91 @@ -package com.podio.item; - -import java.util.HashMap; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.contact.ProfileMini; - -public class AppActivity { - - /** - * The type of activity - */ - private ItemActivityType type; - - /** - * When the activity happened - */ - private DateTime createdOn; - - /** - * The id of the item the activity was on - */ - private int itemId; - - /** - * The title of the item - */ - private String title; - - /** - * Any data associated with the event - */ - private HashMap data; - - /** - * The user who was responsible for the event - */ - private ProfileMini user; - - public ItemActivityType getType() { - return type; - } - - public void setType(ItemActivityType type) { - this.type = type; - } - - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } - - public int getItemId() { - return itemId; - } - - @JsonProperty("item_id") - public void setItemId(int itemId) { - this.itemId = itemId; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public HashMap getData() { - return data; - } - - public void setData(HashMap data) { - this.data = data; - } - - public ProfileMini getUser() { - return user; - } - - public void setUser(ProfileMini user) { - this.user = user; - } -} +package com.podio.item; + +import java.util.HashMap; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.contact.ProfileMini; + +public class AppActivity { + + /** + * The type of activity + */ + private ItemActivityType type; + + /** + * When the activity happened + */ + private DateTime createdOn; + + /** + * The id of the item the activity was on + */ + private int itemId; + + /** + * The title of the item + */ + private String title; + + /** + * Any data associated with the event + */ + private HashMap data; + + /** + * The user who was responsible for the event + */ + private ProfileMini user; + + public ItemActivityType getType() { + return type; + } + + public void setType(ItemActivityType type) { + this.type = type; + } + + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } + + public int getItemId() { + return itemId; + } + + @JsonProperty("item_id") + public void setItemId(int itemId) { + this.itemId = itemId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public HashMap getData() { + return data; + } + + public void setData(HashMap data) { + this.data = data; + } + + public ProfileMini getUser() { + return user; + } + + public void setUser(ProfileMini user) { + this.user = user; + } +} diff --git a/src/main/java/com/podio/item/FieldValuesUpdate.java b/src/main/java/com/podio/item/FieldValuesUpdate.java index 0e6f1d4..9536b56 100644 --- a/src/main/java/com/podio/item/FieldValuesUpdate.java +++ b/src/main/java/com/podio/item/FieldValuesUpdate.java @@ -1,95 +1,95 @@ -package com.podio.item; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class FieldValuesUpdate { - - /** - * The id of the field - */ - private Integer id; - - /** - * The external id of the field - */ - private String externalId; - - /** - * The values - */ - private List> values; - - public FieldValuesUpdate() { - super(); - } - - public FieldValuesUpdate(int id, List> values) { - super(); - this.id = id; - this.values = values; - } - - public FieldValuesUpdate(int id, Map value) { - super(); - this.id = id; - this.values = Collections.> singletonList(value); - } - - public FieldValuesUpdate(int id, String subId, Object value) { - super(); - this.id = id; - this.values = Collections.> singletonList(Collections - .singletonMap(subId, value)); - } - - public FieldValuesUpdate(String externalId, List> values) { - super(); - this.externalId = externalId; - this.values = values; - } - - public FieldValuesUpdate(String externalId, Map value) { - super(); - this.externalId = externalId; - this.values = Collections.> singletonList(value); - } - - public FieldValuesUpdate(String externalId, String subId, Object value) { - super(); - this.externalId = externalId; - this.values = Collections.> singletonList(Collections - .singletonMap(subId, value)); - } - - @JsonProperty("field_id") - public Integer getId() { - return id; - } - - @JsonProperty("field_id") - public void setId(Integer fieldId) { - this.id = fieldId; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public List> getValues() { - return values; - } - - public void setValues(List> values) { - this.values = values; - } -} +package com.podio.item; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class FieldValuesUpdate { + + /** + * The id of the field + */ + private Integer id; + + /** + * The external id of the field + */ + private String externalId; + + /** + * The values + */ + private List> values; + + public FieldValuesUpdate() { + super(); + } + + public FieldValuesUpdate(int id, List> values) { + super(); + this.id = id; + this.values = values; + } + + public FieldValuesUpdate(int id, Map value) { + super(); + this.id = id; + this.values = Collections.> singletonList(value); + } + + public FieldValuesUpdate(int id, String subId, Object value) { + super(); + this.id = id; + this.values = Collections.> singletonList(Collections + .singletonMap(subId, value)); + } + + public FieldValuesUpdate(String externalId, List> values) { + super(); + this.externalId = externalId; + this.values = values; + } + + public FieldValuesUpdate(String externalId, Map value) { + super(); + this.externalId = externalId; + this.values = Collections.> singletonList(value); + } + + public FieldValuesUpdate(String externalId, String subId, Object value) { + super(); + this.externalId = externalId; + this.values = Collections.> singletonList(Collections + .singletonMap(subId, value)); + } + + @JsonProperty("field_id") + public Integer getId() { + return id; + } + + @JsonProperty("field_id") + public void setId(Integer fieldId) { + this.id = fieldId; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public List> getValues() { + return values; + } + + public void setValues(List> values) { + this.values = values; + } +} diff --git a/src/main/java/com/podio/item/FieldValuesView.java b/src/main/java/com/podio/item/FieldValuesView.java index 543b554..44f9774 100644 --- a/src/main/java/com/podio/item/FieldValuesView.java +++ b/src/main/java/com/podio/item/FieldValuesView.java @@ -1,87 +1,87 @@ -package com.podio.item; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.app.ApplicationFieldType; - -public class FieldValuesView implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the field - */ - private int id; - - /** - * The external id of the field - */ - private String externalId; - - /** - * The type of the field - */ - private ApplicationFieldType type; - - /** - * The label of the field - */ - private String label; - - /** - * The values - */ - private List> values; - - public FieldValuesView() { - super(); - } - - @JsonProperty("field_id") - public int getId() { - return id; - } - - @JsonProperty("field_id") - public void setId(int fieldId) { - this.id = fieldId; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public ApplicationFieldType getType() { - return type; - } - - public void setType(ApplicationFieldType type) { - this.type = type; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public List> getValues() { - return values; - } - - public void setValues(List> values) { - this.values = values; - } -} +package com.podio.item; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.app.ApplicationFieldType; + +public class FieldValuesView implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the field + */ + private int id; + + /** + * The external id of the field + */ + private String externalId; + + /** + * The type of the field + */ + private ApplicationFieldType type; + + /** + * The label of the field + */ + private String label; + + /** + * The values + */ + private List> values; + + public FieldValuesView() { + super(); + } + + @JsonProperty("field_id") + public int getId() { + return id; + } + + @JsonProperty("field_id") + public void setId(int fieldId) { + this.id = fieldId; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public ApplicationFieldType getType() { + return type; + } + + public void setType(ApplicationFieldType type) { + this.type = type; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List> getValues() { + return values; + } + + public void setValues(List> values) { + this.values = values; + } +} diff --git a/src/main/java/com/podio/item/Item.java b/src/main/java/com/podio/item/Item.java index 32306ee..0ac8135 100644 --- a/src/main/java/com/podio/item/Item.java +++ b/src/main/java/com/podio/item/Item.java @@ -1,267 +1,267 @@ -package com.podio.item; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonDeserialize; -import org.joda.time.DateTime; - -import com.podio.app.Application; -import com.podio.comment.Comment; -import com.podio.common.AuthorizationEntity; -import com.podio.file.File; -import com.podio.rating.RatingType; -import com.podio.rating.RatingTypeKeyDeserializer; -import com.podio.rating.RatingValuesMap; - -public class Item implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The id of the item - */ - private int id; - - /** - * The app where the item belongs - */ - private Application application; - - /** - * The external id of the item. This can be used to hold a reference to the - * item in an external system. - */ - private String externalId; - - /** - * The information on who created the first revision of the item - */ - private ItemRevision initialRevision; - - /** - * The latest revision - */ - private ItemRevision currentRevision; - - /** - * The title of the item. This is made of up one of the fields below, or by - * the item name and id - */ - private String title; - - /** - * The direct link to the item - */ - private String link; - - /** - * The values for each field - */ - private List fields; - - /** - * The latest 8 revisions of the item sorted descending by date - */ - private List revisions; - - /** - * All the comments on the item - */ - private List comments; - - /** - * The ratings on the item - */ - private RatingValuesMap ratings; - - /** - * The files on the item - */ - private List files; - - /** - * The tags on the item - */ - private List tags; - - /** - * true if the user is subscribed to the item, - * false otherwise - */ - private boolean subscribed; - - /** - * The ratings and their values done by the active user on the item - */ - private Map userRatings; - - /** - * The entity who created the item - */ - private AuthorizationEntity createdBy; - - /** - * The date and time the item was created - */ - private DateTime createdOn; - - - @JsonProperty("item_id") - public int getId() { - return id; - } - - @JsonProperty("item_id") - public void setId(int id) { - this.id = id; - } - - @JsonProperty("app") - public Application getApplication() { - return application; - } - - @JsonProperty("app") - public void setApplication(Application application) { - this.application = application; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - @JsonProperty("initial_revision") - public ItemRevision getInitialRevision() { - return initialRevision; - } - - @JsonProperty("initial_revision") - public void setInitialRevision(ItemRevision initialRevision) { - this.initialRevision = initialRevision; - } - - @JsonProperty("current_revision") - public ItemRevision getCurrentRevision() { - return currentRevision; - } - - @JsonProperty("current_revision") - public void setCurrentRevision(ItemRevision currentRevision) { - this.currentRevision = currentRevision; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - public List getRevisions() { - return revisions; - } - - public void setRevisions(List revisions) { - this.revisions = revisions; - } - - public List getComments() { - return comments; - } - - public void setComments(List comments) { - this.comments = comments; - } - - public RatingValuesMap getRatings() { - return ratings; - } - - public void setRatings(RatingValuesMap ratings) { - this.ratings = ratings; - } - - public List getFiles() { - return files; - } - - public void setFiles(List files) { - this.files = files; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public boolean isSubscribed() { - return subscribed; - } - - public void setSubscribed(boolean subscribed) { - this.subscribed = subscribed; - } - - public Integer getUserRating(RatingType type) { - return userRatings.get(type); - } - - public Map getUserRatings() { - return userRatings; - } - - @JsonDeserialize(keyUsing = RatingTypeKeyDeserializer.class) - @JsonProperty("user_ratings") - public void setUserRatings(Map userRatings) { - this.userRatings = userRatings; - } - - @JsonProperty("created_by") - public AuthorizationEntity getCreatedBy() { - return createdBy; - } - - @JsonProperty("created_by") - public void setCreatedBy(AuthorizationEntity createdBy) { - this.createdBy = createdBy; - } - - @JsonProperty("created_on") - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } -} +package com.podio.item; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonDeserialize; +import org.joda.time.DateTime; + +import com.podio.app.Application; +import com.podio.comment.Comment; +import com.podio.common.AuthorizationEntity; +import com.podio.file.File; +import com.podio.rating.RatingType; +import com.podio.rating.RatingTypeKeyDeserializer; +import com.podio.rating.RatingValuesMap; + +public class Item implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * The id of the item + */ + private int id; + + /** + * The app where the item belongs + */ + private Application application; + + /** + * The external id of the item. This can be used to hold a reference to the + * item in an external system. + */ + private String externalId; + + /** + * The information on who created the first revision of the item + */ + private ItemRevision initialRevision; + + /** + * The latest revision + */ + private ItemRevision currentRevision; + + /** + * The title of the item. This is made of up one of the fields below, or by + * the item name and id + */ + private String title; + + /** + * The direct link to the item + */ + private String link; + + /** + * The values for each field + */ + private List fields; + + /** + * The latest 8 revisions of the item sorted descending by date + */ + private List revisions; + + /** + * All the comments on the item + */ + private List comments; + + /** + * The ratings on the item + */ + private RatingValuesMap ratings; + + /** + * The files on the item + */ + private List files; + + /** + * The tags on the item + */ + private List tags; + + /** + * true if the user is subscribed to the item, + * false otherwise + */ + private boolean subscribed; + + /** + * The ratings and their values done by the active user on the item + */ + private Map userRatings; + + /** + * The entity who created the item + */ + private AuthorizationEntity createdBy; + + /** + * The date and time the item was created + */ + private DateTime createdOn; + + + @JsonProperty("item_id") + public int getId() { + return id; + } + + @JsonProperty("item_id") + public void setId(int id) { + this.id = id; + } + + @JsonProperty("app") + public Application getApplication() { + return application; + } + + @JsonProperty("app") + public void setApplication(Application application) { + this.application = application; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + @JsonProperty("initial_revision") + public ItemRevision getInitialRevision() { + return initialRevision; + } + + @JsonProperty("initial_revision") + public void setInitialRevision(ItemRevision initialRevision) { + this.initialRevision = initialRevision; + } + + @JsonProperty("current_revision") + public ItemRevision getCurrentRevision() { + return currentRevision; + } + + @JsonProperty("current_revision") + public void setCurrentRevision(ItemRevision currentRevision) { + this.currentRevision = currentRevision; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public List getRevisions() { + return revisions; + } + + public void setRevisions(List revisions) { + this.revisions = revisions; + } + + public List getComments() { + return comments; + } + + public void setComments(List comments) { + this.comments = comments; + } + + public RatingValuesMap getRatings() { + return ratings; + } + + public void setRatings(RatingValuesMap ratings) { + this.ratings = ratings; + } + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public boolean isSubscribed() { + return subscribed; + } + + public void setSubscribed(boolean subscribed) { + this.subscribed = subscribed; + } + + public Integer getUserRating(RatingType type) { + return userRatings.get(type); + } + + public Map getUserRatings() { + return userRatings; + } + + @JsonDeserialize(keyUsing = RatingTypeKeyDeserializer.class) + @JsonProperty("user_ratings") + public void setUserRatings(Map userRatings) { + this.userRatings = userRatings; + } + + @JsonProperty("created_by") + public AuthorizationEntity getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_by") + public void setCreatedBy(AuthorizationEntity createdBy) { + this.createdBy = createdBy; + } + + @JsonProperty("created_on") + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } +} diff --git a/src/main/java/com/podio/item/ItemAPI.java b/src/main/java/com/podio/item/ItemAPI.java index 6cc3b3c..bc22842 100644 --- a/src/main/java/com/podio/item/ItemAPI.java +++ b/src/main/java/com/podio/item/ItemAPI.java @@ -1,325 +1,421 @@ -package com.podio.item; - -import java.util.List; -import java.util.Map; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.ToStringUtil; -import com.podio.filter.ExternalIdFilterBy; -import com.podio.filter.FilterByValue; -import com.podio.filter.SortBy; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; - -/** - * Items are entries in an app. If you think of app as a table, items will be - * the rows in the table. Items consists of some basic information as well - * values for each of the fields in the app. For each field there can be - * multiple values (F.ex. there can be multiple links to another app) and - * multiple types of values (F.ex. a field of type date field consists of both a - * start date and an optional end date). The type is denoted by an string id - * called a sub_id. Most types of fields have only one type, which is denoted by - * the sub_id values. Others have multiple sub_ids. - */ -public class ItemAPI extends BaseAPI { - - public ItemAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Adds a new item to the given app. - * - * @param appId - * The id of the app the item should be added to - * @param create - * The data for the new item - * @param silent - * True if the create should be silten, false otherwise - * @return The id of the newly created item - */ - public int addItem(int appId, ItemCreate create, boolean silent) { - return getResourceFactory().getApiResource("/item/app/" + appId + "/") - .queryParam("silent", silent ? "1" : "0") - .entity(create, MediaType.APPLICATION_JSON_TYPE) - .post(ItemCreateResponse.class).getId(); - } - - /** - * Gets the item with the given id - * - * @param itemId - * The id of the item - * @return The item with given id - */ - public Item getItem(int itemId) { - return getResourceFactory().getApiResource("/item/" + itemId).get( - Item.class); - } - - /** - * Updates the entire item. Only fields which have values specified will be - * updated. To delete the contents of a field, pass an empty array for the - * value. - * - * @param itemId - * The id of the item to update - * @param update - * The data for the update - * @param silent - * True if the update should be silent, false otherwise - * @param hook - * True if hooks should be executed for the change, false otherwise - */ - public void updateItem(int itemId, ItemUpdate update, boolean silent, boolean hook) { - getResourceFactory().getApiResource("/item/" + itemId) - .queryParam("silent", silent ? "1" : "0") - .queryParam("hook", hook ? "1" : "0") - .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Updates all the values for an item - * - * @param itemId - * The id of the item - * @param values - * The values for the fields - * @param silent - * True if the update should be silent, false otherwise - * @param hook - * True if hooks should be executed for the change, false otherwise - */ - public void updateItemValues(int itemId, List values, - boolean silent, boolean hook) { - getResourceFactory().getApiResource("/item/" + itemId + "/value/") - .queryParam("silent", silent ? "1" : "0") - .queryParam("hook", hook ? "1" : "0") - .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Update the item values for a specific field. - * - * @param itemId - * The id of the item - * @param fieldId - * The id of the field - * @param values - * The new values for the field - * @param silent - * True if the update should be silent, false otherwise - * @param hook - * True if hooks should be executed for the change, false otherwise - */ - public void updateItemFieldValues(int itemId, int fieldId, - List> values, boolean silent, boolean hook) { - getResourceFactory() - .getApiResource("/item/" + itemId + "/value/" + fieldId) - .queryParam("silent", silent ? "1" : "0") - .queryParam("hook", hook ? "1" : "0") - .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Deletes an item and removes it from all views. The data can no longer be - * retrieved. - * - * @param itemId - * The id of the item - * @param silent - * True if the deletion should be silent, false otherwise - */ - public void deleteItem(int itemId, boolean silent) { - getResourceFactory().getApiResource("/item/" + itemId) - .queryParam("silent", silent ? "1" : "0").delete(); - } - - /** - * Returns the values for a specified field on an item - * - * @param itemId - * The id of the item - * @param fieldId - * The id of the field - * @return The values on the field on the item - */ - public List> getItemFieldValues(int itemId, int fieldId) { - return getResourceFactory().getApiResource( - "/item/" + itemId + "/value/" + fieldId).get( - new GenericType>>() { - }); - } - - /** - * Returns all the values for an item, with the additional data provided by - * the get item operation. - * - * @param itemId - * The id of the item - * @return The values on the item - */ - public List getItemValues(int itemId) { - return getResourceFactory().getApiResource( - "/item/" + itemId + "/value/").get( - new GenericType>() { - }); - } - - /** - * Used to find possible items for a given application field. It searches - * the relevant items for the title given. - * - * @param fieldId - * The id of app reference field to search for - * @param text - * The text to search for in the items title - * @param notItemIds - * If supplied the items with these ids will not be returned - * @param limit - * The maximum number of results to return. Default value: 13 - * @return The items that were valid for the field and with text matching - */ - public List getItemsByFieldAndTitle(int fieldId, String text, - List notItemIds, Integer limit) { - WebResource resource = getResourceFactory().getApiResource( - "/item/field/" + fieldId + "/find"); - - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - - if (notItemIds != null && notItemIds.size() > 0) { - resource = resource.queryParam( - "not_item_id", ToStringUtil.toString(notItemIds, ",")); - } - - resource = resource.queryParam("text", text); - return resource.get(new GenericType>() {}); - } - - /** - * Returns the items that have a reference to the given item. The references - * are grouped by app. Both the apps and the items are sorted by title. - * - * @param itemId - * The id of the item - * @return The references to the given item - */ - public List getItemReference(int itemId) { - return getResourceFactory().getApiResource( - "/item/" + itemId + "/reference/").get( - new GenericType>() { - }); - } - - /** - * Returns the data about the specific revision on an item - * - * @param itemId - * The id of the item - * @param revisionId - * The running revision number, starts at 0 for the initial - * revision - * @return The revision - */ - public ItemRevision getItemRevision(int itemId, int revisionId) { - return getResourceFactory().getApiResource( - "/item/" + itemId + "/revision/" + revisionId).get( - ItemRevision.class); - } - - /** - * Returns the difference in fields values between the two revisions. - * - * @param itemId - * The id of the item - * @param revisionFrom - * The from revision - * @param revisionTo - * The to revision - * @return The difference between the two revision - */ - public List getItemRevisionDifference(int itemId, - int revisionFrom, int revisionTo) { - return getResourceFactory().getApiResource( - "/item/" + itemId + "/revision/" + revisionFrom + "/" - + revisionTo).get( - new GenericType>() { - }); - } - - /** - * Returns all the revisions that have been made to an item - * - * @param itemId - * The id of the item - * @return All the revisions - */ - public List getItemRevisions(int itemId) { - return getResourceFactory().getApiResource( - "/item/" + itemId + "/revision/").get( - new GenericType>() { - }); - } - - /** - * Returns the items on app matching the given filters. - * - * @param appId - * The id of the app - * @param limit - * The maximum number of items to receive, defaults to 20 - * @param offset - * The offset from the start of the items returned, defaults to 0 - * @param sortBy - * How the items should be sorted. For the possible options, see - * the filter area. - * @param sortDesc - * true or leave out to sort descending, use - * false to sort ascending - * @param filters - * The filters to apply - * @return The items matching the filters - */ - public ItemsResponse getItems(int appId, Integer limit, Integer offset, - SortBy sortBy, Boolean sortDesc, FilterByValue... filters) { - WebResource resource = getResourceFactory().getApiResource( - "/item/app/" + appId + "/v2/"); - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - if (offset != null) { - resource = resource.queryParam("offset", offset.toString()); - } - if (sortBy != null) { - resource = resource.queryParam("sort_by", sortBy.getKey()); - } - if (sortDesc != null) { - resource = resource.queryParam("sort_desc", sortDesc ? "1" : "0"); - } - for (FilterByValue filter : filters) { - resource = resource.queryParam(filter.getBy().getKey(), - filter.getFormattedValue()); - } - - return resource.get(ItemsResponse.class); - } - - /** - * Utility method to get items matching an external id - * - * @param appId - * The id of the app - * @param externalId - * The external id - * @return The items matching the app and external id - */ - public ItemsResponse getItemsByExternalId(int appId, String externalId) { - return getItems(appId, null, null, null, null, - new FilterByValue(new ExternalIdFilterBy(), externalId)); - } -} +package com.podio.item; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.ToStringUtil; +import com.podio.filter.ExternalIdFilterBy; +import com.podio.filter.FilterByValue; +import com.podio.filter.SortBy; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; + +/** + * Items are entries in an app. If you think of app as a table, items will be + * the rows in the table. Items consists of some basic information as well + * values for each of the fields in the app. For each field there can be + * multiple values (F.ex. there can be multiple links to another app) and + * multiple types of values (F.ex. a field of type date field consists of both a + * start date and an optional end date). The type is denoted by an string id + * called a sub_id. Most types of fields have only one type, which is denoted by + * the sub_id values. Others have multiple sub_ids. + */ +public class ItemAPI extends BaseAPI { + + public class PaginatePodio + { + public int limit = 50; + } + + public ItemAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Adds a new item to the given app. + * + * @param appId + * The id of the app the item should be added to + * @param create + * The data for the new item + * @param silent + * True if the create should be silten, false otherwise + * @return The id of the newly created item + */ + public int addItem(int appId, ItemCreate create, boolean silent) { + return getResourceFactory().getApiResource("/item/app/" + appId + "/") + .queryParam("silent", silent ? "1" : "0") + .entity(create, MediaType.APPLICATION_JSON_TYPE) + .post(ItemCreateResponse.class).getId(); + } + + /** + * Gets the item with the given id + * + * @param itemId + * The id of the item + * @return The item with given id + */ + public Item getItem(int itemId) { + return getResourceFactory().getApiResource("/item/" + itemId).get( + Item.class); + } + + /** + * Updates the entire item. Only fields which have values specified will be + * updated. To delete the contents of a field, pass an empty array for the + * value. + * + * @param itemId + * The id of the item to update + * @param update + * The data for the update + * @param silent + * True if the update should be silent, false otherwise + * @param hook + * True if hooks should be executed for the change, false otherwise + */ + public void updateItem(int itemId, ItemUpdate update, boolean silent, boolean hook) { + getResourceFactory().getApiResource("/item/" + itemId) + .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") + .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Updates all the values for an item + * + * @param itemId + * The id of the item + * @param values + * The values for the fields + * @param silent + * True if the update should be silent, false otherwise + * @param hook + * True if hooks should be executed for the change, false otherwise + */ + public void updateItemValues(int itemId, List values, + boolean silent, boolean hook) { + getResourceFactory().getApiResource("/item/" + itemId + "/value/") + .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") + .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Update the item values for a specific field. + * + * @param itemId + * The id of the item + * @param fieldId + * The id of the field + * @param values + * The new values for the field + * @param silent + * True if the update should be silent, false otherwise + * @param hook + * True if hooks should be executed for the change, false otherwise + */ + public void updateItemFieldValues(int itemId, int fieldId, + List> values, boolean silent, boolean hook) { + getResourceFactory() + .getApiResource("/item/" + itemId + "/value/" + fieldId) + .queryParam("silent", silent ? "1" : "0") + .queryParam("hook", hook ? "1" : "0") + .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Deletes an item and removes it from all views. The data can no longer be + * retrieved. + * + * @param itemId + * The id of the item + * @param silent + * True if the deletion should be silent, false otherwise + */ + public void deleteItem(int itemId, boolean silent) { + getResourceFactory().getApiResource("/item/" + itemId) + .queryParam("silent", silent ? "1" : "0").delete(); + } + + /** + * Returns the values for a specified field on an item + * + * @param itemId + * The id of the item + * @param fieldId + * The id of the field + * @return The values on the field on the item + */ + public List> getItemFieldValues(int itemId, int fieldId) { + return getResourceFactory().getApiResource( + "/item/" + itemId + "/value/" + fieldId).get( + new GenericType>>() { + }); + } + + /** + * Returns all the values for an item, with the additional data provided by + * the get item operation. + * + * @param itemId + * The id of the item + * @return The values on the item + */ + public List getItemValues(int itemId) { + return getResourceFactory().getApiResource( + "/item/" + itemId + "/value/").get( + new GenericType>() { + }); + } + + /** + * Used to find possible items for a given application field. It searches + * the relevant items for the title given. + * + * @param fieldId + * The id of app reference field to search for + * @param text + * The text to search for in the items title + * @param notItemIds + * If supplied the items with these ids will not be returned + * @param limit + * The maximum number of results to return. Default value: 13 + * @return The items that were valid for the field and with text matching + */ + public List getItemsByFieldAndTitle(int fieldId, String text, + List notItemIds, Integer limit) { + WebResource resource = getResourceFactory().getApiResource( + "/item/field/" + fieldId + "/find"); + + if (limit != null) { + resource = resource.queryParam("limit", limit.toString()); + } + + if (notItemIds != null && notItemIds.size() > 0) { + resource = resource.queryParam( + "not_item_id", ToStringUtil.toString(notItemIds, ",")); + } + + resource = resource.queryParam("text", text); + return resource.get(new GenericType>() {}); + } + + /** + * Returns the items that have a reference to the given item. The references + * are grouped by app. Both the apps and the items are sorted by title. + * + * @param itemId + * The id of the item + * @return The references to the given item + */ + public List getItemReference(int itemId) { + return getResourceFactory().getApiResource( + "/item/" + itemId + "/reference/").get( + new GenericType>() { + }); + } + + /** + * Returns the data about the specific revision on an item + * + * @param itemId + * The id of the item + * @param revisionId + * The running revision number, starts at 0 for the initial + * revision + * @return The revision + */ + public ItemRevision getItemRevision(int itemId, int revisionId) { + return getResourceFactory().getApiResource( + "/item/" + itemId + "/revision/" + revisionId).get( + ItemRevision.class); + } + + /** + * Returns the difference in fields values between the two revisions. + * + * @param itemId + * The id of the item + * @param revisionFrom + * The from revision + * @param revisionTo + * The to revision + * @return The difference between the two revision + */ + public List getItemRevisionDifference(int itemId, + int revisionFrom, int revisionTo) { + return getResourceFactory().getApiResource( + "/item/" + itemId + "/revision/" + revisionFrom + "/" + + revisionTo).get( + new GenericType>() { + }); + } + + /** + * Returns all the revisions that have been made to an item + * + * @param itemId + * The id of the item + * @return All the revisions + */ + public List getItemRevisions(int itemId) { + return getResourceFactory().getApiResource( + "/item/" + itemId + "/revision/").get( + new GenericType>() { + }); + } + + /** + * Returns the items on app matching the given filters. + * + * @param appId + * The id of the app + * @param limit + * The maximum number of items to receive, defaults to 20 + * @param offset + * The offset from the start of the items returned, defaults to 0 + * @param sortBy + * How the items should be sorted. For the possible options, see + * the filter area. + * @param sortDesc + * true or leave out to sort descending, use + * false to sort ascending + * @param filters + * The filters to apply + * @return The items matching the filters + */ + public ItemsResponse getItems(int appId, Integer limit, Integer offset, + SortBy sortBy, Boolean sortDesc, FilterByValue... filters) { + WebResource resource = getResourceFactory().getApiResource( + "/item/app/" + appId + "/filter/"); + Map object = new HashMap(); + if (limit != null) { + object.put("limit", limit); + } + if (offset != null) { + object.put("offset", offset); + } + if (sortBy != null) { + object.put("sort_by", sortBy.getKey()); + } + if (sortDesc != null) { + object.put("sort_desc", sortDesc); + } + if( filters != null ) + { + Map filterMap = new HashMap(); + for (FilterByValue filter : filters) + { + filterMap.put( filter.getBy().getKey(), filter.getValue() ); + } + if (filterMap.size() > 0) + { + object.put("filters", filterMap); + } + } + return resource.entity(object, MediaType.APPLICATION_JSON_TYPE) + .post(ItemsResponse.class); + } + + /** + * Utility method to get items matching an external id + * + * @param appId + * The id of the app + * @param externalId + * The external id + * @return The items matching the app and external id + */ + public ItemsResponse getItemsByExternalId(int appId, String externalId) { + return getItems(appId, null, null, null, null, + new FilterByValue(new ExternalIdFilterBy(), externalId)); + } + + /** + * Returns the items on app for a given view + * + * @param appId + * The id of the app + * @param viewId + * The id of the view + * @param limit + * The maximum number of items to receive, defaults to 20 + * @param offset + * The offset from the start of the items returned, defaults to 0 + * @param sortBy + * How the items should be sorted. For the possible options, see + * the filter area. + * @param sortDesc + * true or leave out to sort descending, use + * false to sort ascending + * @param filters + * The filters to apply + * @return The items matching the filters + */ + public ItemsResponse getItemsByView(int appId, int viewId, Integer limit, Integer offset, + SortBy sortBy, Boolean sortDesc, FilterByValue... filters) { + WebResource resource = getResourceFactory().getApiResource( + "/item/app/" + appId + "/filter/" + viewId + "/"); + Map object = new HashMap(); + if (limit != null) { + object.put("limit", limit); + } + if (offset != null) { + object.put("offest", offset); + } + if (sortBy != null) { + object.put("sort_by", sortBy); + } + if (sortDesc != null) { + object.put("sort_desc", sortDesc); + } + Map filterMap = new HashMap(); + for (FilterByValue filter : filters) { + filterMap.put(filter.getBy().getKey(), filter.getFormattedValue()); + } + object.put("filters", filterMap); + + return resource.entity(object, MediaType.APPLICATION_JSON_TYPE) + .post(ItemsResponse.class); + } + + /** + * Returns the items on app for a given view + * + * @param appId + * The id of the app + * @return the item count + */ + public ItemCount getItemCount(int appId ) + { + WebResource resource = getResourceFactory().getApiResource( + "/item/app/" + appId + "/count"); + return resource.get( ItemCount.class ); + } + + /** + * Returns the items on app for a given view + * + * @param appId + * The id of the app + * @param viewId + * The id of the view + * @return the item count + */ + public ItemCount getItemCount(int appId, Integer viewId) { + WebResource resource = getResourceFactory().getApiResource( + "/item/app/" + appId + "/count"); + if (viewId != null) { + resource = resource.queryParam("view_id", viewId.toString()); + } + return resource.get( ItemCount.class ); + } + +} diff --git a/src/main/java/com/podio/item/ItemActivityType.java b/src/main/java/com/podio/item/ItemActivityType.java index f637ce6..f1622b2 100644 --- a/src/main/java/com/podio/item/ItemActivityType.java +++ b/src/main/java/com/podio/item/ItemActivityType.java @@ -1,28 +1,28 @@ -package com.podio.item; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -/** - * The type of activity - */ -public enum ItemActivityType { - - CREATION, - UPDATE, - DELETE, - COMMENT, - FILE, - RATING; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static ItemActivityType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.item; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +/** + * The type of activity + */ +public enum ItemActivityType { + + CREATION, + UPDATE, + DELETE, + COMMENT, + FILE, + RATING; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static ItemActivityType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/item/ItemBadge.java b/src/main/java/com/podio/item/ItemBadge.java index 4943d46..5f48b15 100644 --- a/src/main/java/com/podio/item/ItemBadge.java +++ b/src/main/java/com/podio/item/ItemBadge.java @@ -1,169 +1,169 @@ -package com.podio.item; - -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonDeserialize; - -import com.podio.rating.RatingType; -import com.podio.rating.RatingTypeKeyDeserializer; -import com.podio.rating.TypeRating; -import org.joda.time.DateTime; - -public class ItemBadge { - - /** - * The id of the item - */ - private int id; - - /** - * The information on who created the first revision of the item - */ - private ItemRevision initialRevision; - - /** - * The latest revision - */ - private ItemRevision currentRevision; - - /** - * The external id of the item, if any - */ - private String externalId; - - /** - * The title of the item. This is made of up one of the fields below, or by - * the item name and id - */ - private String title; - - /** - * The direct link to the item - */ - private String link; - - /** - * The values for each field - */ - private List fields; - - /** - * Number of comments on the item - */ - private int comments; - - /** - * The ratings on the item - */ - private Map ratings; - - /** - * The number of files on the item - */ - private int files; - - /** - * The date and time the item was created - */ - private DateTime createdOn; - - @JsonProperty("item_id") - public int getId() { - return id; - } - - @JsonProperty("item_id") - public void setId(int id) { - this.id = id; - } - - @JsonProperty("initial_revision") - public ItemRevision getInitialRevision() { - return initialRevision; - } - - @JsonProperty("initial_revision") - public void setInitialRevision(ItemRevision initialRevision) { - this.initialRevision = initialRevision; - } - - @JsonProperty("current_revision") - public ItemRevision getCurrentRevision() { - return currentRevision; - } - - @JsonProperty("current_revision") - public void setCurrentRevision(ItemRevision currentRevision) { - this.currentRevision = currentRevision; - } - - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - public Map getRatings() { - return ratings; - } - - @JsonDeserialize(keyUsing = RatingTypeKeyDeserializer.class) - public void setRatings(Map ratings) { - this.ratings = ratings; - } - - public int getComments() { - return comments; - } - - public void setComments(int comments) { - this.comments = comments; - } - - public int getFiles() { - return files; - } - - public void setFiles(int files) { - this.files = files; - } - - @JsonProperty("created_on") - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } -} +package com.podio.item; + +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonDeserialize; + +import com.podio.rating.RatingType; +import com.podio.rating.RatingTypeKeyDeserializer; +import com.podio.rating.TypeRating; +import org.joda.time.DateTime; + +public class ItemBadge { + + /** + * The id of the item + */ + private int id; + + /** + * The information on who created the first revision of the item + */ + private ItemRevision initialRevision; + + /** + * The latest revision + */ + private ItemRevision currentRevision; + + /** + * The external id of the item, if any + */ + private String externalId; + + /** + * The title of the item. This is made of up one of the fields below, or by + * the item name and id + */ + private String title; + + /** + * The direct link to the item + */ + private String link; + + /** + * The values for each field + */ + private List fields; + + /** + * Number of comments on the item + */ + private int comments; + + /** + * The ratings on the item + */ + private Map ratings; + + /** + * The number of files on the item + */ + private int files; + + /** + * The date and time the item was created + */ + private DateTime createdOn; + + @JsonProperty("item_id") + public int getId() { + return id; + } + + @JsonProperty("item_id") + public void setId(int id) { + this.id = id; + } + + @JsonProperty("initial_revision") + public ItemRevision getInitialRevision() { + return initialRevision; + } + + @JsonProperty("initial_revision") + public void setInitialRevision(ItemRevision initialRevision) { + this.initialRevision = initialRevision; + } + + @JsonProperty("current_revision") + public ItemRevision getCurrentRevision() { + return currentRevision; + } + + @JsonProperty("current_revision") + public void setCurrentRevision(ItemRevision currentRevision) { + this.currentRevision = currentRevision; + } + + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public Map getRatings() { + return ratings; + } + + @JsonDeserialize(keyUsing = RatingTypeKeyDeserializer.class) + public void setRatings(Map ratings) { + this.ratings = ratings; + } + + public int getComments() { + return comments; + } + + public void setComments(int comments) { + this.comments = comments; + } + + public int getFiles() { + return files; + } + + public void setFiles(int files) { + this.files = files; + } + + @JsonProperty("created_on") + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } +} diff --git a/src/main/java/com/podio/item/ItemCount.java b/src/main/java/com/podio/item/ItemCount.java new file mode 100644 index 0000000..35db520 --- /dev/null +++ b/src/main/java/com/podio/item/ItemCount.java @@ -0,0 +1,30 @@ +package com.podio.item; + +public class ItemCount +{ + private int count; + + /** + * @return the count + */ + public int getCount() + { + return count; + } + + /** + * @param count the count to set + */ + public void setCount( int count ) + { + this.count = count; + } + + @Override + public String toString() + { + if ( count == 1 ) + return count + " item"; + return count + " items"; + } +} diff --git a/src/main/java/com/podio/item/ItemCreate.java b/src/main/java/com/podio/item/ItemCreate.java index 809ffa8..4395553 100644 --- a/src/main/java/com/podio/item/ItemCreate.java +++ b/src/main/java/com/podio/item/ItemCreate.java @@ -1,49 +1,49 @@ -package com.podio.item; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ItemCreate extends ItemUpdate { - - /** - * Temporary files that have been uploaded and should be attached to this - * item - */ - private List fileIds; - - /** - * The tags to put on the item - */ - private List tags; - - public ItemCreate() { - super(); - } - - public ItemCreate(String externalId, List fields, - List fileIds, List tags) { - super(externalId, fields); - this.fileIds = fileIds; - this.tags = tags; - } - - @JsonProperty("file_ids") - public List getFileIds() { - return fileIds; - } - - @JsonProperty("file_ids") - public void setFileIds(List fileIds) { - this.fileIds = fileIds; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - -} +package com.podio.item; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ItemCreate extends ItemUpdate { + + /** + * Temporary files that have been uploaded and should be attached to this + * item + */ + private List fileIds; + + /** + * The tags to put on the item + */ + private List tags; + + public ItemCreate() { + super(); + } + + public ItemCreate(String externalId, List fields, + List fileIds, List tags) { + super(externalId, fields); + this.fileIds = fileIds; + this.tags = tags; + } + + @JsonProperty("file_ids") + public List getFileIds() { + return fileIds; + } + + @JsonProperty("file_ids") + public void setFileIds(List fileIds) { + this.fileIds = fileIds; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + +} diff --git a/src/main/java/com/podio/item/ItemCreateResponse.java b/src/main/java/com/podio/item/ItemCreateResponse.java index cedcf0d..82e8f6a 100644 --- a/src/main/java/com/podio/item/ItemCreateResponse.java +++ b/src/main/java/com/podio/item/ItemCreateResponse.java @@ -1,17 +1,17 @@ -package com.podio.item; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ItemCreateResponse { - - private int id; - - public int getId() { - return id; - } - - @JsonProperty("item_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.item; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ItemCreateResponse { + + private int id; + + public int getId() { + return id; + } + + @JsonProperty("item_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/item/ItemFieldDifference.java b/src/main/java/com/podio/item/ItemFieldDifference.java index bcd7b24..d7287b4 100644 --- a/src/main/java/com/podio/item/ItemFieldDifference.java +++ b/src/main/java/com/podio/item/ItemFieldDifference.java @@ -1,77 +1,77 @@ -package com.podio.item; - -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.app.ApplicationFieldType; - -public class ItemFieldDifference { - - /** - * The id of the field - */ - private int id; - - /** - * The type of the field - */ - private ApplicationFieldType type; - - /** - * The label of the field - */ - private String label; - - /** - * The values at the from revision - */ - private List> from; - - /** - * The values at the to revsion - */ - private List> to; - - public int getId() { - return id; - } - - @JsonProperty("field_id") - public void setId(int fieldId) { - this.id = fieldId; - } - - public ApplicationFieldType getType() { - return type; - } - - public void setType(ApplicationFieldType type) { - this.type = type; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public List> getFrom() { - return from; - } - - public void setFrom(List> from) { - this.from = from; - } - - public List> getTo() { - return to; - } - - public void setTo(List> to) { - this.to = to; - } -} +package com.podio.item; + +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.app.ApplicationFieldType; + +public class ItemFieldDifference { + + /** + * The id of the field + */ + private int id; + + /** + * The type of the field + */ + private ApplicationFieldType type; + + /** + * The label of the field + */ + private String label; + + /** + * The values at the from revision + */ + private List> from; + + /** + * The values at the to revsion + */ + private List> to; + + public int getId() { + return id; + } + + @JsonProperty("field_id") + public void setId(int fieldId) { + this.id = fieldId; + } + + public ApplicationFieldType getType() { + return type; + } + + public void setType(ApplicationFieldType type) { + this.type = type; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List> getFrom() { + return from; + } + + public void setFrom(List> from) { + this.from = from; + } + + public List> getTo() { + return to; + } + + public void setTo(List> to) { + this.to = to; + } +} diff --git a/src/main/java/com/podio/item/ItemMicro.java b/src/main/java/com/podio/item/ItemMicro.java index 3cb1d20..cef38d7 100644 --- a/src/main/java/com/podio/item/ItemMicro.java +++ b/src/main/java/com/podio/item/ItemMicro.java @@ -1,36 +1,36 @@ -package com.podio.item; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ItemMicro { - - /** - * The id of the item - */ - private int id; - - /** - * The title of the item. This is made of up one of the fields below, or by - * the item name and id - */ - private String title; - - @JsonProperty("item_id") - public int getId() { - return id; - } - - @JsonProperty("item_id") - public void setId(int id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - -} +package com.podio.item; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ItemMicro { + + /** + * The id of the item + */ + private int id; + + /** + * The title of the item. This is made of up one of the fields below, or by + * the item name and id + */ + private String title; + + @JsonProperty("item_id") + public int getId() { + return id; + } + + @JsonProperty("item_id") + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + +} diff --git a/src/main/java/com/podio/item/ItemMini.java b/src/main/java/com/podio/item/ItemMini.java index d02d886..d9dc94c 100644 --- a/src/main/java/com/podio/item/ItemMini.java +++ b/src/main/java/com/podio/item/ItemMini.java @@ -1,67 +1,67 @@ -package com.podio.item; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.app.Application; - -public class ItemMini { - - /** - * The id of the item - */ - private int id; - - /** - * The title of the item. This is made of up one of the fields below, or by - * the item name and id - */ - private String title; - - /** - * The information on who created the first revision of the item - */ - private ItemRevision initialRevision; - - /** - * The app where the item belongs - */ - private Application application; - - @JsonProperty("item_id") - public int getId() { - return id; - } - - @JsonProperty("item_id") - public void setId(int id) { - this.id = id; - } - - @JsonProperty("app") - public Application getApplication() { - return application; - } - - @JsonProperty("app") - public void setApplication(Application application) { - this.application = application; - } - - @JsonProperty("initial_revision") - public ItemRevision getInitialRevision() { - return initialRevision; - } - - @JsonProperty("initial_revision") - public void setInitialRevision(ItemRevision initialRevision) { - this.initialRevision = initialRevision; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } -} +package com.podio.item; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.app.Application; + +public class ItemMini { + + /** + * The id of the item + */ + private int id; + + /** + * The title of the item. This is made of up one of the fields below, or by + * the item name and id + */ + private String title; + + /** + * The information on who created the first revision of the item + */ + private ItemRevision initialRevision; + + /** + * The app where the item belongs + */ + private Application application; + + @JsonProperty("item_id") + public int getId() { + return id; + } + + @JsonProperty("item_id") + public void setId(int id) { + this.id = id; + } + + @JsonProperty("app") + public Application getApplication() { + return application; + } + + @JsonProperty("app") + public void setApplication(Application application) { + this.application = application; + } + + @JsonProperty("initial_revision") + public ItemRevision getInitialRevision() { + return initialRevision; + } + + @JsonProperty("initial_revision") + public void setInitialRevision(ItemRevision initialRevision) { + this.initialRevision = initialRevision; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/src/main/java/com/podio/item/ItemReference.java b/src/main/java/com/podio/item/ItemReference.java index b495d6f..5f8c073 100644 --- a/src/main/java/com/podio/item/ItemReference.java +++ b/src/main/java/com/podio/item/ItemReference.java @@ -1,33 +1,33 @@ -package com.podio.item; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.app.Application; - -public class ItemReference { - - private Application application; - - private List items; - - @JsonProperty("app") - public Application getApplication() { - return application; - } - - @JsonProperty("app") - public void setApplication(Application application) { - this.application = application; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - -} +package com.podio.item; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.app.Application; + +public class ItemReference { + + private Application application; + + private List items; + + @JsonProperty("app") + public Application getApplication() { + return application; + } + + @JsonProperty("app") + public void setApplication(Application application) { + this.application = application; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + +} diff --git a/src/main/java/com/podio/item/ItemRevision.java b/src/main/java/com/podio/item/ItemRevision.java index a23d9bf..70933b8 100644 --- a/src/main/java/com/podio/item/ItemRevision.java +++ b/src/main/java/com/podio/item/ItemRevision.java @@ -1,38 +1,38 @@ -package com.podio.item; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.common.CreatedBase; - -public class ItemRevision extends CreatedBase { - - private static final long serialVersionUID = 1L; - - /** - * The revision number - */ - private int revision; - - /** - * The revision of the app at the time this item revision was made - */ - private int appRevision; - - public int getRevision() { - return revision; - } - - public void setRevision(int revision) { - this.revision = revision; - } - - @JsonProperty("app_revision") - public int getAppRevision() { - return appRevision; - } - - @JsonProperty("app_revision") - public void setAppRevision(int appRevision) { - this.appRevision = appRevision; - } -} +package com.podio.item; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.CreatedBase; + +public class ItemRevision extends CreatedBase { + + private static final long serialVersionUID = 1L; + + /** + * The revision number + */ + private int revision; + + /** + * The revision of the app at the time this item revision was made + */ + private int appRevision; + + public int getRevision() { + return revision; + } + + public void setRevision(int revision) { + this.revision = revision; + } + + @JsonProperty("app_revision") + public int getAppRevision() { + return appRevision; + } + + @JsonProperty("app_revision") + public void setAppRevision(int appRevision) { + this.appRevision = appRevision; + } +} diff --git a/src/main/java/com/podio/item/ItemUpdate.java b/src/main/java/com/podio/item/ItemUpdate.java index 4f60c17..343481c 100644 --- a/src/main/java/com/podio/item/ItemUpdate.java +++ b/src/main/java/com/podio/item/ItemUpdate.java @@ -1,70 +1,70 @@ -package com.podio.item; - -import java.util.ArrayList; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class ItemUpdate { - - /** - * The external id of the item. This can be used to hold a reference to the - * item in an external system. - */ - private String externalId; - - /** - * The internal revision from podio. - */ - private int revision; - - /** - * The values for each field - */ - private List fields; - - public ItemUpdate() { - super(); - } - - public ItemUpdate(String externalId, List fields) { - super(); - this.externalId = externalId; - this.fields = fields; - } - - @JsonProperty("external_id") - public String getExternalId() { - return externalId; - } - - @JsonProperty("external_id") - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - @JsonProperty("revision") - public int getRevision() { - return revision; - } - - @JsonProperty("revision") - public void setRevision(int revision) { - this.revision = revision; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - public void addField(FieldValuesUpdate field) { - if (this.fields == null) { - this.fields = new ArrayList(); - } - this.fields.add(field); - } -} +package com.podio.item; + +import java.util.ArrayList; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ItemUpdate { + + /** + * The external id of the item. This can be used to hold a reference to the + * item in an external system. + */ + private String externalId; + + /** + * The internal revision from podio. + */ + private int revision; + + /** + * The values for each field + */ + private List fields; + + public ItemUpdate() { + super(); + } + + public ItemUpdate(String externalId, List fields) { + super(); + this.externalId = externalId; + this.fields = fields; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @JsonProperty("external_id") + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + @JsonProperty("revision") + public int getRevision() { + return revision; + } + + @JsonProperty("revision") + public void setRevision(int revision) { + this.revision = revision; + } + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public void addField(FieldValuesUpdate field) { + if (this.fields == null) { + this.fields = new ArrayList(); + } + this.fields.add(field); + } +} diff --git a/src/main/java/com/podio/item/ItemsResponse.java b/src/main/java/com/podio/item/ItemsResponse.java index ac15029..723cec4 100644 --- a/src/main/java/com/podio/item/ItemsResponse.java +++ b/src/main/java/com/podio/item/ItemsResponse.java @@ -1,51 +1,51 @@ -package com.podio.item; - -import java.util.List; - -public class ItemsResponse { - - /** - * Total number of items - */ - private int total; - - /** - * Total number of items matching the filter - */ - private int filtered; - - /** - * The items returned - */ - private List items; - - @Override - public String toString() { - return "ItemsResponse [total=" + total + ", filtered=" + filtered - + ", items=" + items + "]"; - } - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public int getFiltered() { - return filtered; - } - - public void setFiltered(int filtered) { - this.filtered = filtered; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } -} +package com.podio.item; + +import java.util.List; + +public class ItemsResponse { + + /** + * Total number of items + */ + private int total; + + /** + * Total number of items matching the filter + */ + private int filtered; + + /** + * The items returned + */ + private List items; + + @Override + public String toString() { + return "ItemsResponse [total=" + total + ", filtered=" + filtered + + ", items=" + items + "]"; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public int getFiltered() { + return filtered; + } + + public void setFiltered(int filtered) { + this.filtered = filtered; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } +} diff --git a/src/main/java/com/podio/item/filter/Filter.java b/src/main/java/com/podio/item/filter/Filter.java index f0d80d9..f11d1bb 100644 --- a/src/main/java/com/podio/item/filter/Filter.java +++ b/src/main/java/com/podio/item/filter/Filter.java @@ -1,5 +1,5 @@ -package com.podio.item.filter; - -public class Filter { - -} +package com.podio.item.filter; + +public class Filter { + +} diff --git a/src/main/java/com/podio/item/map/ExternalId.java b/src/main/java/com/podio/item/map/ExternalId.java index ec5d218..23aa0d4 100644 --- a/src/main/java/com/podio/item/map/ExternalId.java +++ b/src/main/java/com/podio/item/map/ExternalId.java @@ -1,12 +1,12 @@ -package com.podio.item.map; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ExternalId { - -} +package com.podio.item.map; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface ExternalId { + +} diff --git a/src/main/java/com/podio/item/map/Field.java b/src/main/java/com/podio/item/map/Field.java index 8537e8c..f84abb2 100644 --- a/src/main/java/com/podio/item/map/Field.java +++ b/src/main/java/com/podio/item/map/Field.java @@ -1,13 +1,13 @@ -package com.podio.item.map; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Field { - - String value() default ""; -} +package com.podio.item.map; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Field { + + String value() default ""; +} diff --git a/src/main/java/com/podio/item/map/FieldMap.java b/src/main/java/com/podio/item/map/FieldMap.java index dbccd8c..dbfe558 100644 --- a/src/main/java/com/podio/item/map/FieldMap.java +++ b/src/main/java/com/podio/item/map/FieldMap.java @@ -1,137 +1,137 @@ -package com.podio.item.map; - -import java.beans.PropertyDescriptor; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.podio.app.ApplicationField; -import com.podio.item.FieldValuesUpdate; -import com.podio.item.FieldValuesView; -import com.podio.item.map.converter.FieldConverter; -import com.podio.item.map.converter.FieldConverterRegistry; - -public class FieldMap { - - private final String externalId; - - private final PropertyDescriptor property; - - private final boolean single; - - private final FieldConverter converter; - - private FieldMap(String externalId, PropertyDescriptor property, - boolean single, FieldConverter converter) { - super(); - - this.externalId = externalId; - this.property = property; - this.single = single; - this.converter = converter; - } - - public FieldValuesUpdate fromModel(Object model) { - Object value; - try { - value = property.getReadMethod().invoke(model); - } catch (Exception e) { - throw new RuntimeException("Unable to get model value", e); - } - - List> apiValues = new ArrayList>(); - - if (value != null) { - if (!single) { - Collection subValues = (Collection) value; - for (Object subValue : subValues) { - apiValues.add(converter.fromModel(subValue)); - } - } else { - apiValues.add(converter.fromModel(value)); - } - } - - return new FieldValuesUpdate(externalId, apiValues); - } - - public void toModel(Object model, List views) { - for (FieldValuesView view : views) { - if (view.getExternalId().equals(externalId)) { - if (view.getValues().size() > 0) { - try { - if (single) { - if (view.getValues().size() > 1) { - throw new RuntimeException( - "Expected at most one value"); - } - - Object value = converter.toModel(view.getValues() - .get(0), property.getPropertyType()); - property.getWriteMethod().invoke(model, value); - } else { - ParameterizedType innerType = (ParameterizedType) property - .getReadMethod().getGenericReturnType(); - - Collection col = getCollectionInstance(); - - for (Map values : view.getValues()) { - Object value = converter.toModel(values, - (Class) innerType - .getActualTypeArguments()[0]); - col.add(value); - } - - property.getWriteMethod().invoke(model, col); - } - } catch (Exception e) { - throw new RuntimeException("Unable to set model value", - e); - } - } - } - } - } - - private Collection getCollectionInstance() - throws InstantiationException, IllegalAccessException { - if (property.getPropertyType() == Collection.class - || property.getPropertyType() == List.class) { - return new ArrayList(); - } else if (property.getPropertyType() == Set.class) { - return new HashSet(); - } else { - return (Collection) property.getPropertyType() - .newInstance(); - } - } - - public static FieldMap get(PropertyDescriptor property, - Map fieldMap) { - Field field = property.getReadMethod().getAnnotation(Field.class); - String externalId; - if (field == null || field.value() == "") { - externalId = NameUtil.toAPI(property.getName()); - } else { - externalId = field.value(); - } - - ApplicationField applicationField = fieldMap.get(externalId); - if (applicationField == null) { - throw new RuntimeException("No field found with external id " - + externalId); - } - - boolean single = !Collection.class.isAssignableFrom(property - .getPropertyType()); - - FieldConverter converter = FieldConverterRegistry.getConverter( - applicationField, property.getReadMethod()); - - return new FieldMap(externalId, property, single, converter); - } -} +package com.podio.item.map; + +import java.beans.PropertyDescriptor; +import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.podio.app.ApplicationField; +import com.podio.item.FieldValuesUpdate; +import com.podio.item.FieldValuesView; +import com.podio.item.map.converter.FieldConverter; +import com.podio.item.map.converter.FieldConverterRegistry; + +public class FieldMap { + + private final String externalId; + + private final PropertyDescriptor property; + + private final boolean single; + + private final FieldConverter converter; + + private FieldMap(String externalId, PropertyDescriptor property, + boolean single, FieldConverter converter) { + super(); + + this.externalId = externalId; + this.property = property; + this.single = single; + this.converter = converter; + } + + public FieldValuesUpdate fromModel(Object model) { + Object value; + try { + value = property.getReadMethod().invoke(model); + } catch (Exception e) { + throw new RuntimeException("Unable to get model value", e); + } + + List> apiValues = new ArrayList>(); + + if (value != null) { + if (!single) { + Collection subValues = (Collection) value; + for (Object subValue : subValues) { + apiValues.add(converter.fromModel(subValue)); + } + } else { + apiValues.add(converter.fromModel(value)); + } + } + + return new FieldValuesUpdate(externalId, apiValues); + } + + public void toModel(Object model, List views) { + for (FieldValuesView view : views) { + if (view.getExternalId().equals(externalId)) { + if (view.getValues().size() > 0) { + try { + if (single) { + if (view.getValues().size() > 1) { + throw new RuntimeException( + "Expected at most one value"); + } + + Object value = converter.toModel(view.getValues() + .get(0), property.getPropertyType()); + property.getWriteMethod().invoke(model, value); + } else { + ParameterizedType innerType = (ParameterizedType) property + .getReadMethod().getGenericReturnType(); + + Collection col = getCollectionInstance(); + + for (Map values : view.getValues()) { + Object value = converter.toModel(values, + (Class) innerType + .getActualTypeArguments()[0]); + col.add(value); + } + + property.getWriteMethod().invoke(model, col); + } + } catch (Exception e) { + throw new RuntimeException("Unable to set model value", + e); + } + } + } + } + } + + private Collection getCollectionInstance() + throws InstantiationException, IllegalAccessException { + if (property.getPropertyType() == Collection.class + || property.getPropertyType() == List.class) { + return new ArrayList(); + } else if (property.getPropertyType() == Set.class) { + return new HashSet(); + } else { + return (Collection) property.getPropertyType() + .newInstance(); + } + } + + public static FieldMap get(PropertyDescriptor property, + Map fieldMap) { + Field field = property.getReadMethod().getAnnotation(Field.class); + String externalId; + if (field == null || field.value() == "") { + externalId = NameUtil.toAPI(property.getName()); + } else { + externalId = field.value(); + } + + ApplicationField applicationField = fieldMap.get(externalId); + if (applicationField == null) { + throw new RuntimeException("No field found with external id " + + externalId); + } + + boolean single = !Collection.class.isAssignableFrom(property + .getPropertyType()); + + FieldConverter converter = FieldConverterRegistry.getConverter( + applicationField, property.getReadMethod()); + + return new FieldMap(externalId, property, single, converter); + } +} diff --git a/src/main/java/com/podio/item/map/ItemMap.java b/src/main/java/com/podio/item/map/ItemMap.java index 4145c4e..75e1381 100644 --- a/src/main/java/com/podio/item/map/ItemMap.java +++ b/src/main/java/com/podio/item/map/ItemMap.java @@ -1,136 +1,136 @@ -package com.podio.item.map; - -import java.beans.PropertyDescriptor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.beanutils.PropertyUtils; - -import com.podio.app.Application; -import com.podio.app.ApplicationField; -import com.podio.item.FieldValuesUpdate; -import com.podio.item.FieldValuesView; -import com.podio.item.Item; -import com.podio.item.ItemBadge; -import com.podio.item.ItemCreate; -import com.podio.item.ItemUpdate; -import com.podio.item.map.converter.ExternalIdConverter; - -public class ItemMap { - - private final Class modelClass; - - private final List fieldMaps; - - private final ExternalIdConverter externalIdConverter; - - public ItemMap(Class modelClass, List fieldMaps, - ExternalIdConverter externalIdConverter) { - super(); - this.modelClass = modelClass; - this.fieldMaps = fieldMaps; - this.externalIdConverter = externalIdConverter; - } - - public ItemCreate getCreate(T model) { - return new ItemCreate(getExternalId(model), getUpdates(model), - Collections. emptyList(), - Collections. emptyList()); - } - - private String getExternalId(T model) { - String externalId = null; - if (externalIdConverter != null) { - externalId = externalIdConverter.fromModel(model); - } - return externalId; - } - - private void setExternalId(String externalId, T model) { - if (externalIdConverter != null) { - externalIdConverter.toModel(externalId, model); - } - } - - private List getUpdates(T model) { - List updates = new ArrayList(); - for (FieldMap fieldMap : fieldMaps) { - FieldValuesUpdate update = fieldMap.fromModel(model); - - updates.add(update); - } - - return updates; - } - - public ItemUpdate getUpdate(T model) { - return new ItemUpdate(getExternalId(model), getUpdates(model)); - } - - public T getView(Item item) { - return getView(item.getExternalId(), item.getFields()); - } - - public T getView(ItemBadge item) { - return getView(item.getExternalId(), item.getFields()); - } - - private T getView(String externalId, List views) { - T model; - try { - model = modelClass.newInstance(); - } catch (Exception e) { - throw new RuntimeException("Unable to create new " - + modelClass.getName() - + ", ensure that a non-arguments public constructor exists"); - } - - setExternalId(externalId, model); - - for (FieldMap fieldMap : fieldMaps) { - fieldMap.toModel(model, views); - } - - return model; - } - - public static ItemMap get(Application application, - Class modelClass) { - Map fields = new HashMap(); - for (ApplicationField field : application.getFields()) { - fields.put(field.getExternalId(), field); - } - - List fieldMaps = new ArrayList(); - ExternalIdConverter externalIdConverter = null; - - PropertyDescriptor[] descriptors = PropertyUtils - .getPropertyDescriptors(modelClass); - for (PropertyDescriptor descriptor : descriptors) { - if (descriptor.getReadMethod() == null - || descriptor.getWriteMethod() == null) { - continue; - } - - Transient tr = descriptor.getReadMethod().getAnnotation( - Transient.class); - if (tr != null) { - continue; - } - - ExternalId externalId = descriptor.getReadMethod().getAnnotation( - ExternalId.class); - if (externalId != null) { - externalIdConverter = new ExternalIdConverter(descriptor); - continue; - } - - fieldMaps.add(FieldMap.get(descriptor, fields)); - } - - return new ItemMap(modelClass, fieldMaps, externalIdConverter); - } -} +package com.podio.item.map; + +import java.beans.PropertyDescriptor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.beanutils.PropertyUtils; + +import com.podio.app.Application; +import com.podio.app.ApplicationField; +import com.podio.item.FieldValuesUpdate; +import com.podio.item.FieldValuesView; +import com.podio.item.Item; +import com.podio.item.ItemBadge; +import com.podio.item.ItemCreate; +import com.podio.item.ItemUpdate; +import com.podio.item.map.converter.ExternalIdConverter; + +public class ItemMap { + + private final Class modelClass; + + private final List fieldMaps; + + private final ExternalIdConverter externalIdConverter; + + public ItemMap(Class modelClass, List fieldMaps, + ExternalIdConverter externalIdConverter) { + super(); + this.modelClass = modelClass; + this.fieldMaps = fieldMaps; + this.externalIdConverter = externalIdConverter; + } + + public ItemCreate getCreate(T model) { + return new ItemCreate(getExternalId(model), getUpdates(model), + Collections. emptyList(), + Collections. emptyList()); + } + + private String getExternalId(T model) { + String externalId = null; + if (externalIdConverter != null) { + externalId = externalIdConverter.fromModel(model); + } + return externalId; + } + + private void setExternalId(String externalId, T model) { + if (externalIdConverter != null) { + externalIdConverter.toModel(externalId, model); + } + } + + private List getUpdates(T model) { + List updates = new ArrayList(); + for (FieldMap fieldMap : fieldMaps) { + FieldValuesUpdate update = fieldMap.fromModel(model); + + updates.add(update); + } + + return updates; + } + + public ItemUpdate getUpdate(T model) { + return new ItemUpdate(getExternalId(model), getUpdates(model)); + } + + public T getView(Item item) { + return getView(item.getExternalId(), item.getFields()); + } + + public T getView(ItemBadge item) { + return getView(item.getExternalId(), item.getFields()); + } + + private T getView(String externalId, List views) { + T model; + try { + model = modelClass.newInstance(); + } catch (Exception e) { + throw new RuntimeException("Unable to create new " + + modelClass.getName() + + ", ensure that a non-arguments public constructor exists"); + } + + setExternalId(externalId, model); + + for (FieldMap fieldMap : fieldMaps) { + fieldMap.toModel(model, views); + } + + return model; + } + + public static ItemMap get(Application application, + Class modelClass) { + Map fields = new HashMap(); + for (ApplicationField field : application.getFields()) { + fields.put(field.getExternalId(), field); + } + + List fieldMaps = new ArrayList(); + ExternalIdConverter externalIdConverter = null; + + PropertyDescriptor[] descriptors = PropertyUtils + .getPropertyDescriptors(modelClass); + for (PropertyDescriptor descriptor : descriptors) { + if (descriptor.getReadMethod() == null + || descriptor.getWriteMethod() == null) { + continue; + } + + Transient tr = descriptor.getReadMethod().getAnnotation( + Transient.class); + if (tr != null) { + continue; + } + + ExternalId externalId = descriptor.getReadMethod().getAnnotation( + ExternalId.class); + if (externalId != null) { + externalIdConverter = new ExternalIdConverter(descriptor); + continue; + } + + fieldMaps.add(FieldMap.get(descriptor, fields)); + } + + return new ItemMap(modelClass, fieldMaps, externalIdConverter); + } +} diff --git a/src/main/java/com/podio/item/map/MappedItemAPI.java b/src/main/java/com/podio/item/map/MappedItemAPI.java index 231615f..9250441 100644 --- a/src/main/java/com/podio/item/map/MappedItemAPI.java +++ b/src/main/java/com/podio/item/map/MappedItemAPI.java @@ -1,51 +1,51 @@ -package com.podio.item.map; - -import org.apache.commons.beanutils.ConvertUtils; - -import com.podio.APIFactory; -import com.podio.app.AppAPI; -import com.podio.app.Application; -import com.podio.item.ItemAPI; -import com.podio.item.ItemsResponse; - -public class MappedItemAPI { - - private final APIFactory factory; - - private final Application application; - - private final ItemMap map; - - public MappedItemAPI(APIFactory factory, int appId, Class cls) { - super(); - this.factory = factory; - this.application = factory.getAPI(AppAPI.class).getApp(appId); - this.map = ItemMap.get(application, cls); - } - - public int insert(T object, boolean silent) { - return factory.getAPI(ItemAPI.class).addItem(application.getId(), - map.getCreate(object), silent); - } - - public void update(T object, boolean silent) { - factory.getAPI(ItemAPI.class).updateItem(-1, map.getUpdate(object), - silent, false); - } - - public T get(Object externalId) { - String stringExternalId = (String) ConvertUtils.convert(externalId, - String.class); - - ItemsResponse item = factory.getAPI(ItemAPI.class) - .getItemsByExternalId(application.getId(), stringExternalId); - if (item.getFiltered() == 1) { - return map.getView(item.getItems().get(0)); - } else if (item.getFiltered() == 0) { - return null; - } else { - throw new RuntimeException( - "Multiple items found with the external id " + externalId); - } - } -} +package com.podio.item.map; + +import org.apache.commons.beanutils.ConvertUtils; + +import com.podio.APIFactory; +import com.podio.app.AppAPI; +import com.podio.app.Application; +import com.podio.item.ItemAPI; +import com.podio.item.ItemsResponse; + +public class MappedItemAPI { + + private final APIFactory factory; + + private final Application application; + + private final ItemMap map; + + public MappedItemAPI(APIFactory factory, int appId, Class cls) { + super(); + this.factory = factory; + this.application = factory.getAPI(AppAPI.class).getApp(appId); + this.map = ItemMap.get(application, cls); + } + + public int insert(T object, boolean silent) { + return factory.getAPI(ItemAPI.class).addItem(application.getId(), + map.getCreate(object), silent); + } + + public void update(T object, boolean silent) { + factory.getAPI(ItemAPI.class).updateItem(-1, map.getUpdate(object), + silent, false); + } + + public T get(Object externalId) { + String stringExternalId = (String) ConvertUtils.convert(externalId, + String.class); + + ItemsResponse item = factory.getAPI(ItemAPI.class) + .getItemsByExternalId(application.getId(), stringExternalId); + if (item.getFiltered() == 1) { + return map.getView(item.getItems().get(0)); + } else if (item.getFiltered() == 0) { + return null; + } else { + throw new RuntimeException( + "Multiple items found with the external id " + externalId); + } + } +} diff --git a/src/main/java/com/podio/item/map/MoneyField.java b/src/main/java/com/podio/item/map/MoneyField.java index 73855ce..d4e33d1 100644 --- a/src/main/java/com/podio/item/map/MoneyField.java +++ b/src/main/java/com/podio/item/map/MoneyField.java @@ -1,13 +1,13 @@ -package com.podio.item.map; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface MoneyField { - - String currency(); -} +package com.podio.item.map; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface MoneyField { + + String currency(); +} diff --git a/src/main/java/com/podio/item/map/NameUtil.java b/src/main/java/com/podio/item/map/NameUtil.java index 7324d80..ef75c7a 100644 --- a/src/main/java/com/podio/item/map/NameUtil.java +++ b/src/main/java/com/podio/item/map/NameUtil.java @@ -1,40 +1,40 @@ -package com.podio.item.map; - -public final class NameUtil { - - private NameUtil() { - } - - public static String toJava(String name) { - String out = ""; - boolean nextUpper = false; - for (int i = 0; i < name.length(); i++) { - char next = name.charAt(i); - if (next == '-') { - nextUpper = true; - } else { - if (nextUpper) { - next = Character.toUpperCase(next); - } - out += next; - nextUpper = false; - } - } - - return out; - } - - public static String toAPI(String name) { - String out = ""; - for (int i = 0; i < name.length(); i++) { - char next = name.charAt(i); - if (Character.isUpperCase(next)) { - out += '-'; - next = Character.toLowerCase(next); - } - out += next; - } - - return out; - } -} +package com.podio.item.map; + +public final class NameUtil { + + private NameUtil() { + } + + public static String toJava(String name) { + String out = ""; + boolean nextUpper = false; + for (int i = 0; i < name.length(); i++) { + char next = name.charAt(i); + if (next == '-') { + nextUpper = true; + } else { + if (nextUpper) { + next = Character.toUpperCase(next); + } + out += next; + nextUpper = false; + } + } + + return out; + } + + public static String toAPI(String name) { + String out = ""; + for (int i = 0; i < name.length(); i++) { + char next = name.charAt(i); + if (Character.isUpperCase(next)) { + out += '-'; + next = Character.toLowerCase(next); + } + out += next; + } + + return out; + } +} diff --git a/src/main/java/com/podio/item/map/Transient.java b/src/main/java/com/podio/item/map/Transient.java index bbaf34c..a1eedd7 100644 --- a/src/main/java/com/podio/item/map/Transient.java +++ b/src/main/java/com/podio/item/map/Transient.java @@ -1,12 +1,12 @@ -package com.podio.item.map; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Transient { - -} +package com.podio.item.map; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Transient { + +} diff --git a/src/main/java/com/podio/item/map/converter/CategoryConverter.java b/src/main/java/com/podio/item/map/converter/CategoryConverter.java index 5630d9f..1872b03 100644 --- a/src/main/java/com/podio/item/map/converter/CategoryConverter.java +++ b/src/main/java/com/podio/item/map/converter/CategoryConverter.java @@ -1,63 +1,63 @@ -package com.podio.item.map.converter; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.beanutils.ConvertUtils; - -import com.podio.app.CategoryOption; - -public class CategoryConverter implements FieldConverter { - - private final List options; - - public CategoryConverter(List options) { - super(); - this.options = options; - } - - @Override - public Map fromModel(Object value) { - String stringValue; - if (value.getClass().isEnum()) { - stringValue = value.toString(); - stringValue = stringValue.replace(' ', '_'); - } else { - stringValue = (String) ConvertUtils.convert(value, - String.class); - } - - CategoryOption option = getOptionByText(stringValue); - if (option != null) { - return Collections.singletonMap("value", option.getId()); - } - - throw new RuntimeException("No state with name " + stringValue - + " found"); - } - - private CategoryOption getOptionByText(String text) { - for (CategoryOption option : options) { - if (option.getText().equalsIgnoreCase(text)) { - return option; - } - } - - return null; - } - - @Override - public Object toModel(Map map, Class modelClass) { - Map option = (Map) map.get("value"); - - String stringValue = (String) option.get("text"); - - if (modelClass.isEnum()) { - return Enum.valueOf(modelClass, stringValue.toUpperCase()); - } else { - return ConvertUtils.convert(stringValue, modelClass); - } - } -} +package com.podio.item.map.converter; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.beanutils.ConvertUtils; + +import com.podio.app.CategoryOption; + +public class CategoryConverter implements FieldConverter { + + private final List options; + + public CategoryConverter(List options) { + super(); + this.options = options; + } + + @Override + public Map fromModel(Object value) { + String stringValue; + if (value.getClass().isEnum()) { + stringValue = value.toString(); + stringValue = stringValue.replace(' ', '_'); + } else { + stringValue = (String) ConvertUtils.convert(value, + String.class); + } + + CategoryOption option = getOptionByText(stringValue); + if (option != null) { + return Collections.singletonMap("value", option.getId()); + } + + throw new RuntimeException("No state with name " + stringValue + + " found"); + } + + private CategoryOption getOptionByText(String text) { + for (CategoryOption option : options) { + if (option.getText().equalsIgnoreCase(text)) { + return option; + } + } + + return null; + } + + @Override + public Object toModel(Map map, Class modelClass) { + Map option = (Map) map.get("value"); + + String stringValue = (String) option.get("text"); + + if (modelClass.isEnum()) { + return Enum.valueOf(modelClass, stringValue.toUpperCase()); + } else { + return ConvertUtils.convert(stringValue, modelClass); + } + } +} diff --git a/src/main/java/com/podio/item/map/converter/CategoryConverterProvider.java b/src/main/java/com/podio/item/map/converter/CategoryConverterProvider.java index 0160fbf..c72806c 100644 --- a/src/main/java/com/podio/item/map/converter/CategoryConverterProvider.java +++ b/src/main/java/com/podio/item/map/converter/CategoryConverterProvider.java @@ -1,20 +1,20 @@ -package com.podio.item.map.converter; - -import java.lang.reflect.AnnotatedElement; - -import com.podio.app.ApplicationField; -import com.podio.app.ApplicationFieldType; - -public class CategoryConverterProvider implements FieldConverterProvider { - - @Override - public boolean isSupported(ApplicationFieldType fieldType) { - return fieldType == ApplicationFieldType.CATEGORY; - } - - @Override - public FieldConverter getConverter(ApplicationField field, - AnnotatedElement element) { - return new CategoryConverter(field.getConfiguration().getSettings().getOptions()); - } -} +package com.podio.item.map.converter; + +import java.lang.reflect.AnnotatedElement; + +import com.podio.app.ApplicationField; +import com.podio.app.ApplicationFieldType; + +public class CategoryConverterProvider implements FieldConverterProvider { + + @Override + public boolean isSupported(ApplicationFieldType fieldType) { + return fieldType == ApplicationFieldType.CATEGORY; + } + + @Override + public FieldConverter getConverter(ApplicationField field, + AnnotatedElement element) { + return new CategoryConverter(field.getConfiguration().getSettings().getOptions()); + } +} diff --git a/src/main/java/com/podio/item/map/converter/ExternalIdConverter.java b/src/main/java/com/podio/item/map/converter/ExternalIdConverter.java index a8a176e..918a1e9 100644 --- a/src/main/java/com/podio/item/map/converter/ExternalIdConverter.java +++ b/src/main/java/com/podio/item/map/converter/ExternalIdConverter.java @@ -1,40 +1,40 @@ -package com.podio.item.map.converter; - -import java.beans.PropertyDescriptor; - -import org.apache.commons.beanutils.ConvertUtils; - -public class ExternalIdConverter { - - private final PropertyDescriptor descriptor; - - public ExternalIdConverter(PropertyDescriptor descriptor) { - super(); - this.descriptor = descriptor; - } - - public String fromModel(Object model) { - Object value; - try { - value = descriptor.getReadMethod().invoke(model); - } catch (Exception e) { - throw new RuntimeException("Unable to get external id"); - } - if (value == null) { - return null; - } - - return (String) ConvertUtils.convert(value, String.class); - } - - public void toModel(String externalId, Object model) { - Object value = ConvertUtils.convert(externalId, - descriptor.getPropertyType()); - - try { - descriptor.getWriteMethod().invoke(model, value); - } catch (Exception e) { - throw new RuntimeException("Unable to set external id", e); - } - } -} +package com.podio.item.map.converter; + +import java.beans.PropertyDescriptor; + +import org.apache.commons.beanutils.ConvertUtils; + +public class ExternalIdConverter { + + private final PropertyDescriptor descriptor; + + public ExternalIdConverter(PropertyDescriptor descriptor) { + super(); + this.descriptor = descriptor; + } + + public String fromModel(Object model) { + Object value; + try { + value = descriptor.getReadMethod().invoke(model); + } catch (Exception e) { + throw new RuntimeException("Unable to get external id"); + } + if (value == null) { + return null; + } + + return (String) ConvertUtils.convert(value, String.class); + } + + public void toModel(String externalId, Object model) { + Object value = ConvertUtils.convert(externalId, + descriptor.getPropertyType()); + + try { + descriptor.getWriteMethod().invoke(model, value); + } catch (Exception e) { + throw new RuntimeException("Unable to set external id", e); + } + } +} diff --git a/src/main/java/com/podio/item/map/converter/FieldConverter.java b/src/main/java/com/podio/item/map/converter/FieldConverter.java index 3b7e178..978fb0f 100644 --- a/src/main/java/com/podio/item/map/converter/FieldConverter.java +++ b/src/main/java/com/podio/item/map/converter/FieldConverter.java @@ -1,10 +1,10 @@ -package com.podio.item.map.converter; - -import java.util.Map; - -public interface FieldConverter { - - Map fromModel(Object value); - - Object toModel(Map map, Class modelClass); -} +package com.podio.item.map.converter; + +import java.util.Map; + +public interface FieldConverter { + + Map fromModel(Object value); + + Object toModel(Map map, Class modelClass); +} diff --git a/src/main/java/com/podio/item/map/converter/FieldConverterProvider.java b/src/main/java/com/podio/item/map/converter/FieldConverterProvider.java index f4983b3..f017655 100644 --- a/src/main/java/com/podio/item/map/converter/FieldConverterProvider.java +++ b/src/main/java/com/podio/item/map/converter/FieldConverterProvider.java @@ -1,13 +1,13 @@ -package com.podio.item.map.converter; - -import java.lang.reflect.AnnotatedElement; - -import com.podio.app.ApplicationField; -import com.podio.app.ApplicationFieldType; - -public interface FieldConverterProvider { - - boolean isSupported(ApplicationFieldType fieldType); - - FieldConverter getConverter(ApplicationField field, AnnotatedElement element); -} +package com.podio.item.map.converter; + +import java.lang.reflect.AnnotatedElement; + +import com.podio.app.ApplicationField; +import com.podio.app.ApplicationFieldType; + +public interface FieldConverterProvider { + + boolean isSupported(ApplicationFieldType fieldType); + + FieldConverter getConverter(ApplicationField field, AnnotatedElement element); +} diff --git a/src/main/java/com/podio/item/map/converter/FieldConverterRegistry.java b/src/main/java/com/podio/item/map/converter/FieldConverterRegistry.java index ab44c8b..8f86679 100644 --- a/src/main/java/com/podio/item/map/converter/FieldConverterRegistry.java +++ b/src/main/java/com/podio/item/map/converter/FieldConverterRegistry.java @@ -1,35 +1,35 @@ -package com.podio.item.map.converter; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import com.podio.app.ApplicationField; - -public class FieldConverterRegistry { - - private static final List REGISTRY = new ArrayList(); - - static { - REGISTRY.add(new MoneyConverterProvider()); - REGISTRY.add(new CategoryConverterProvider()); - REGISTRY.add(new NumberConverterProvider()); - REGISTRY.add(new TextConverterProvider()); - REGISTRY.add(new ProgressConverterProvider()); - } - - private FieldConverterRegistry() { - } - - public static FieldConverter getConverter(ApplicationField field, - Method readMethod) { - for (FieldConverterProvider provider : REGISTRY) { - if (provider.isSupported(field.getType())) { - return provider.getConverter(field, readMethod); - } - } - - throw new RuntimeException("No converter found for field of type " - + field.getType()); - } -} +package com.podio.item.map.converter; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import com.podio.app.ApplicationField; + +public class FieldConverterRegistry { + + private static final List REGISTRY = new ArrayList(); + + static { + REGISTRY.add(new MoneyConverterProvider()); + REGISTRY.add(new CategoryConverterProvider()); + REGISTRY.add(new NumberConverterProvider()); + REGISTRY.add(new TextConverterProvider()); + REGISTRY.add(new ProgressConverterProvider()); + } + + private FieldConverterRegistry() { + } + + public static FieldConverter getConverter(ApplicationField field, + Method readMethod) { + for (FieldConverterProvider provider : REGISTRY) { + if (provider.isSupported(field.getType())) { + return provider.getConverter(field, readMethod); + } + } + + throw new RuntimeException("No converter found for field of type " + + field.getType()); + } +} diff --git a/src/main/java/com/podio/item/map/converter/MoneyConverter.java b/src/main/java/com/podio/item/map/converter/MoneyConverter.java index caf0eda..2731b72 100644 --- a/src/main/java/com/podio/item/map/converter/MoneyConverter.java +++ b/src/main/java/com/podio/item/map/converter/MoneyConverter.java @@ -1,54 +1,54 @@ -package com.podio.item.map.converter; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.beanutils.ConvertUtils; -import org.joda.money.CurrencyUnit; -import org.joda.money.Money; - -public class MoneyConverter implements FieldConverter { - - private final CurrencyUnit defaultCurrency; - - public MoneyConverter(CurrencyUnit defaultCurrency) { - super(); - this.defaultCurrency = defaultCurrency; - } - - @Override - public Map fromModel(Object value) { - Map map = new HashMap(); - - Class javaClass = value.getClass(); - if (javaClass == Money.class) { - Money moneyValue = (Money) value; - - map.put("value", moneyValue.getAmount().toPlainString()); - map.put("currency", moneyValue.getCurrencyUnit().getCurrencyCode()); - } else { - map.put("value", ((BigDecimal) ConvertUtils.convert(value, - BigDecimal.class)).toPlainString()); - map.put("currency", defaultCurrency.getCurrencyCode()); - } - - return map; - } - - @Override - public Object toModel(Map map, Class modelClass) { - if (modelClass == Money.class) { - BigDecimal amount = new BigDecimal((String) map.get("value")); - CurrencyUnit currency = CurrencyUnit.of((String) map - .get("currency")); - BigDecimal roundedAmount = amount.setScale( - currency.getDecimalPlaces(), RoundingMode.HALF_EVEN); - - return Money.of(currency, roundedAmount); - } else { - return ConvertUtils.convert(map.get("value"), modelClass); - } - } -} +package com.podio.item.map.converter; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.beanutils.ConvertUtils; +import org.joda.money.CurrencyUnit; +import org.joda.money.Money; + +public class MoneyConverter implements FieldConverter { + + private final CurrencyUnit defaultCurrency; + + public MoneyConverter(CurrencyUnit defaultCurrency) { + super(); + this.defaultCurrency = defaultCurrency; + } + + @Override + public Map fromModel(Object value) { + Map map = new HashMap(); + + Class javaClass = value.getClass(); + if (javaClass == Money.class) { + Money moneyValue = (Money) value; + + map.put("value", moneyValue.getAmount().toPlainString()); + map.put("currency", moneyValue.getCurrencyUnit().getCurrencyCode()); + } else { + map.put("value", ((BigDecimal) ConvertUtils.convert(value, + BigDecimal.class)).toPlainString()); + map.put("currency", defaultCurrency.getCurrencyCode()); + } + + return map; + } + + @Override + public Object toModel(Map map, Class modelClass) { + if (modelClass == Money.class) { + BigDecimal amount = new BigDecimal((String) map.get("value")); + CurrencyUnit currency = CurrencyUnit.of((String) map + .get("currency")); + BigDecimal roundedAmount = amount.setScale( + currency.getDecimalPlaces(), RoundingMode.HALF_EVEN); + + return Money.of(currency, roundedAmount); + } else { + return ConvertUtils.convert(map.get("value"), modelClass); + } + } +} diff --git a/src/main/java/com/podio/item/map/converter/MoneyConverterProvider.java b/src/main/java/com/podio/item/map/converter/MoneyConverterProvider.java index 5a9c452..67b4000 100644 --- a/src/main/java/com/podio/item/map/converter/MoneyConverterProvider.java +++ b/src/main/java/com/podio/item/map/converter/MoneyConverterProvider.java @@ -1,33 +1,33 @@ -package com.podio.item.map.converter; - -import java.lang.reflect.AnnotatedElement; - -import org.joda.money.CurrencyUnit; - -import com.podio.app.ApplicationField; -import com.podio.app.ApplicationFieldType; -import com.podio.item.map.MoneyField; - -public class MoneyConverterProvider implements FieldConverterProvider { - - @Override - public boolean isSupported(ApplicationFieldType fieldType) { - return fieldType == ApplicationFieldType.MONEY; - } - - @Override - public FieldConverter getConverter(ApplicationField field, - AnnotatedElement element) { - MoneyField moneyField = element.getAnnotation(MoneyField.class); - - CurrencyUnit defaultCurrency; - if (moneyField != null) { - defaultCurrency = CurrencyUnit.of(moneyField.currency()); - } else { - defaultCurrency = CurrencyUnit.of(field.getConfiguration() - .getSettings().getAllowedCurrencies().get(0)); - } - - return new MoneyConverter(defaultCurrency); - } -} +package com.podio.item.map.converter; + +import java.lang.reflect.AnnotatedElement; + +import org.joda.money.CurrencyUnit; + +import com.podio.app.ApplicationField; +import com.podio.app.ApplicationFieldType; +import com.podio.item.map.MoneyField; + +public class MoneyConverterProvider implements FieldConverterProvider { + + @Override + public boolean isSupported(ApplicationFieldType fieldType) { + return fieldType == ApplicationFieldType.MONEY; + } + + @Override + public FieldConverter getConverter(ApplicationField field, + AnnotatedElement element) { + MoneyField moneyField = element.getAnnotation(MoneyField.class); + + CurrencyUnit defaultCurrency; + if (moneyField != null) { + defaultCurrency = CurrencyUnit.of(moneyField.currency()); + } else { + defaultCurrency = CurrencyUnit.of(field.getConfiguration() + .getSettings().getAllowedCurrencies().get(0)); + } + + return new MoneyConverter(defaultCurrency); + } +} diff --git a/src/main/java/com/podio/item/map/converter/NumberConverter.java b/src/main/java/com/podio/item/map/converter/NumberConverter.java index 5f3b988..7fb9ce7 100644 --- a/src/main/java/com/podio/item/map/converter/NumberConverter.java +++ b/src/main/java/com/podio/item/map/converter/NumberConverter.java @@ -1,25 +1,25 @@ -package com.podio.item.map.converter; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.Map; - -import org.apache.commons.beanutils.ConvertUtils; - -public class NumberConverter implements FieldConverter { - - @Override - public Map fromModel(Object value) { - BigDecimal bdValue = (BigDecimal) ConvertUtils.convert(value, - BigDecimal.class); - - return Collections.singletonMap("value", bdValue.toPlainString()); - } - - @Override - public Object toModel(Map map, Class modelClass) { - BigDecimal bdValue = new BigDecimal((String) map.get("value")); - - return ConvertUtils.convert(bdValue, modelClass); - } -} +package com.podio.item.map.converter; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.Map; + +import org.apache.commons.beanutils.ConvertUtils; + +public class NumberConverter implements FieldConverter { + + @Override + public Map fromModel(Object value) { + BigDecimal bdValue = (BigDecimal) ConvertUtils.convert(value, + BigDecimal.class); + + return Collections.singletonMap("value", bdValue.toPlainString()); + } + + @Override + public Object toModel(Map map, Class modelClass) { + BigDecimal bdValue = new BigDecimal((String) map.get("value")); + + return ConvertUtils.convert(bdValue, modelClass); + } +} diff --git a/src/main/java/com/podio/item/map/converter/NumberConverterProvider.java b/src/main/java/com/podio/item/map/converter/NumberConverterProvider.java index 286cab8..4f55ca6 100644 --- a/src/main/java/com/podio/item/map/converter/NumberConverterProvider.java +++ b/src/main/java/com/podio/item/map/converter/NumberConverterProvider.java @@ -1,21 +1,21 @@ -package com.podio.item.map.converter; - -import java.lang.reflect.AnnotatedElement; - -import com.podio.app.ApplicationField; -import com.podio.app.ApplicationFieldType; - -public class NumberConverterProvider implements FieldConverterProvider { - - @Override - public boolean isSupported(ApplicationFieldType fieldType) { - return fieldType == ApplicationFieldType.NUMBER; - } - - @Override - public FieldConverter getConverter(ApplicationField field, - AnnotatedElement element) { - return new NumberConverter(); - } - -} +package com.podio.item.map.converter; + +import java.lang.reflect.AnnotatedElement; + +import com.podio.app.ApplicationField; +import com.podio.app.ApplicationFieldType; + +public class NumberConverterProvider implements FieldConverterProvider { + + @Override + public boolean isSupported(ApplicationFieldType fieldType) { + return fieldType == ApplicationFieldType.NUMBER; + } + + @Override + public FieldConverter getConverter(ApplicationField field, + AnnotatedElement element) { + return new NumberConverter(); + } + +} diff --git a/src/main/java/com/podio/item/map/converter/ProgressConverter.java b/src/main/java/com/podio/item/map/converter/ProgressConverter.java index 8c6782d..71fd32c 100644 --- a/src/main/java/com/podio/item/map/converter/ProgressConverter.java +++ b/src/main/java/com/podio/item/map/converter/ProgressConverter.java @@ -1,25 +1,25 @@ -package com.podio.item.map.converter; - -import java.util.Collections; -import java.util.Map; - -import org.apache.commons.beanutils.ConvertUtils; - -public class ProgressConverter implements FieldConverter { - - @Override - public Map fromModel(Object value) { - Integer integerValue = (Integer) ConvertUtils.convert(value, - Integer.class); - - return Collections.singletonMap("value", integerValue); - } - - @Override - public Object toModel(Map map, Class modelClass) { - Integer value = (Integer) map.get("value"); - - return ConvertUtils.convert(value, modelClass); - } - -} +package com.podio.item.map.converter; + +import java.util.Collections; +import java.util.Map; + +import org.apache.commons.beanutils.ConvertUtils; + +public class ProgressConverter implements FieldConverter { + + @Override + public Map fromModel(Object value) { + Integer integerValue = (Integer) ConvertUtils.convert(value, + Integer.class); + + return Collections.singletonMap("value", integerValue); + } + + @Override + public Object toModel(Map map, Class modelClass) { + Integer value = (Integer) map.get("value"); + + return ConvertUtils.convert(value, modelClass); + } + +} diff --git a/src/main/java/com/podio/item/map/converter/ProgressConverterProvider.java b/src/main/java/com/podio/item/map/converter/ProgressConverterProvider.java index bc88e75..a958590 100644 --- a/src/main/java/com/podio/item/map/converter/ProgressConverterProvider.java +++ b/src/main/java/com/podio/item/map/converter/ProgressConverterProvider.java @@ -1,21 +1,21 @@ -package com.podio.item.map.converter; - -import java.lang.reflect.AnnotatedElement; - -import com.podio.app.ApplicationField; -import com.podio.app.ApplicationFieldType; - -public class ProgressConverterProvider implements FieldConverterProvider { - - @Override - public boolean isSupported(ApplicationFieldType fieldType) { - return fieldType == ApplicationFieldType.PROGRESS; - } - - @Override - public FieldConverter getConverter(ApplicationField field, - AnnotatedElement element) { - return new ProgressConverter(); - } - -} +package com.podio.item.map.converter; + +import java.lang.reflect.AnnotatedElement; + +import com.podio.app.ApplicationField; +import com.podio.app.ApplicationFieldType; + +public class ProgressConverterProvider implements FieldConverterProvider { + + @Override + public boolean isSupported(ApplicationFieldType fieldType) { + return fieldType == ApplicationFieldType.PROGRESS; + } + + @Override + public FieldConverter getConverter(ApplicationField field, + AnnotatedElement element) { + return new ProgressConverter(); + } + +} diff --git a/src/main/java/com/podio/item/map/converter/TextConverter.java b/src/main/java/com/podio/item/map/converter/TextConverter.java index f1cc473..728126e 100644 --- a/src/main/java/com/podio/item/map/converter/TextConverter.java +++ b/src/main/java/com/podio/item/map/converter/TextConverter.java @@ -1,22 +1,22 @@ -package com.podio.item.map.converter; - -import java.util.Collections; -import java.util.Map; - -import org.apache.commons.beanutils.ConvertUtils; - -public class TextConverter implements FieldConverter { - - @Override - public Map fromModel(Object value) { - String stringValue = (String) ConvertUtils.convert(value, String.class); - - return Collections. singletonMap("value", stringValue); - } - - @Override - public Object toModel(Map map, Class modelClass) { - return ConvertUtils.convert(map.get("value"), modelClass); - } - -} +package com.podio.item.map.converter; + +import java.util.Collections; +import java.util.Map; + +import org.apache.commons.beanutils.ConvertUtils; + +public class TextConverter implements FieldConverter { + + @Override + public Map fromModel(Object value) { + String stringValue = (String) ConvertUtils.convert(value, String.class); + + return Collections. singletonMap("value", stringValue); + } + + @Override + public Object toModel(Map map, Class modelClass) { + return ConvertUtils.convert(map.get("value"), modelClass); + } + +} diff --git a/src/main/java/com/podio/item/map/converter/TextConverterProvider.java b/src/main/java/com/podio/item/map/converter/TextConverterProvider.java index dbe8392..9107c2c 100644 --- a/src/main/java/com/podio/item/map/converter/TextConverterProvider.java +++ b/src/main/java/com/podio/item/map/converter/TextConverterProvider.java @@ -1,22 +1,22 @@ -package com.podio.item.map.converter; - -import java.lang.reflect.AnnotatedElement; - -import com.podio.app.ApplicationField; -import com.podio.app.ApplicationFieldType; - -public class TextConverterProvider implements FieldConverterProvider { - - @Override - public boolean isSupported(ApplicationFieldType fieldType) { - return fieldType == ApplicationFieldType.TEXT - || fieldType == ApplicationFieldType.LOCATION; - } - - @Override - public FieldConverter getConverter(ApplicationField field, - AnnotatedElement element) { - return new TextConverter(); - } - -} +package com.podio.item.map.converter; + +import java.lang.reflect.AnnotatedElement; + +import com.podio.app.ApplicationField; +import com.podio.app.ApplicationFieldType; + +public class TextConverterProvider implements FieldConverterProvider { + + @Override + public boolean isSupported(ApplicationFieldType fieldType) { + return fieldType == ApplicationFieldType.TEXT + || fieldType == ApplicationFieldType.LOCATION; + } + + @Override + public FieldConverter getConverter(ApplicationField field, + AnnotatedElement element) { + return new TextConverter(); + } + +} diff --git a/src/main/java/com/podio/notification/InboxNewCount.java b/src/main/java/com/podio/notification/InboxNewCount.java index ec92208..f4a82c8 100644 --- a/src/main/java/com/podio/notification/InboxNewCount.java +++ b/src/main/java/com/podio/notification/InboxNewCount.java @@ -1,17 +1,17 @@ -package com.podio.notification; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class InboxNewCount { - - private int newNotifications; - - public int getNewNotifications() { - return newNotifications; - } - - @JsonProperty("new") - public void setNewNotifications(int newNotifications) { - this.newNotifications = newNotifications; - } -} +package com.podio.notification; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class InboxNewCount { + + private int newNotifications; + + public int getNewNotifications() { + return newNotifications; + } + + @JsonProperty("new") + public void setNewNotifications(int newNotifications) { + this.newNotifications = newNotifications; + } +} diff --git a/src/main/java/com/podio/notification/NotificationAPI.java b/src/main/java/com/podio/notification/NotificationAPI.java index cd0e880..0933cfb 100644 --- a/src/main/java/com/podio/notification/NotificationAPI.java +++ b/src/main/java/com/podio/notification/NotificationAPI.java @@ -1,54 +1,54 @@ -package com.podio.notification; - -import java.util.Collection; -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import org.joda.time.DateTime; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.CSVUtil; -import com.podio.common.Empty; -import com.podio.serialize.DateTimeUtil; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; - -/** - * A notification is an information about an event that occured in Podio. A - * notification is directed against a single user, and can have a status of - * either unread or viewed. Notifications have a reference to the action that - * caused the notification. - */ -public class NotificationAPI extends BaseAPI { - - public NotificationAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Returns the number of unread notifications - * - * @return The number of unread notifications - */ - public int getInboxNewCount() { - WebResource resource = getResourceFactory().getApiResource( - "/notification/inbox/new/count"); - - return resource.get(InboxNewCount.class).getNewNotifications(); - } - - /** - * Mark the notification as viewed. This will move the notification from the - * inbox to the viewed archive. - * - * @param notificationId - * The id of the notification - */ - public void markAsViewed(int notificationId) { - getResourceFactory() - .getApiResource("/notification/" + notificationId + "/viewed") - .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); - } +package com.podio.notification; + +import java.util.Collection; +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import org.joda.time.DateTime; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.CSVUtil; +import com.podio.common.Empty; +import com.podio.serialize.DateTimeUtil; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; + +/** + * A notification is an information about an event that occured in Podio. A + * notification is directed against a single user, and can have a status of + * either unread or viewed. Notifications have a reference to the action that + * caused the notification. + */ +public class NotificationAPI extends BaseAPI { + + public NotificationAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Returns the number of unread notifications + * + * @return The number of unread notifications + */ + public int getInboxNewCount() { + WebResource resource = getResourceFactory().getApiResource( + "/notification/inbox/new/count"); + + return resource.get(InboxNewCount.class).getNewNotifications(); + } + + /** + * Mark the notification as viewed. This will move the notification from the + * inbox to the viewed archive. + * + * @param notificationId + * The id of the notification + */ + public void markAsViewed(int notificationId) { + getResourceFactory() + .getApiResource("/notification/" + notificationId + "/viewed") + .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); + } } \ No newline at end of file diff --git a/src/main/java/com/podio/notification/NotificationContextType.java b/src/main/java/com/podio/notification/NotificationContextType.java index 11c686c..b1f8b77 100644 --- a/src/main/java/com/podio/notification/NotificationContextType.java +++ b/src/main/java/com/podio/notification/NotificationContextType.java @@ -1,21 +1,21 @@ -package com.podio.notification; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum NotificationContextType { - - STATUS, TASK, PROFILES, SPACE, ITEM, BULLETIN, APP, SHARE, ORG, QUESTION, FILE, BATCH; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static NotificationContextType getByName(String value) { - return valueOf(value.toUpperCase()); - } - -} +package com.podio.notification; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum NotificationContextType { + + STATUS, TASK, PROFILES, SPACE, ITEM, BULLETIN, APP, SHARE, ORG, QUESTION, FILE, BATCH; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static NotificationContextType getByName(String value) { + return valueOf(value.toUpperCase()); + } + +} diff --git a/src/main/java/com/podio/notification/NotificationDateType.java b/src/main/java/com/podio/notification/NotificationDateType.java index 2872eb0..13af50f 100644 --- a/src/main/java/com/podio/notification/NotificationDateType.java +++ b/src/main/java/com/podio/notification/NotificationDateType.java @@ -1,28 +1,28 @@ -package com.podio.notification; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum NotificationDateType { - - /** - * Ordered by when the notification was created - */ - CREATED, - - /** - * Ordered by when the notification was viewed - */ - VIEWED; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static NotificationDateType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.notification; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum NotificationDateType { + + /** + * Ordered by when the notification was created + */ + CREATED, + + /** + * Ordered by when the notification was viewed + */ + VIEWED; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static NotificationDateType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/notification/NotificationType.java b/src/main/java/com/podio/notification/NotificationType.java index 51e819c..76531f9 100644 --- a/src/main/java/com/podio/notification/NotificationType.java +++ b/src/main/java/com/podio/notification/NotificationType.java @@ -1,128 +1,128 @@ -package com.podio.notification; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum NotificationType { - - /** - * The user was alerted as part of an action - */ - ALERT, - - /** - * A comment was added to an object - */ - COMMENT, - - /** - * A file was attached to an object - */ - FILE, - - /** - * The user was added as a reference on an item - */ - MEMBER_REFERENCE_ADD, - - /** - * The user was removed as a reference on an item - */ - MEMBER_REFERENCE_REMOVE, - - /** - * A rating was added to an object - */ - RATING, - - /** - * The user was invited to join a space - */ - SPACE_INVITE, - - /** - * The user accepted an invitation to join the space - */ - SPACE_ACCEPT, - - /** - * The user declined an invitation to join the space - */ - SPACE_DECLINE, - - /** - * The admin ended the users space membership - */ - MEMBER_ENDED_USER, - - /** - * The user left the space - */ - MEMBER_ENDED_ADMIN, - - /** - * The role of the user was changed on a space - */ - ROLE_CHANGE, - - /** - * An object was created - */ - CREATION, - - /** - * An object was updated - */ - UPDATE, - - /** - * An object was deleted - */ - DELETE, - - /** - * A message was received from a conversation - */ - MESSAGE, - - /** - * A news item was received from Hoist - */ - BULLETIN, - - /** - * An item was created on an app with RSVP enabled - */ - RSVP, - - /** - * A question was answered - */ - ANSWER, - - /** - * A reminder - */ - REMINDER, - - /** - * The batch is processing - */ - BATCH_PROCESS, - - /** - * The batch was completed - */ - BATCH_COMPLETE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static NotificationType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.notification; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum NotificationType { + + /** + * The user was alerted as part of an action + */ + ALERT, + + /** + * A comment was added to an object + */ + COMMENT, + + /** + * A file was attached to an object + */ + FILE, + + /** + * The user was added as a reference on an item + */ + MEMBER_REFERENCE_ADD, + + /** + * The user was removed as a reference on an item + */ + MEMBER_REFERENCE_REMOVE, + + /** + * A rating was added to an object + */ + RATING, + + /** + * The user was invited to join a space + */ + SPACE_INVITE, + + /** + * The user accepted an invitation to join the space + */ + SPACE_ACCEPT, + + /** + * The user declined an invitation to join the space + */ + SPACE_DECLINE, + + /** + * The admin ended the users space membership + */ + MEMBER_ENDED_USER, + + /** + * The user left the space + */ + MEMBER_ENDED_ADMIN, + + /** + * The role of the user was changed on a space + */ + ROLE_CHANGE, + + /** + * An object was created + */ + CREATION, + + /** + * An object was updated + */ + UPDATE, + + /** + * An object was deleted + */ + DELETE, + + /** + * A message was received from a conversation + */ + MESSAGE, + + /** + * A news item was received from Hoist + */ + BULLETIN, + + /** + * An item was created on an app with RSVP enabled + */ + RSVP, + + /** + * A question was answered + */ + ANSWER, + + /** + * A reminder + */ + REMINDER, + + /** + * The batch is processing + */ + BATCH_PROCESS, + + /** + * The batch was completed + */ + BATCH_COMPLETE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static NotificationType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/oauth/OAuthAppCredentials.java b/src/main/java/com/podio/oauth/OAuthAppCredentials.java index 2851018..681cd81 100644 --- a/src/main/java/com/podio/oauth/OAuthAppCredentials.java +++ b/src/main/java/com/podio/oauth/OAuthAppCredentials.java @@ -1,26 +1,26 @@ -package com.podio.oauth; - -import javax.ws.rs.core.MultivaluedMap; - -public class OAuthAppCredentials implements OAuthUserCredentials { - - private final int appId; - - private final String appToken; - - public OAuthAppCredentials(int appId, String appToken) { - super(); - this.appId = appId; - this.appToken = appToken; - } - - public String getType() { - return "app"; - } - - public void addParameters(MultivaluedMap map) { - map.add("app_id", Integer.toString(appId)); - map.add("app_token", appToken); - } - -} +package com.podio.oauth; + +import javax.ws.rs.core.MultivaluedMap; + +public class OAuthAppCredentials implements OAuthUserCredentials { + + private final int appId; + + private final String appToken; + + public OAuthAppCredentials(int appId, String appToken) { + super(); + this.appId = appId; + this.appToken = appToken; + } + + public String getType() { + return "app"; + } + + public void addParameters(MultivaluedMap map) { + map.add("app_id", Integer.toString(appId)); + map.add("app_token", appToken); + } + +} diff --git a/src/main/java/com/podio/org/EndMemberInfo.java b/src/main/java/com/podio/org/EndMemberInfo.java index 59f016b..2c7cbca 100644 --- a/src/main/java/com/podio/org/EndMemberInfo.java +++ b/src/main/java/com/podio/org/EndMemberInfo.java @@ -1,40 +1,40 @@ -package com.podio.org; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.space.SpaceMemberDetails; - -public class EndMemberInfo { - - /** - * list of spaces the user would just be removed from - */ - private List toRemove; - - /** - * list of spaces where all other users will be promoted to admin - */ - private List toPromote; - - /** - * list of spaces which would be deleted - */ - private List toDelete; - - @JsonProperty("to_remove") - public List getToRemove() { - return toRemove; - } - - @JsonProperty("to_promote") - public List getToPromote() { - return toPromote; - } - - @JsonProperty("to_delete") - public List getToDelete() { - return toDelete; - } -} +package com.podio.org; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.space.SpaceMemberDetails; + +public class EndMemberInfo { + + /** + * list of spaces the user would just be removed from + */ + private List toRemove; + + /** + * list of spaces where all other users will be promoted to admin + */ + private List toPromote; + + /** + * list of spaces which would be deleted + */ + private List toDelete; + + @JsonProperty("to_remove") + public List getToRemove() { + return toRemove; + } + + @JsonProperty("to_promote") + public List getToPromote() { + return toPromote; + } + + @JsonProperty("to_delete") + public List getToDelete() { + return toDelete; + } +} diff --git a/src/main/java/com/podio/org/Organization.java b/src/main/java/com/podio/org/Organization.java index cc95db0..4fb5c44 100644 --- a/src/main/java/com/podio/org/Organization.java +++ b/src/main/java/com/podio/org/Organization.java @@ -1,64 +1,64 @@ -package com.podio.org; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.contact.ProfileMini; - -public class Organization extends OrganizationMini { - - /** - * The status of the organization - */ - private OrganizationStatus status; - - /** - * The maximum number of users that are allowed in the organization - */ - private int userLimit; - - /** - * The date and time when the organization was created - */ - private DateTime createdOn; - - /** - * The user that created the organization - */ - private ProfileMini createdBy; - - public OrganizationStatus getStatus() { - return status; - } - - public void setStatus(OrganizationStatus status) { - this.status = status; - } - - public int getUserLimit() { - return userLimit; - } - - @JsonProperty("user_limit") - public void setUserLimit(int userLimit) { - this.userLimit = userLimit; - } - - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } - - public ProfileMini getCreatedBy() { - return createdBy; - } - - @JsonProperty("created_by") - public void setCreatedBy(ProfileMini createdBy) { - this.createdBy = createdBy; - } -} +package com.podio.org; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.contact.ProfileMini; + +public class Organization extends OrganizationMini { + + /** + * The status of the organization + */ + private OrganizationStatus status; + + /** + * The maximum number of users that are allowed in the organization + */ + private int userLimit; + + /** + * The date and time when the organization was created + */ + private DateTime createdOn; + + /** + * The user that created the organization + */ + private ProfileMini createdBy; + + public OrganizationStatus getStatus() { + return status; + } + + public void setStatus(OrganizationStatus status) { + this.status = status; + } + + public int getUserLimit() { + return userLimit; + } + + @JsonProperty("user_limit") + public void setUserLimit(int userLimit) { + this.userLimit = userLimit; + } + + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } + + public ProfileMini getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_by") + public void setCreatedBy(ProfileMini createdBy) { + this.createdBy = createdBy; + } +} diff --git a/src/main/java/com/podio/org/OrganizationCreate.java b/src/main/java/com/podio/org/OrganizationCreate.java index 47ca239..7e6e4f6 100644 --- a/src/main/java/com/podio/org/OrganizationCreate.java +++ b/src/main/java/com/podio/org/OrganizationCreate.java @@ -1,36 +1,36 @@ -package com.podio.org; - -public class OrganizationCreate { - - /** - * The name of the new organization - */ - private String name; - - /** - * The file id of the logo of the organization - */ - private Integer logo; - - public OrganizationCreate(String name, Integer logo) { - super(); - this.name = name; - this.logo = logo; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getLogo() { - return logo; - } - - public void setLogo(Integer logo) { - this.logo = logo; - } -} +package com.podio.org; + +public class OrganizationCreate { + + /** + * The name of the new organization + */ + private String name; + + /** + * The file id of the logo of the organization + */ + private Integer logo; + + public OrganizationCreate(String name, Integer logo) { + super(); + this.name = name; + this.logo = logo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getLogo() { + return logo; + } + + public void setLogo(Integer logo) { + this.logo = logo; + } +} diff --git a/src/main/java/com/podio/org/OrganizationCreateResponse.java b/src/main/java/com/podio/org/OrganizationCreateResponse.java index c9884fd..6d16e86 100644 --- a/src/main/java/com/podio/org/OrganizationCreateResponse.java +++ b/src/main/java/com/podio/org/OrganizationCreateResponse.java @@ -1,33 +1,33 @@ -package com.podio.org; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class OrganizationCreateResponse { - - /** - * The id of the newly created organization - */ - private int id; - - /** - * The full URL of the organization - */ - private String url; - - public int getId() { - return id; - } - - @JsonProperty("org_id") - public void setId(int id) { - this.id = id; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } -} +package com.podio.org; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class OrganizationCreateResponse { + + /** + * The id of the newly created organization + */ + private int id; + + /** + * The full URL of the organization + */ + private String url; + + public int getId() { + return id; + } + + @JsonProperty("org_id") + public void setId(int id) { + this.id = id; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/main/java/com/podio/org/OrganizationMember.java b/src/main/java/com/podio/org/OrganizationMember.java index d67beac..b234375 100644 --- a/src/main/java/com/podio/org/OrganizationMember.java +++ b/src/main/java/com/podio/org/OrganizationMember.java @@ -1,78 +1,78 @@ -package com.podio.org; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.common.Role; -import com.podio.contact.Profile; -import com.podio.user.User; - -public class OrganizationMember { - - /** - * The user data of the member - */ - private User user; - - /** - * The profile of the member - */ - private Profile profile; - - /** - * True if the member is an employee, false otherwise - */ - private boolean employee; - - /** - * The organization role of the user, if any, either "regular" or "admin" - */ - private Role role; - - /** - * The number of spaces the user is member of in the organization - */ - private int spaceMemberships; - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Profile getProfile() { - return profile; - } - - public void setProfile(Profile profile) { - this.profile = profile; - } - - public boolean isEmployee() { - return employee; - } - - public void setEmployee(boolean employee) { - this.employee = employee; - } - - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } - - @JsonProperty("space_memberships") - public int getSpaceMemberships() { - return spaceMemberships; - } - - @JsonProperty("space_memberships") - public void setSpaceMemberships(int spaceMemberships) { - this.spaceMemberships = spaceMemberships; - } - -} +package com.podio.org; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.Role; +import com.podio.contact.Profile; +import com.podio.user.User; + +public class OrganizationMember { + + /** + * The user data of the member + */ + private User user; + + /** + * The profile of the member + */ + private Profile profile; + + /** + * True if the member is an employee, false otherwise + */ + private boolean employee; + + /** + * The organization role of the user, if any, either "regular" or "admin" + */ + private Role role; + + /** + * The number of spaces the user is member of in the organization + */ + private int spaceMemberships; + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Profile getProfile() { + return profile; + } + + public void setProfile(Profile profile) { + this.profile = profile; + } + + public boolean isEmployee() { + return employee; + } + + public void setEmployee(boolean employee) { + this.employee = employee; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + @JsonProperty("space_memberships") + public int getSpaceMemberships() { + return spaceMemberships; + } + + @JsonProperty("space_memberships") + public void setSpaceMemberships(int spaceMemberships) { + this.spaceMemberships = spaceMemberships; + } + +} diff --git a/src/main/java/com/podio/org/OrganizationStatistics.java b/src/main/java/com/podio/org/OrganizationStatistics.java index aca5856..edfa075 100644 --- a/src/main/java/com/podio/org/OrganizationStatistics.java +++ b/src/main/java/com/podio/org/OrganizationStatistics.java @@ -1,105 +1,105 @@ -package com.podio.org; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -public class OrganizationStatistics { - - /** - * The id of the org - */ - private int id; - - /** - * number of all items in all apps in all spaces - */ - private int itemsCount; - - /** - * time when a user last logged in - */ - private DateTime lastActivityOn; - - /** - * number of all invitations - */ - private int availableInvitations; - - /** - * number of all apps in all spaces - */ - private int appsCount; - - /** - * number of spaces - */ - private int spacesCount; - - /** - * number of users in this org - */ - private int usersCount; - - public int getId() { - return id; - } - - @JsonProperty("org_id") - public void setId(int id) { - this.id = id; - } - - public int getItemsCount() { - return itemsCount; - } - - @JsonProperty("items_count") - public void setItemsCount(int itemsCount) { - this.itemsCount = itemsCount; - } - - public DateTime getLastActivityOn() { - return lastActivityOn; - } - - @JsonProperty("last_activity_on") - public void setLastActivityOn(DateTime lastActivityOn) { - this.lastActivityOn = lastActivityOn; - } - - public int getAvailableInvitations() { - return availableInvitations; - } - - @JsonProperty("available_invitations") - public void setAvailableInvitations(int availableInvitations) { - this.availableInvitations = availableInvitations; - } - - public int getAppsCount() { - return appsCount; - } - - @JsonProperty("apps_count") - public void setAppsCount(int appsCount) { - this.appsCount = appsCount; - } - - public int getSpacesCount() { - return spacesCount; - } - - @JsonProperty("spaces_count") - public void setSpacesCount(int spacesCount) { - this.spacesCount = spacesCount; - } - - public int getUsersCount() { - return usersCount; - } - - @JsonProperty("users_count") - public void setUsersCount(int usersCount) { - this.usersCount = usersCount; - } -} +package com.podio.org; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +public class OrganizationStatistics { + + /** + * The id of the org + */ + private int id; + + /** + * number of all items in all apps in all spaces + */ + private int itemsCount; + + /** + * time when a user last logged in + */ + private DateTime lastActivityOn; + + /** + * number of all invitations + */ + private int availableInvitations; + + /** + * number of all apps in all spaces + */ + private int appsCount; + + /** + * number of spaces + */ + private int spacesCount; + + /** + * number of users in this org + */ + private int usersCount; + + public int getId() { + return id; + } + + @JsonProperty("org_id") + public void setId(int id) { + this.id = id; + } + + public int getItemsCount() { + return itemsCount; + } + + @JsonProperty("items_count") + public void setItemsCount(int itemsCount) { + this.itemsCount = itemsCount; + } + + public DateTime getLastActivityOn() { + return lastActivityOn; + } + + @JsonProperty("last_activity_on") + public void setLastActivityOn(DateTime lastActivityOn) { + this.lastActivityOn = lastActivityOn; + } + + public int getAvailableInvitations() { + return availableInvitations; + } + + @JsonProperty("available_invitations") + public void setAvailableInvitations(int availableInvitations) { + this.availableInvitations = availableInvitations; + } + + public int getAppsCount() { + return appsCount; + } + + @JsonProperty("apps_count") + public void setAppsCount(int appsCount) { + this.appsCount = appsCount; + } + + public int getSpacesCount() { + return spacesCount; + } + + @JsonProperty("spaces_count") + public void setSpacesCount(int spacesCount) { + this.spacesCount = spacesCount; + } + + public int getUsersCount() { + return usersCount; + } + + @JsonProperty("users_count") + public void setUsersCount(int usersCount) { + this.usersCount = usersCount; + } +} diff --git a/src/main/java/com/podio/org/OrganizationStatus.java b/src/main/java/com/podio/org/OrganizationStatus.java index 4af0bb9..4709252 100644 --- a/src/main/java/com/podio/org/OrganizationStatus.java +++ b/src/main/java/com/podio/org/OrganizationStatus.java @@ -1,21 +1,21 @@ -package com.podio.org; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum OrganizationStatus { - - ACTIVE, - INACTIVE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static OrganizationStatus getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.org; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum OrganizationStatus { + + ACTIVE, + INACTIVE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static OrganizationStatus getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/rating/Rating.java b/src/main/java/com/podio/rating/Rating.java index 50e5db1..0554a89 100644 --- a/src/main/java/com/podio/rating/Rating.java +++ b/src/main/java/com/podio/rating/Rating.java @@ -1,60 +1,60 @@ -package com.podio.rating; - -import org.joda.time.DateTime; - -import com.podio.contact.ProfileMini; - -public class Rating { - - /** - * The type of rating - */ - private RatingType type; - - /** - * The value of the rating - */ - private int value; - - /** - * The user who gave the rating - */ - private ProfileMini user; - - /** - * The date and time the rating was given - */ - private DateTime time; - - public RatingType getType() { - return type; - } - - public void setType(RatingType type) { - this.type = type; - } - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } - - public ProfileMini getUser() { - return user; - } - - public void setUser(ProfileMini user) { - this.user = user; - } - - public DateTime getTime() { - return time; - } - - public void setTime(DateTime time) { - this.time = time; - } -} +package com.podio.rating; + +import org.joda.time.DateTime; + +import com.podio.contact.ProfileMini; + +public class Rating { + + /** + * The type of rating + */ + private RatingType type; + + /** + * The value of the rating + */ + private int value; + + /** + * The user who gave the rating + */ + private ProfileMini user; + + /** + * The date and time the rating was given + */ + private DateTime time; + + public RatingType getType() { + return type; + } + + public void setType(RatingType type) { + this.type = type; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public ProfileMini getUser() { + return user; + } + + public void setUser(ProfileMini user) { + this.user = user; + } + + public DateTime getTime() { + return time; + } + + public void setTime(DateTime time) { + this.time = time; + } +} diff --git a/src/main/java/com/podio/rating/RatingCreateResponse.java b/src/main/java/com/podio/rating/RatingCreateResponse.java index 10eb01f..0803bec 100644 --- a/src/main/java/com/podio/rating/RatingCreateResponse.java +++ b/src/main/java/com/podio/rating/RatingCreateResponse.java @@ -1,17 +1,17 @@ -package com.podio.rating; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class RatingCreateResponse { - - private int id; - - public int getId() { - return id; - } - - @JsonProperty("rating_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.rating; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class RatingCreateResponse { + + private int id; + + public int getId() { + return id; + } + + @JsonProperty("rating_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/rating/RatingType.java b/src/main/java/com/podio/rating/RatingType.java index 656aca5..d1305c2 100644 --- a/src/main/java/com/podio/rating/RatingType.java +++ b/src/main/java/com/podio/rating/RatingType.java @@ -1,49 +1,49 @@ -package com.podio.rating; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum RatingType { - - /** - * Signals that the user approves (0) or disapproves(1) - */ - APPROVED, - - /** - * Indicates that the user can attend (0), cannot attend (1) or can maybe - * attend (2) - */ - RSVP, - - /** - * A rating from 1-5 where 5 is the best - */ - FIVESTAR, - - /** - * Signals the user says yes (0) or no (1) - */ - YESNO, - - /** - * Signals a thumbs up (0) or thumbs down (1) - */ - THUMBS, - - /** - * Signals the user likes the item (1) - */ - LIKE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static RatingType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.rating; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum RatingType { + + /** + * Signals that the user approves (0) or disapproves(1) + */ + APPROVED, + + /** + * Indicates that the user can attend (0), cannot attend (1) or can maybe + * attend (2) + */ + RSVP, + + /** + * A rating from 1-5 where 5 is the best + */ + FIVESTAR, + + /** + * Signals the user says yes (0) or no (1) + */ + YESNO, + + /** + * Signals a thumbs up (0) or thumbs down (1) + */ + THUMBS, + + /** + * Signals the user likes the item (1) + */ + LIKE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static RatingType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/rating/RatingTypeKeyDeserializer.java b/src/main/java/com/podio/rating/RatingTypeKeyDeserializer.java index f61ba0f..d476afc 100644 --- a/src/main/java/com/podio/rating/RatingTypeKeyDeserializer.java +++ b/src/main/java/com/podio/rating/RatingTypeKeyDeserializer.java @@ -1,16 +1,16 @@ -package com.podio.rating; - -import java.io.IOException; - -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.KeyDeserializer; - -public class RatingTypeKeyDeserializer extends KeyDeserializer { - - @Override - public Object deserializeKey(String key, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - return RatingType.getByName(key); - } -} +package com.podio.rating; + +import java.io.IOException; + +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.KeyDeserializer; + +public class RatingTypeKeyDeserializer extends KeyDeserializer { + + @Override + public Object deserializeKey(String key, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + return RatingType.getByName(key); + } +} diff --git a/src/main/java/com/podio/rating/RatingValue.java b/src/main/java/com/podio/rating/RatingValue.java index a7e80a0..7654e1b 100644 --- a/src/main/java/com/podio/rating/RatingValue.java +++ b/src/main/java/com/podio/rating/RatingValue.java @@ -1,28 +1,28 @@ -package com.podio.rating; - -public class RatingValue { - - public static final int YESNO_YES = 0; - public static final int YESNO_NO = 1; - - public static final int APPROVED_APPROVES = 0; - public static final int APPROVED_DISAPPROVES = 1; - - public static final int RSVP_ATTEND = 0; - public static final int RSVP_NOT_ATTEND = 1; - public static final int RSVP_MAYBE_ATTEND = 2; - - public static final int FIVESTAR_1_STAR = 1; - public static final int FIVESTAR_2_STARS = 2; - public static final int FIVESTAR_3_STARS = 3; - public static final int FIVESTAR_4_STARS = 4; - public static final int FIVESTAR_5_STARS = 5; - - public static final int THUMBS_UP = 0; - public static final int THUMBS_DOWN = 1; - - public static final int LIKE = 1; - - private RatingValue() { - } -} +package com.podio.rating; + +public class RatingValue { + + public static final int YESNO_YES = 0; + public static final int YESNO_NO = 1; + + public static final int APPROVED_APPROVES = 0; + public static final int APPROVED_DISAPPROVES = 1; + + public static final int RSVP_ATTEND = 0; + public static final int RSVP_NOT_ATTEND = 1; + public static final int RSVP_MAYBE_ATTEND = 2; + + public static final int FIVESTAR_1_STAR = 1; + public static final int FIVESTAR_2_STARS = 2; + public static final int FIVESTAR_3_STARS = 3; + public static final int FIVESTAR_4_STARS = 4; + public static final int FIVESTAR_5_STARS = 5; + + public static final int THUMBS_UP = 0; + public static final int THUMBS_DOWN = 1; + + public static final int LIKE = 1; + + private RatingValue() { + } +} diff --git a/src/main/java/com/podio/rating/RatingValuesMap.java b/src/main/java/com/podio/rating/RatingValuesMap.java index 3c334b2..4357814 100644 --- a/src/main/java/com/podio/rating/RatingValuesMap.java +++ b/src/main/java/com/podio/rating/RatingValuesMap.java @@ -1,23 +1,23 @@ -package com.podio.rating; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonAnySetter; - -public class RatingValuesMap implements Serializable { - - private static final long serialVersionUID = 1L; - - private final Map values = new HashMap(); - - public TypeRating get(RatingType type) { - return values.get(type); - } - - @JsonAnySetter - public void set(String type, TypeRating value) { - values.put(RatingType.getByName(type), value); - } -} +package com.podio.rating; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonAnySetter; + +public class RatingValuesMap implements Serializable { + + private static final long serialVersionUID = 1L; + + private final Map values = new HashMap(); + + public TypeRating get(RatingType type) { + return values.get(type); + } + + @JsonAnySetter + public void set(String type, TypeRating value) { + values.put(RatingType.getByName(type), value); + } +} diff --git a/src/main/java/com/podio/rating/SingleRatingValue.java b/src/main/java/com/podio/rating/SingleRatingValue.java index ddf4581..4f5e328 100644 --- a/src/main/java/com/podio/rating/SingleRatingValue.java +++ b/src/main/java/com/podio/rating/SingleRatingValue.java @@ -1,14 +1,14 @@ -package com.podio.rating; - -public class SingleRatingValue { - - private int value; - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } -} +package com.podio.rating; + +public class SingleRatingValue { + + private int value; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/podio/rating/TypeRating.java b/src/main/java/com/podio/rating/TypeRating.java index ae1d922..8c70ad9 100644 --- a/src/main/java/com/podio/rating/TypeRating.java +++ b/src/main/java/com/podio/rating/TypeRating.java @@ -1,40 +1,40 @@ -package com.podio.rating; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -public class TypeRating implements Serializable { - - private static final long serialVersionUID = 1L; - - private Map counts = new HashMap(); - - private Float average; - - @Override - public String toString() { - return "TypeRating [counts=" + counts + ", average=" + average + "]"; - } - - public ValueRatings getCounts(int value) { - return counts.get(value); - } - - public Map getCounts() { - return counts; - } - - public void setCounts(Map counts) { - this.counts = counts; - } - - public Float getAverage() { - return average; - } - - public void setAverage(Float average) { - this.average = average; - } - -} +package com.podio.rating; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class TypeRating implements Serializable { + + private static final long serialVersionUID = 1L; + + private Map counts = new HashMap(); + + private Float average; + + @Override + public String toString() { + return "TypeRating [counts=" + counts + ", average=" + average + "]"; + } + + public ValueRatings getCounts(int value) { + return counts.get(value); + } + + public Map getCounts() { + return counts; + } + + public void setCounts(Map counts) { + this.counts = counts; + } + + public Float getAverage() { + return average; + } + + public void setAverage(Float average) { + this.average = average; + } + +} diff --git a/src/main/java/com/podio/rating/ValueRatings.java b/src/main/java/com/podio/rating/ValueRatings.java index a34acfc..9b3a116 100644 --- a/src/main/java/com/podio/rating/ValueRatings.java +++ b/src/main/java/com/podio/rating/ValueRatings.java @@ -1,37 +1,37 @@ -package com.podio.rating; - -import java.io.Serializable; -import java.util.List; - -import com.podio.contact.ProfileMini; - -public class ValueRatings implements Serializable { - - private static final long serialVersionUID = 1L; - - private int total; - - private List users; - - @Override - public String toString() { - return "ValueRatings [total=" + total + ", users=" + users + "]"; - } - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public List getUsers() { - return users; - } - - public void setUsers(List users) { - this.users = users; - } - -} +package com.podio.rating; + +import java.io.Serializable; +import java.util.List; + +import com.podio.contact.ProfileMini; + +public class ValueRatings implements Serializable { + + private static final long serialVersionUID = 1L; + + private int total; + + private List users; + + @Override + public String toString() { + return "ValueRatings [total=" + total + ", users=" + users + "]"; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + +} diff --git a/src/main/java/com/podio/serialize/DateTimeDeserializer.java b/src/main/java/com/podio/serialize/DateTimeDeserializer.java index 72c19ca..17dbe83 100644 --- a/src/main/java/com/podio/serialize/DateTimeDeserializer.java +++ b/src/main/java/com/podio/serialize/DateTimeDeserializer.java @@ -1,18 +1,18 @@ -package com.podio.serialize; - -import java.io.IOException; - -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; -import org.joda.time.DateTime; - -public class DateTimeDeserializer extends JsonDeserializer { - - @Override - public DateTime deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - return DateTimeUtil.parseDateTime(jp.getText()); - } -} +package com.podio.serialize; + +import java.io.IOException; + +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; +import org.joda.time.DateTime; + +public class DateTimeDeserializer extends JsonDeserializer { + + @Override + public DateTime deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + return DateTimeUtil.parseDateTime(jp.getText()); + } +} diff --git a/src/main/java/com/podio/serialize/DateTimeSerializer.java b/src/main/java/com/podio/serialize/DateTimeSerializer.java index 1fdae73..3fa0de7 100644 --- a/src/main/java/com/podio/serialize/DateTimeSerializer.java +++ b/src/main/java/com/podio/serialize/DateTimeSerializer.java @@ -1,20 +1,20 @@ -package com.podio.serialize; - -import java.io.IOException; - -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; -import org.joda.time.DateTime; - -public class DateTimeSerializer extends JsonSerializer { - - @Override - public void serialize(DateTime value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeString(DateTimeUtil.formatDateTime(value)); - } - -} +package com.podio.serialize; + +import java.io.IOException; + +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; +import org.joda.time.DateTime; + +public class DateTimeSerializer extends JsonSerializer { + + @Override + public void serialize(DateTime value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(DateTimeUtil.formatDateTime(value)); + } + +} diff --git a/src/main/java/com/podio/serialize/DateTimeUtil.java b/src/main/java/com/podio/serialize/DateTimeUtil.java index 6790d4c..85e4728 100644 --- a/src/main/java/com/podio/serialize/DateTimeUtil.java +++ b/src/main/java/com/podio/serialize/DateTimeUtil.java @@ -1,40 +1,40 @@ -package com.podio.serialize; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.LocalDate; -import org.joda.time.LocalTime; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - -public final class DateTimeUtil { - - private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormat - .forPattern("yyyy-MM-dd HH:mm:ss").withZone(DateTimeZone.UTC); - - private static final DateTimeFormatter DATE_FORMAT = DateTimeFormat - .forPattern("yyyy-MM-dd").withZone(DateTimeZone.UTC); - - private DateTimeUtil() { - } - - public static DateTime parseDateTime(String text) { - try { - return DATE_TIME_FORMAT.parseDateTime(text); - } catch (IllegalArgumentException e) { - return parseDate(text).toDateTime(new LocalTime(0, 0)); - } - } - - public static String formatDateTime(DateTime dateTime) { - return DATE_TIME_FORMAT.print(dateTime); - } - - public static LocalDate parseDate(String text) { - return DATE_FORMAT.parseDateTime(text).toLocalDate(); - } - - public static String formatDate(LocalDate date) { - return DATE_FORMAT.print(date); - } -} +package com.podio.serialize; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.LocalDate; +import org.joda.time.LocalTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +public final class DateTimeUtil { + + private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormat + .forPattern("yyyy-MM-dd HH:mm:ss").withZone(DateTimeZone.UTC); + + private static final DateTimeFormatter DATE_FORMAT = DateTimeFormat + .forPattern("yyyy-MM-dd").withZone(DateTimeZone.UTC); + + private DateTimeUtil() { + } + + public static DateTime parseDateTime(String text) { + try { + return DATE_TIME_FORMAT.parseDateTime(text); + } catch (IllegalArgumentException e) { + return parseDate(text).toDateTime(new LocalTime(0, 0)); + } + } + + public static String formatDateTime(DateTime dateTime) { + return DATE_TIME_FORMAT.print(dateTime); + } + + public static LocalDate parseDate(String text) { + return DATE_FORMAT.parseDateTime(text).toLocalDate(); + } + + public static String formatDate(LocalDate date) { + return DATE_FORMAT.print(date); + } +} diff --git a/src/main/java/com/podio/serialize/LocalDateDeserializer.java b/src/main/java/com/podio/serialize/LocalDateDeserializer.java index 69f06de..8f33133 100644 --- a/src/main/java/com/podio/serialize/LocalDateDeserializer.java +++ b/src/main/java/com/podio/serialize/LocalDateDeserializer.java @@ -1,18 +1,18 @@ -package com.podio.serialize; - -import java.io.IOException; - -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; -import org.joda.time.LocalDate; - -public class LocalDateDeserializer extends JsonDeserializer { - - @Override - public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - return DateTimeUtil.parseDate(jp.getText()); - } -} +package com.podio.serialize; + +import java.io.IOException; + +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; +import org.joda.time.LocalDate; + +public class LocalDateDeserializer extends JsonDeserializer { + + @Override + public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + return DateTimeUtil.parseDate(jp.getText()); + } +} diff --git a/src/main/java/com/podio/serialize/LocalDateSerializer.java b/src/main/java/com/podio/serialize/LocalDateSerializer.java index 631f769..f14d3b3 100644 --- a/src/main/java/com/podio/serialize/LocalDateSerializer.java +++ b/src/main/java/com/podio/serialize/LocalDateSerializer.java @@ -1,20 +1,20 @@ -package com.podio.serialize; - -import java.io.IOException; - -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; -import org.joda.time.LocalDate; - -public class LocalDateSerializer extends JsonSerializer { - - @Override - public void serialize(LocalDate value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeString(DateTimeUtil.formatDate(value)); - } - -} +package com.podio.serialize; + +import java.io.IOException; + +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; +import org.joda.time.LocalDate; + +public class LocalDateSerializer extends JsonSerializer { + + @Override + public void serialize(LocalDate value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(DateTimeUtil.formatDate(value)); + } + +} diff --git a/src/main/java/com/podio/serialize/LocaleDeserializer.java b/src/main/java/com/podio/serialize/LocaleDeserializer.java index ea64e68..12287a8 100644 --- a/src/main/java/com/podio/serialize/LocaleDeserializer.java +++ b/src/main/java/com/podio/serialize/LocaleDeserializer.java @@ -1,18 +1,18 @@ -package com.podio.serialize; - -import java.io.IOException; -import java.util.Locale; - -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; - -public class LocaleDeserializer extends JsonDeserializer { - - @Override - public Locale deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - return new Locale(jp.getText()); - } -} +package com.podio.serialize; + +import java.io.IOException; +import java.util.Locale; + +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; + +public class LocaleDeserializer extends JsonDeserializer { + + @Override + public Locale deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + return new Locale(jp.getText()); + } +} diff --git a/src/main/java/com/podio/serialize/LocaleSerializer.java b/src/main/java/com/podio/serialize/LocaleSerializer.java index 7134bbf..2002353 100644 --- a/src/main/java/com/podio/serialize/LocaleSerializer.java +++ b/src/main/java/com/podio/serialize/LocaleSerializer.java @@ -1,20 +1,20 @@ -package com.podio.serialize; - -import java.io.IOException; -import java.util.Locale; - -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; - -public class LocaleSerializer extends JsonSerializer { - - @Override - public void serialize(Locale value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeString(value.getLanguage() + "_" + value.getCountry()); - } - -} +package com.podio.serialize; + +import java.io.IOException; +import java.util.Locale; + +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; + +public class LocaleSerializer extends JsonSerializer { + + @Override + public void serialize(Locale value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(value.getLanguage() + "_" + value.getCountry()); + } + +} diff --git a/src/main/java/com/podio/serialize/TimeZoneDeserializer.java b/src/main/java/com/podio/serialize/TimeZoneDeserializer.java index 453c398..f028091 100644 --- a/src/main/java/com/podio/serialize/TimeZoneDeserializer.java +++ b/src/main/java/com/podio/serialize/TimeZoneDeserializer.java @@ -1,18 +1,18 @@ -package com.podio.serialize; - -import java.io.IOException; -import java.util.TimeZone; - -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.DeserializationContext; -import org.codehaus.jackson.map.JsonDeserializer; - -public class TimeZoneDeserializer extends JsonDeserializer { - - @Override - public TimeZone deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - return TimeZone.getTimeZone(jp.getText()); - } -} +package com.podio.serialize; + +import java.io.IOException; +import java.util.TimeZone; + +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; + +public class TimeZoneDeserializer extends JsonDeserializer { + + @Override + public TimeZone deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + return TimeZone.getTimeZone(jp.getText()); + } +} diff --git a/src/main/java/com/podio/serialize/TimeZoneSerializer.java b/src/main/java/com/podio/serialize/TimeZoneSerializer.java index 5556ce9..80d06f2 100644 --- a/src/main/java/com/podio/serialize/TimeZoneSerializer.java +++ b/src/main/java/com/podio/serialize/TimeZoneSerializer.java @@ -1,20 +1,20 @@ -package com.podio.serialize; - -import java.io.IOException; -import java.util.TimeZone; - -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.map.SerializerProvider; - -public class TimeZoneSerializer extends JsonSerializer { - - @Override - public void serialize(TimeZone value, JsonGenerator jgen, - SerializerProvider provider) throws IOException, - JsonProcessingException { - jgen.writeString(value.getID()); - } - -} +package com.podio.serialize; + +import java.io.IOException; +import java.util.TimeZone; + +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; + +public class TimeZoneSerializer extends JsonSerializer { + + @Override + public void serialize(TimeZone value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(value.getID()); + } + +} diff --git a/src/main/java/com/podio/share/Share.java b/src/main/java/com/podio/share/Share.java index e1e08d3..d8b249e 100644 --- a/src/main/java/com/podio/share/Share.java +++ b/src/main/java/com/podio/share/Share.java @@ -1,66 +1,66 @@ -package com.podio.share; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.common.Role; -import com.podio.contact.ProfileMini; - -public class Share { - - /** - * The user the object was share with - */ - private ProfileMini user; - - /** - * The role the user has to the object - */ - private Role role; - - /** - * The date and time the object was shared - */ - private DateTime grantedOn; - - /** - * The user who shared the item - */ - private ProfileMini grantedBy; - - public ProfileMini getUser() { - return user; - } - - public void setUser(ProfileMini user) { - this.user = user; - } - - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } - - @JsonProperty("granted_on") - public DateTime getGrantedOn() { - return grantedOn; - } - - @JsonProperty("granted_on") - public void setGrantedOn(DateTime grantedOn) { - this.grantedOn = grantedOn; - } - - @JsonProperty("granted_by") - public ProfileMini getGrantedBy() { - return grantedBy; - } - - @JsonProperty("granted_by") - public void setGrantedBy(ProfileMini grantedBy) { - this.grantedBy = grantedBy; - } -} +package com.podio.share; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.common.Role; +import com.podio.contact.ProfileMini; + +public class Share { + + /** + * The user the object was share with + */ + private ProfileMini user; + + /** + * The role the user has to the object + */ + private Role role; + + /** + * The date and time the object was shared + */ + private DateTime grantedOn; + + /** + * The user who shared the item + */ + private ProfileMini grantedBy; + + public ProfileMini getUser() { + return user; + } + + public void setUser(ProfileMini user) { + this.user = user; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + @JsonProperty("granted_on") + public DateTime getGrantedOn() { + return grantedOn; + } + + @JsonProperty("granted_on") + public void setGrantedOn(DateTime grantedOn) { + this.grantedOn = grantedOn; + } + + @JsonProperty("granted_by") + public ProfileMini getGrantedBy() { + return grantedBy; + } + + @JsonProperty("granted_by") + public void setGrantedBy(ProfileMini grantedBy) { + this.grantedBy = grantedBy; + } +} diff --git a/src/main/java/com/podio/space/Space.java b/src/main/java/com/podio/space/Space.java index 3108e65..99508f6 100644 --- a/src/main/java/com/podio/space/Space.java +++ b/src/main/java/com/podio/space/Space.java @@ -1,81 +1,81 @@ -package com.podio.space; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.common.Role; -import com.podio.contact.ProfileMini; - -public class Space extends SpaceMini { - - /** - * true if new apps should be announced with a status update, - * false otherwise - */ - private boolean postOnNewApp; - - /** - * true if new members should be announced with a status - * update, false otherwise - */ - private boolean postOnNewMember; - - /** - * The date and time the space was created - */ - private DateTime createdOn; - - /** - * The user who created the space - */ - private ProfileMini createdBy; - - /** - * The role of the active user on the space - */ - private Role role; - - public boolean isPostOnNewApp() { - return postOnNewApp; - } - - @JsonProperty("post_on_new_app") - public void setPostOnNewApp(boolean postOnNewApp) { - this.postOnNewApp = postOnNewApp; - } - - public boolean isPostOnNewMember() { - return postOnNewMember; - } - - @JsonProperty("post_on_new_member") - public void setPostOnNewMember(boolean postOnNewMember) { - this.postOnNewMember = postOnNewMember; - } - - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } - - public ProfileMini getCreatedBy() { - return createdBy; - } - - @JsonProperty("created_by") - public void setCreatedBy(ProfileMini createdBy) { - this.createdBy = createdBy; - } - - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } -} +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.common.Role; +import com.podio.contact.ProfileMini; + +public class Space extends SpaceMini { + + /** + * true if new apps should be announced with a status update, + * false otherwise + */ + private boolean postOnNewApp; + + /** + * true if new members should be announced with a status + * update, false otherwise + */ + private boolean postOnNewMember; + + /** + * The date and time the space was created + */ + private DateTime createdOn; + + /** + * The user who created the space + */ + private ProfileMini createdBy; + + /** + * The role of the active user on the space + */ + private Role role; + + public boolean isPostOnNewApp() { + return postOnNewApp; + } + + @JsonProperty("post_on_new_app") + public void setPostOnNewApp(boolean postOnNewApp) { + this.postOnNewApp = postOnNewApp; + } + + public boolean isPostOnNewMember() { + return postOnNewMember; + } + + @JsonProperty("post_on_new_member") + public void setPostOnNewMember(boolean postOnNewMember) { + this.postOnNewMember = postOnNewMember; + } + + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } + + public ProfileMini getCreatedBy() { + return createdBy; + } + + @JsonProperty("created_by") + public void setCreatedBy(ProfileMini createdBy) { + this.createdBy = createdBy; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } +} diff --git a/src/main/java/com/podio/space/SpaceCreate.java b/src/main/java/com/podio/space/SpaceCreate.java index 2328303..2368746 100644 --- a/src/main/java/com/podio/space/SpaceCreate.java +++ b/src/main/java/com/podio/space/SpaceCreate.java @@ -1,23 +1,23 @@ -package com.podio.space; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class SpaceCreate extends SpaceUpdate { - - private int orgId; - - public SpaceCreate(String name, boolean postOnNewApp, - boolean postOnNewMember, int orgId) { - super(name, postOnNewApp, postOnNewMember); - this.orgId = orgId; - } - - @JsonProperty("org_id") - public int getOrgId() { - return orgId; - } - - public void setOrgId(int orgId) { - this.orgId = orgId; - } -} +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class SpaceCreate extends SpaceUpdate { + + private int orgId; + + public SpaceCreate(String name, boolean postOnNewApp, + boolean postOnNewMember, int orgId) { + super(name, postOnNewApp, postOnNewMember); + this.orgId = orgId; + } + + @JsonProperty("org_id") + public int getOrgId() { + return orgId; + } + + public void setOrgId(int orgId) { + this.orgId = orgId; + } +} diff --git a/src/main/java/com/podio/space/SpaceCreateResponse.java b/src/main/java/com/podio/space/SpaceCreateResponse.java index e225c38..a7f0c70 100644 --- a/src/main/java/com/podio/space/SpaceCreateResponse.java +++ b/src/main/java/com/podio/space/SpaceCreateResponse.java @@ -1,34 +1,34 @@ -package com.podio.space; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class SpaceCreateResponse { - - /** - * The id of the newly created space - */ - private int id; - - /** - * The full URL of the new space - */ - private String url; - - public int getId() { - return id; - } - - @JsonProperty("space_id") - public void setId(int id) { - this.id = id; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - -} +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class SpaceCreateResponse { + + /** + * The id of the newly created space + */ + private int id; + + /** + * The full URL of the new space + */ + private String url; + + public int getId() { + return id; + } + + @JsonProperty("space_id") + public void setId(int id) { + this.id = id; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + +} diff --git a/src/main/java/com/podio/space/SpaceInvitation.java b/src/main/java/com/podio/space/SpaceInvitation.java index 2b90a0b..ddd3874 100644 --- a/src/main/java/com/podio/space/SpaceInvitation.java +++ b/src/main/java/com/podio/space/SpaceInvitation.java @@ -1,114 +1,114 @@ -package com.podio.space; - -import java.util.List; - -import com.podio.common.Role; - -public class SpaceInvitation { - - /** - * The role of the new users - */ - private Role role; - - /** - * The subject to put in the invitation mail to the users - */ - private String subject; - - /** - * The personalized message to put in the invitation - */ - private String message; - - /** - * true if the invitation should be resend every week, - * false otherwise - */ - private boolean resend; - - /** - * true if the inviter should be notified when the user accepts - * or declines the invitation, false otherwise - */ - private boolean notify; - - /** - * The list of user ids of existing Podio users - */ - private List users; - - /** - * The list of mail addresses for new or existing Podio users - */ - private List mails; - - public SpaceInvitation(Role role, String subject, String message, - boolean resend, boolean notify, List users, - List mails) { - super(); - this.role = role; - this.subject = subject; - this.message = message; - this.resend = resend; - this.notify = notify; - this.users = users; - this.mails = mails; - } - - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public boolean isResend() { - return resend; - } - - public void setResend(boolean resend) { - this.resend = resend; - } - - public boolean isNotify() { - return notify; - } - - public void setNotify(boolean notify) { - this.notify = notify; - } - - public List getUsers() { - return users; - } - - public void setUsers(List users) { - this.users = users; - } - - public List getMails() { - return mails; - } - - public void setMails(List mails) { - this.mails = mails; - } -} +package com.podio.space; + +import java.util.List; + +import com.podio.common.Role; + +public class SpaceInvitation { + + /** + * The role of the new users + */ + private Role role; + + /** + * The subject to put in the invitation mail to the users + */ + private String subject; + + /** + * The personalized message to put in the invitation + */ + private String message; + + /** + * true if the invitation should be resend every week, + * false otherwise + */ + private boolean resend; + + /** + * true if the inviter should be notified when the user accepts + * or declines the invitation, false otherwise + */ + private boolean notify; + + /** + * The list of user ids of existing Podio users + */ + private List users; + + /** + * The list of mail addresses for new or existing Podio users + */ + private List mails; + + public SpaceInvitation(Role role, String subject, String message, + boolean resend, boolean notify, List users, + List mails) { + super(); + this.role = role; + this.subject = subject; + this.message = message; + this.resend = resend; + this.notify = notify; + this.users = users; + this.mails = mails; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isResend() { + return resend; + } + + public void setResend(boolean resend) { + this.resend = resend; + } + + public boolean isNotify() { + return notify; + } + + public void setNotify(boolean notify) { + this.notify = notify; + } + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + + public List getMails() { + return mails; + } + + public void setMails(List mails) { + this.mails = mails; + } +} diff --git a/src/main/java/com/podio/space/SpaceInvitationUpdate.java b/src/main/java/com/podio/space/SpaceInvitationUpdate.java index e100f2e..e01d7e2 100644 --- a/src/main/java/com/podio/space/SpaceInvitationUpdate.java +++ b/src/main/java/com/podio/space/SpaceInvitationUpdate.java @@ -1,36 +1,36 @@ -package com.podio.space; - -public class SpaceInvitationUpdate { - - /** - * The subject to put in the invitation mail to the users - */ - private String subject; - - /** - * The personalized message to put in the invitation - */ - private String message; - - public SpaceInvitationUpdate(String subject, String message) { - super(); - this.subject = subject; - this.message = message; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} +package com.podio.space; + +public class SpaceInvitationUpdate { + + /** + * The subject to put in the invitation mail to the users + */ + private String subject; + + /** + * The personalized message to put in the invitation + */ + private String message; + + public SpaceInvitationUpdate(String subject, String message) { + super(); + this.subject = subject; + this.message = message; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/com/podio/space/SpaceMember.java b/src/main/java/com/podio/space/SpaceMember.java index 9c773ba..d0db1b3 100644 --- a/src/main/java/com/podio/space/SpaceMember.java +++ b/src/main/java/com/podio/space/SpaceMember.java @@ -1,79 +1,80 @@ -package com.podio.space; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.common.Role; -import com.podio.contact.ProfileMini; - -public class SpaceMember { - - /** - * The member of the space - */ - private ProfileMini user; - - /** - * The role that the member has - */ - private Role role; - - /** - * The date and time the user was invited - */ - private DateTime invitedOn; - - /** - * The date and time the user accepted the invitation - */ - private DateTime startedOn; - - /** - * The date and item the membership was ended. Only set if membership is - * ended - */ - private DateTime endedOn; - - public ProfileMini getUser() { - return user; - } - - public void setUser(ProfileMini user) { - this.user = user; - } - - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } - - public DateTime getInvitedOn() { - return invitedOn; - } - - @JsonProperty("invited_on") - public void setInvitedOn(DateTime invitedOn) { - this.invitedOn = invitedOn; - } - - public DateTime getStartedOn() { - return startedOn; - } - - @JsonProperty("started_on") - public void setStartedOn(DateTime startedOn) { - this.startedOn = startedOn; - } - - public DateTime getEndedOn() { - return endedOn; - } - - @JsonProperty("ended_on") - public void setEndedOn(DateTime endedOn) { - this.endedOn = endedOn; - } -} +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.common.Role; +import com.podio.contact.ProfileMini; + +public class SpaceMember { + + /** + * The member of the space + */ + private ProfileMini user; + + /** + * The role that the member has + */ + private Role role; + + /** + * The date and time the user was invited + */ + private DateTime invitedOn; + + /** + * The date and time the user accepted the invitation + */ + private DateTime startedOn; + + /** + * The date and item the membership was ended. Only set if membership is + * ended + */ + private DateTime endedOn; + + public ProfileMini getUser() { + return user; + } + + @JsonProperty("profile") + public void setUser(ProfileMini user) { + this.user = user; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + public DateTime getInvitedOn() { + return invitedOn; + } + + @JsonProperty("invited_on") + public void setInvitedOn(DateTime invitedOn) { + this.invitedOn = invitedOn; + } + + public DateTime getStartedOn() { + return startedOn; + } + + @JsonProperty("started_on") + public void setStartedOn(DateTime startedOn) { + this.startedOn = startedOn; + } + + public DateTime getEndedOn() { + return endedOn; + } + + @JsonProperty("ended_on") + public void setEndedOn(DateTime endedOn) { + this.endedOn = endedOn; + } +} diff --git a/src/main/java/com/podio/space/SpaceMemberAdd.java b/src/main/java/com/podio/space/SpaceMemberAdd.java index 5f447d3..5ba973c 100644 --- a/src/main/java/com/podio/space/SpaceMemberAdd.java +++ b/src/main/java/com/podio/space/SpaceMemberAdd.java @@ -1,200 +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; - } - -} +/** + * 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; + } + +} diff --git a/src/main/java/com/podio/space/SpaceMemberDetails.java b/src/main/java/com/podio/space/SpaceMemberDetails.java index 2ba851a..f930948 100644 --- a/src/main/java/com/podio/space/SpaceMemberDetails.java +++ b/src/main/java/com/podio/space/SpaceMemberDetails.java @@ -1,24 +1,24 @@ -package com.podio.space; - -import com.podio.common.Role; - -public class SpaceMemberDetails { - - private Space space; - - private Role role; - - private int grants; - - public Space getSpace() { - return space; - } - - public Role getRole() { - return role; - } - - public int getGrants() { - return grants; - } -} +package com.podio.space; + +import com.podio.common.Role; + +public class SpaceMemberDetails { + + private Space space; + + private Role role; + + private int grants; + + public Space getSpace() { + return space; + } + + public Role getRole() { + return role; + } + + public int getGrants() { + return grants; + } +} diff --git a/src/main/java/com/podio/space/SpaceMemberUpdate.java b/src/main/java/com/podio/space/SpaceMemberUpdate.java index 849d2ce..0bcc793 100644 --- a/src/main/java/com/podio/space/SpaceMemberUpdate.java +++ b/src/main/java/com/podio/space/SpaceMemberUpdate.java @@ -1,21 +1,21 @@ -package com.podio.space; - -import com.podio.common.Role; - -public class SpaceMemberUpdate { - - private Role role; - - public SpaceMemberUpdate(Role role) { - super(); - this.role = role; - } - - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } -} +package com.podio.space; + +import com.podio.common.Role; + +public class SpaceMemberUpdate { + + private Role role; + + public SpaceMemberUpdate(Role role) { + super(); + this.role = role; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } +} diff --git a/src/main/java/com/podio/space/SpaceMemberV2.java b/src/main/java/com/podio/space/SpaceMemberV2.java index c6b9cf9..89fe6e7 100644 --- a/src/main/java/com/podio/space/SpaceMemberV2.java +++ b/src/main/java/com/podio/space/SpaceMemberV2.java @@ -1,96 +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 setProfile(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; - } -} +/** + * 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 setProfile(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; + } +} diff --git a/src/main/java/com/podio/space/SpaceStatistics.java b/src/main/java/com/podio/space/SpaceStatistics.java index d38a926..8a55704 100644 --- a/src/main/java/com/podio/space/SpaceStatistics.java +++ b/src/main/java/com/podio/space/SpaceStatistics.java @@ -1,87 +1,87 @@ -package com.podio.space; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -public class SpaceStatistics { - - /** - * When the space was created - */ - private DateTime createdOn; - - /** - * The number of active members - */ - private int members; - - /** - * Number of comments - */ - private int comments; - - /** - * Number of active item - */ - private int items; - - /** - * Number of active statuses - */ - private int statuses; - - /** - * Number of active apps - */ - private int apps; - - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } - - public int getMembers() { - return members; - } - - public void setMembers(int members) { - this.members = members; - } - - public int getComments() { - return comments; - } - - public void setComments(int comments) { - this.comments = comments; - } - - public int getItems() { - return items; - } - - public void setItems(int items) { - this.items = items; - } - - public int getStatuses() { - return statuses; - } - - public void setStatuses(int statuses) { - this.statuses = statuses; - } - - public int getApps() { - return apps; - } - - public void setApps(int apps) { - this.apps = apps; - } - -} +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +public class SpaceStatistics { + + /** + * When the space was created + */ + private DateTime createdOn; + + /** + * The number of active members + */ + private int members; + + /** + * Number of comments + */ + private int comments; + + /** + * Number of active item + */ + private int items; + + /** + * Number of active statuses + */ + private int statuses; + + /** + * Number of active apps + */ + private int apps; + + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } + + public int getMembers() { + return members; + } + + public void setMembers(int members) { + this.members = members; + } + + public int getComments() { + return comments; + } + + public void setComments(int comments) { + this.comments = comments; + } + + public int getItems() { + return items; + } + + public void setItems(int items) { + this.items = items; + } + + public int getStatuses() { + return statuses; + } + + public void setStatuses(int statuses) { + this.statuses = statuses; + } + + public int getApps() { + return apps; + } + + public void setApps(int apps) { + this.apps = apps; + } + +} diff --git a/src/main/java/com/podio/space/SpaceTopMemberGroup.java b/src/main/java/com/podio/space/SpaceTopMemberGroup.java index d11268a..28544ff 100644 --- a/src/main/java/com/podio/space/SpaceTopMemberGroup.java +++ b/src/main/java/com/podio/space/SpaceTopMemberGroup.java @@ -1,28 +1,28 @@ -package com.podio.space; - -import java.util.List; - -import com.podio.contact.ProfileMini; - -public class SpaceTopMemberGroup { - - private List profiles; - - private int left; - - public List getProfiles() { - return profiles; - } - - public void setProfiles(List profiles) { - this.profiles = profiles; - } - - public int getLeft() { - return left; - } - - public void setLeft(int left) { - this.left = left; - } -} +package com.podio.space; + +import java.util.List; + +import com.podio.contact.ProfileMini; + +public class SpaceTopMemberGroup { + + private List profiles; + + private int left; + + public List getProfiles() { + return profiles; + } + + public void setProfiles(List profiles) { + this.profiles = profiles; + } + + public int getLeft() { + return left; + } + + public void setLeft(int left) { + this.left = left; + } +} diff --git a/src/main/java/com/podio/space/SpaceTopMembers.java b/src/main/java/com/podio/space/SpaceTopMembers.java index f9c3f5d..7c45dca 100644 --- a/src/main/java/com/podio/space/SpaceTopMembers.java +++ b/src/main/java/com/podio/space/SpaceTopMembers.java @@ -1,24 +1,24 @@ -package com.podio.space; - -public class SpaceTopMembers { - - private SpaceTopMemberGroup employee; - - private SpaceTopMemberGroup external; - - public SpaceTopMemberGroup getEmployee() { - return employee; - } - - public void setEmployee(SpaceTopMemberGroup employee) { - this.employee = employee; - } - - public SpaceTopMemberGroup getExternal() { - return external; - } - - public void setExternal(SpaceTopMemberGroup external) { - this.external = external; - } -} +package com.podio.space; + +public class SpaceTopMembers { + + private SpaceTopMemberGroup employee; + + private SpaceTopMemberGroup external; + + public SpaceTopMemberGroup getEmployee() { + return employee; + } + + public void setEmployee(SpaceTopMemberGroup employee) { + this.employee = employee; + } + + public SpaceTopMemberGroup getExternal() { + return external; + } + + public void setExternal(SpaceTopMemberGroup external) { + this.external = external; + } +} diff --git a/src/main/java/com/podio/space/SpaceUpdate.java b/src/main/java/com/podio/space/SpaceUpdate.java index 084ba99..5caa1de 100644 --- a/src/main/java/com/podio/space/SpaceUpdate.java +++ b/src/main/java/com/podio/space/SpaceUpdate.java @@ -1,57 +1,57 @@ -package com.podio.space; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class SpaceUpdate { - - /** - * The new name of the space - */ - private String name; - - /** - * true if new apps should be announced with a status update, - * false otherwise - */ - private boolean postOnNewApp; - - /** - * true if new members should be announced with a status - * update, false otherwise - */ - private boolean postOnNewMember; - - public SpaceUpdate(String name, boolean postOnNewApp, - boolean postOnNewMember) { - super(); - this.name = name; - this.postOnNewApp = postOnNewApp; - this.postOnNewMember = postOnNewMember; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @JsonProperty("post_on_new_app") - public boolean isPostOnNewApp() { - return postOnNewApp; - } - - public void setPostOnNewApp(boolean postOnNewApp) { - this.postOnNewApp = postOnNewApp; - } - - @JsonProperty("post_on_new_member") - public boolean isPostOnNewMember() { - return postOnNewMember; - } - - public void setPostOnNewMember(boolean postOnNewMember) { - this.postOnNewMember = postOnNewMember; - } -} +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class SpaceUpdate { + + /** + * The new name of the space + */ + private String name; + + /** + * true if new apps should be announced with a status update, + * false otherwise + */ + private boolean postOnNewApp; + + /** + * true if new members should be announced with a status + * update, false otherwise + */ + private boolean postOnNewMember; + + public SpaceUpdate(String name, boolean postOnNewApp, + boolean postOnNewMember) { + super(); + this.name = name; + this.postOnNewApp = postOnNewApp; + this.postOnNewMember = postOnNewMember; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @JsonProperty("post_on_new_app") + public boolean isPostOnNewApp() { + return postOnNewApp; + } + + public void setPostOnNewApp(boolean postOnNewApp) { + this.postOnNewApp = postOnNewApp; + } + + @JsonProperty("post_on_new_member") + public boolean isPostOnNewMember() { + return postOnNewMember; + } + + public void setPostOnNewMember(boolean postOnNewMember) { + this.postOnNewMember = postOnNewMember; + } +} diff --git a/src/main/java/com/podio/space/SpaceWithOrganization.java b/src/main/java/com/podio/space/SpaceWithOrganization.java index b061ab0..d94a531 100644 --- a/src/main/java/com/podio/space/SpaceWithOrganization.java +++ b/src/main/java/com/podio/space/SpaceWithOrganization.java @@ -1,20 +1,20 @@ -package com.podio.space; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.org.OrganizationWithSpaces; - -public class SpaceWithOrganization extends Space { - - private OrganizationWithSpaces organization; - - @JsonProperty("org") - public OrganizationWithSpaces getOrganization() { - return organization; - } - - @JsonProperty("org") - public void setOrganization(OrganizationWithSpaces organization) { - this.organization = organization; - } -} +package com.podio.space; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.org.OrganizationWithSpaces; + +public class SpaceWithOrganization extends Space { + + private OrganizationWithSpaces organization; + + @JsonProperty("org") + public OrganizationWithSpaces getOrganization() { + return organization; + } + + @JsonProperty("org") + public void setOrganization(OrganizationWithSpaces organization) { + this.organization = organization; + } +} diff --git a/src/main/java/com/podio/status/Status.java b/src/main/java/com/podio/status/Status.java index 4ee14db..f3a8eb4 100644 --- a/src/main/java/com/podio/status/Status.java +++ b/src/main/java/com/podio/status/Status.java @@ -1,38 +1,38 @@ -package com.podio.status; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.common.CreatedBase; - -/** - * A status message posted by a user to a space - */ -public class Status extends CreatedBase { - - private int statusId; - - private String value; - - /** - * @return The id of the status - */ - public int getStatusId() { - return statusId; - } - - @JsonProperty("status_id") - public void setStatusId(int statusId) { - this.statusId = statusId; - } - - /** - * @return The actual status message - */ - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} +package com.podio.status; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.CreatedBase; + +/** + * A status message posted by a user to a space + */ +public class Status extends CreatedBase { + + private int statusId; + + private String value; + + /** + * @return The id of the status + */ + public int getStatusId() { + return statusId; + } + + @JsonProperty("status_id") + public void setStatusId(int statusId) { + this.statusId = statusId; + } + + /** + * @return The actual status message + */ + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/com/podio/status/StatusAPI.java b/src/main/java/com/podio/status/StatusAPI.java index 4f73e01..79909ac 100644 --- a/src/main/java/com/podio/status/StatusAPI.java +++ b/src/main/java/com/podio/status/StatusAPI.java @@ -1,77 +1,77 @@ -package com.podio.status; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; - -/** - * Status messages are small texts that the users wishes to share with the other - * users in a space. It can be anything from a note that the user will be in - * later today over links to interesting resources and information about what - * the user is working on a the moment. - * - * Other users can comment on a status message and indicate that they like the - * status message. - */ -public class StatusAPI extends BaseAPI { - - public StatusAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Creates a new status message for a user on a specific space. A status - * update is simply a short text message that the user wishes to share with - * the rest of the space. - * - * @param status - * The data for the new status message - * @return The id of the newly created status message - */ - public int createStatus(int spaceId, StatusCreate status) { - return getResourceFactory() - .getApiResource("/status/space/" + spaceId + "/") - .entity(status, MediaType.APPLICATION_JSON_TYPE) - .post(StatusCreateResponse.class).getId(); - } - - /** - * This is used to delete a status message. This is normally only done if - * the user regrets his status update. After deletion the status message - * will no longer be viewable by anyone. - * - * @param statusId - * The id of the status to delete - */ - public void deleteStatus(int statusId) { - getResourceFactory().getApiResource("/status/" + statusId).delete(); - } - - /** - * Retrieves a status message by its id. The id of the status message is - * usually gotten from the stream. - * - * @param statusId - * The id of the status - * @return The status message - */ - public StatusFull getStatus(int statusId) { - return getResourceFactory().getApiResource("/status/" + statusId).get( - StatusFull.class); - } - - /** - * This will update an existing status message. This will normally only be - * used to correct spelling and grammatical mistakes. - * - * @param statusId - * The id of the status to be updated - * @param update - * The new data for the status - */ - public void updateStatus(int statusId, StatusUpdate update) { - getResourceFactory().getApiResource("/status/" + statusId) - .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); - } -} +package com.podio.status; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; + +/** + * Status messages are small texts that the users wishes to share with the other + * users in a space. It can be anything from a note that the user will be in + * later today over links to interesting resources and information about what + * the user is working on a the moment. + * + * Other users can comment on a status message and indicate that they like the + * status message. + */ +public class StatusAPI extends BaseAPI { + + public StatusAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Creates a new status message for a user on a specific space. A status + * update is simply a short text message that the user wishes to share with + * the rest of the space. + * + * @param status + * The data for the new status message + * @return The id of the newly created status message + */ + public int createStatus(int spaceId, StatusCreate status) { + return getResourceFactory() + .getApiResource("/status/space/" + spaceId + "/") + .entity(status, MediaType.APPLICATION_JSON_TYPE) + .post(StatusCreateResponse.class).getId(); + } + + /** + * This is used to delete a status message. This is normally only done if + * the user regrets his status update. After deletion the status message + * will no longer be viewable by anyone. + * + * @param statusId + * The id of the status to delete + */ + public void deleteStatus(int statusId) { + getResourceFactory().getApiResource("/status/" + statusId).delete(); + } + + /** + * Retrieves a status message by its id. The id of the status message is + * usually gotten from the stream. + * + * @param statusId + * The id of the status + * @return The status message + */ + public StatusFull getStatus(int statusId) { + return getResourceFactory().getApiResource("/status/" + statusId).get( + StatusFull.class); + } + + /** + * This will update an existing status message. This will normally only be + * used to correct spelling and grammatical mistakes. + * + * @param statusId + * The id of the status to be updated + * @param update + * The new data for the status + */ + public void updateStatus(int statusId, StatusUpdate update) { + getResourceFactory().getApiResource("/status/" + statusId) + .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); + } +} diff --git a/src/main/java/com/podio/status/StatusCreate.java b/src/main/java/com/podio/status/StatusCreate.java index 5cb97ed..f346947 100644 --- a/src/main/java/com/podio/status/StatusCreate.java +++ b/src/main/java/com/podio/status/StatusCreate.java @@ -1,71 +1,71 @@ -package com.podio.status; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class StatusCreate { - - private String value; - - private List alerts; - - private List fileIds; - - public StatusCreate() { - super(); - } - - public StatusCreate(String value, List alerts, - List fileIds) { - super(); - this.value = value; - this.alerts = alerts; - this.fileIds = fileIds; - } - - public String getValue() { - return value; - } - - /** - * Sets the text value of the status message - * - * @param value - * The text of the status - */ - public void setValue(String value) { - this.value = value; - } - - public List getAlerts() { - return alerts; - } - - /** - * Sets the list of users to alert in this status updated - * - * @param alerts - * The ids of the users to alert - */ - public void setAlerts(List alerts) { - this.alerts = alerts; - } - - @JsonProperty("file_ids") - public List getFileIds() { - return fileIds; - } - - /** - * Sets the files to attach to this status message - * - * @param fileIds - * The id of the files already uploaded that should be attached - * to this status - */ - public void setFileIds(List fileIds) { - this.fileIds = fileIds; - } - -} +package com.podio.status; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class StatusCreate { + + private String value; + + private List alerts; + + private List fileIds; + + public StatusCreate() { + super(); + } + + public StatusCreate(String value, List alerts, + List fileIds) { + super(); + this.value = value; + this.alerts = alerts; + this.fileIds = fileIds; + } + + public String getValue() { + return value; + } + + /** + * Sets the text value of the status message + * + * @param value + * The text of the status + */ + public void setValue(String value) { + this.value = value; + } + + public List getAlerts() { + return alerts; + } + + /** + * Sets the list of users to alert in this status updated + * + * @param alerts + * The ids of the users to alert + */ + public void setAlerts(List alerts) { + this.alerts = alerts; + } + + @JsonProperty("file_ids") + public List getFileIds() { + return fileIds; + } + + /** + * Sets the files to attach to this status message + * + * @param fileIds + * The id of the files already uploaded that should be attached + * to this status + */ + public void setFileIds(List fileIds) { + this.fileIds = fileIds; + } + +} diff --git a/src/main/java/com/podio/status/StatusCreateResponse.java b/src/main/java/com/podio/status/StatusCreateResponse.java index c14c8a8..75d571b 100644 --- a/src/main/java/com/podio/status/StatusCreateResponse.java +++ b/src/main/java/com/podio/status/StatusCreateResponse.java @@ -1,18 +1,18 @@ -package com.podio.status; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class StatusCreateResponse { - - private int id; - - @JsonProperty("status_id") - public int getId() { - return id; - } - - @JsonProperty("status_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.status; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class StatusCreateResponse { + + private int id; + + @JsonProperty("status_id") + public int getId() { + return id; + } + + @JsonProperty("status_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/status/StatusFull.java b/src/main/java/com/podio/status/StatusFull.java index cbd361b..94adbbb 100644 --- a/src/main/java/com/podio/status/StatusFull.java +++ b/src/main/java/com/podio/status/StatusFull.java @@ -1,91 +1,91 @@ -package com.podio.status; - -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonDeserialize; - -import com.podio.comment.Comment; -import com.podio.file.File; -import com.podio.rating.RatingType; -import com.podio.rating.RatingTypeKeyDeserializer; -import com.podio.rating.RatingValuesMap; - -/** - * A status message posted by a user to a space - */ -public class StatusFull extends Status { - - /** - * All the comments on the status - */ - private List comments; - - /** - * The ratings on the status - */ - private RatingValuesMap ratings; - - /** - * The files on the status - */ - private List files; - - /** - * true if the user is subscribed to the item, - * false otherwise - */ - private boolean subscribed; - - /** - * The ratings and their values done by the active user on the status - */ - private Map userRatings; - - public List getComments() { - return comments; - } - - public void setComments(List comments) { - this.comments = comments; - } - - public RatingValuesMap getRatings() { - return ratings; - } - - public void setRatings(RatingValuesMap ratings) { - this.ratings = ratings; - } - - public List getFiles() { - return files; - } - - public void setFiles(List files) { - this.files = files; - } - - public boolean isSubscribed() { - return subscribed; - } - - public void setSubscribed(boolean subscribed) { - this.subscribed = subscribed; - } - - public Integer getUserRating(RatingType type) { - return userRatings.get(type); - } - - public Map getUserRatings() { - return userRatings; - } - - @JsonDeserialize(keyUsing = RatingTypeKeyDeserializer.class) - @JsonProperty("user_ratings") - public void setUserRatings(Map userRatings) { - this.userRatings = userRatings; - } -} +package com.podio.status; + +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonDeserialize; + +import com.podio.comment.Comment; +import com.podio.file.File; +import com.podio.rating.RatingType; +import com.podio.rating.RatingTypeKeyDeserializer; +import com.podio.rating.RatingValuesMap; + +/** + * A status message posted by a user to a space + */ +public class StatusFull extends Status { + + /** + * All the comments on the status + */ + private List comments; + + /** + * The ratings on the status + */ + private RatingValuesMap ratings; + + /** + * The files on the status + */ + private List files; + + /** + * true if the user is subscribed to the item, + * false otherwise + */ + private boolean subscribed; + + /** + * The ratings and their values done by the active user on the status + */ + private Map userRatings; + + public List getComments() { + return comments; + } + + public void setComments(List comments) { + this.comments = comments; + } + + public RatingValuesMap getRatings() { + return ratings; + } + + public void setRatings(RatingValuesMap ratings) { + this.ratings = ratings; + } + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + public boolean isSubscribed() { + return subscribed; + } + + public void setSubscribed(boolean subscribed) { + this.subscribed = subscribed; + } + + public Integer getUserRating(RatingType type) { + return userRatings.get(type); + } + + public Map getUserRatings() { + return userRatings; + } + + @JsonDeserialize(keyUsing = RatingTypeKeyDeserializer.class) + @JsonProperty("user_ratings") + public void setUserRatings(Map userRatings) { + this.userRatings = userRatings; + } +} diff --git a/src/main/java/com/podio/status/StatusUpdate.java b/src/main/java/com/podio/status/StatusUpdate.java index 9fda4ee..9cce160 100644 --- a/src/main/java/com/podio/status/StatusUpdate.java +++ b/src/main/java/com/podio/status/StatusUpdate.java @@ -1,52 +1,52 @@ -package com.podio.status; - -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class StatusUpdate { - - private String value; - - private List fileIds; - - public StatusUpdate() { - super(); - } - - public StatusUpdate(String value, List fileIds) { - super(); - this.value = value; - this.fileIds = fileIds; - } - - public String getValue() { - return value; - } - - /** - * Sets the text value of the status message - * - * @param value - * The text of the status - */ - public void setValue(String value) { - this.value = value; - } - - @JsonProperty("file_ids") - public List getFileIds() { - return fileIds; - } - - /** - * Sets the files to attach to this status message - * - * @param fileIds - * The id of the files already uploaded that should be attached - * to this status - */ - public void setFileIds(List fileIds) { - this.fileIds = fileIds; - } -} +package com.podio.status; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class StatusUpdate { + + private String value; + + private List fileIds; + + public StatusUpdate() { + super(); + } + + public StatusUpdate(String value, List fileIds) { + super(); + this.value = value; + this.fileIds = fileIds; + } + + public String getValue() { + return value; + } + + /** + * Sets the text value of the status message + * + * @param value + * The text of the status + */ + public void setValue(String value) { + this.value = value; + } + + @JsonProperty("file_ids") + public List getFileIds() { + return fileIds; + } + + /** + * Sets the files to attach to this status message + * + * @param fileIds + * The id of the files already uploaded that should be attached + * to this status + */ + public void setFileIds(List fileIds) { + this.fileIds = fileIds; + } +} diff --git a/src/main/java/com/podio/stream/StreamAPI.java b/src/main/java/com/podio/stream/StreamAPI.java index e66d063..f6eafe7 100644 --- a/src/main/java/com/podio/stream/StreamAPI.java +++ b/src/main/java/com/podio/stream/StreamAPI.java @@ -1,247 +1,247 @@ -package com.podio.stream; - -import java.util.List; - -import org.joda.time.DateTime; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.Reference; -import com.podio.serialize.DateTimeUtil; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; - -/** - * Subscriptions allows the user to be notified when an object is created, - * updated, delete, comments added to it or rated. - */ -public class StreamAPI extends BaseAPI { - - public StreamAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Returns an object (item or status) as a stream object. This is useful - * when a new status has been posted and should be rendered directly in the - * stream without reloading the entire stream. - * - * @param reference - * The reference to the item - * @return The stream object - */ - public StreamObject getStreamObject(Reference reference) { - return getResourceFactory().getApiResource( - "/stream/" + reference.toURLFragment(false)).get( - StreamObject.class); - } - - /** - * Returns an object (item or status) as a stream object. This is useful - * when a new status has been posted and should be rendered directly in the - * stream without reloading the entire stream. - * - * @param reference - * The reference to the item - * @return The stream object - */ - public StreamObjectV2 getStreamObjectV2(Reference reference) { - return getResourceFactory().getApiResource( - "/stream/" + reference.toURLFragment(false) + "/v2").get( - StreamObjectV2.class); - } - - /** - * Returns the global stream. This includes items and statuses with - * comments, ratings, files and edits. - * - * @param limit - * How many objects should be returned, defaults to 10 - * @param offset - * How far should the objects be offset, defaults to 0 - * @param dateFrom - * The date and time that all events should be after, defaults to - * no limit - * @param dateTo - * The date and time that all events should be before, defaults - * to no limit - * @return The list of stream objects - */ - public List getGlobalStream(Integer limit, Integer offset, - DateTime dateFrom, DateTime dateTo) { - return getStream("/stream/", limit, offset, dateFrom, dateTo); - } - - /** - * Returns the global stream. The types of objects in the stream can be - * either "item", "status" or "task". - * - * @param limit - * How many objects should be returned, defaults to 10 - * @param offset - * How far should the objects be offset, defaults to 0 - * @param dateFrom - * The date and time that all events should be after, defaults to - * no limit - * @param dateTo - * The date and time that all events should be before, defaults - * to no limit - * @return The list of stream objects - */ - public List getGlobalStreamV2(Integer limit, - Integer offset, DateTime dateFrom, DateTime dateTo) { - return getStreamV2("/stream/v2/", limit, offset, dateFrom, dateTo); - } - - /** - * Returns the stream for the organization. Is identical to the global - * stream, but only returns objects in the organization. - * - * @param limit - * How many objects should be returned, defaults to 10 - * @param offset - * How far should the objects be offset, defaults to 0 - * @param dateFrom - * The date and time that all events should be after, defaults to - * no limit - * @param dateTo - * The date and time that all events should be before, defaults - * to no limit - * @return The list of stream objects - */ - public List getOrganizationStream(int orgId, Integer limit, - Integer offset, DateTime dateFrom, DateTime dateTo) { - return getStream("/stream/org/" + orgId + "/", limit, offset, dateFrom, - dateTo); - } - - /** - * Returns the stream for the organization. Is identical to the global - * stream, but only returns objects in the organization. - * - * @param limit - * How many objects should be returned, defaults to 10 - * @param offset - * How far should the objects be offset, defaults to 0 - * @param dateFrom - * The date and time that all events should be after, defaults to - * no limit - * @param dateTo - * The date and time that all events should be before, defaults - * to no limit - * @return The list of stream objects - */ - public List getOrganizationStreamV2(int orgId, - Integer limit, Integer offset, DateTime dateFrom, DateTime dateTo) { - return getStreamV2("/stream/org/" + orgId + "/v2/", limit, offset, - dateFrom, dateTo); - } - - /** - * Returns the stream for the space. Is identical to the global stream, but - * only returns objects in the space. - * - * @param limit - * How many objects should be returned, defaults to 10 - * @param offset - * How far should the objects be offset, defaults to 0 - * @param dateFrom - * The date and time that all events should be after, defaults to - * no limit - * @param dateTo - * The date and time that all events should be before, defaults - * to no limit - * @return The list of stream objects - */ - public List getSpaceStream(int spaceId, Integer limit, - Integer offset, DateTime dateFrom, DateTime dateTo) { - return getStream("/stream/space/" + spaceId + "/", limit, offset, - dateFrom, dateTo); - } - - /** - * Returns the stream for the space. Is identical to the global stream, but - * only returns objects in the space. - * - * @param limit - * How many objects should be returned, defaults to 10 - * @param offset - * How far should the objects be offset, defaults to 0 - * @param dateFrom - * The date and time that all events should be after, defaults to - * no limit - * @param dateTo - * The date and time that all events should be before, defaults - * to no limit - * @return The list of stream objects - */ - public List getSpaceStreamV2(int spaceId, Integer limit, - Integer offset, DateTime dateFrom, DateTime dateTo) { - return getStreamV2("/stream/space/" + spaceId + "/v2/", limit, offset, - dateFrom, dateTo); - } - - /** - * Returns the stream for the app. Is identical to the global stream, but - * only returns objects in the app. - * - * @param limit - * How many objects should be returned, defaults to 10 - * @param offset - * How far should the objects be offset, defaults to 0 - * @param dateFrom - * The date and time that all events should be after, defaults to - * no limit - * @param dateTo - * The date and time that all events should be before, defaults - * to no limit - * @return The list of stream objects - */ - public List getAppStream(int appId, Integer limit, - Integer offset) { - return getStreamV2("/stream/app/" + appId + "/", limit, offset, null, - null); - } - - private List getStream(String path, Integer limit, - Integer offset, DateTime dateFrom, DateTime dateTo) { - WebResource resource = getResourceFactory().getApiResource(path); - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - if (offset != null) { - resource = resource.queryParam("offset", offset.toString()); - } - if (dateFrom != null) { - resource = resource.queryParam("date_from", - DateTimeUtil.formatDateTime(dateFrom)); - } - if (dateTo != null) { - resource = resource.queryParam("date_to", - DateTimeUtil.formatDateTime(dateTo)); - } - return resource.get(new GenericType>() { - }); - } - - private List getStreamV2(String path, Integer limit, - Integer offset, DateTime dateFrom, DateTime dateTo) { - WebResource resource = getResourceFactory().getApiResource(path); - if (limit != null) { - resource = resource.queryParam("limit", limit.toString()); - } - if (offset != null) { - resource = resource.queryParam("offset", offset.toString()); - } - if (dateFrom != null) { - resource = resource.queryParam("date_from", - DateTimeUtil.formatDateTime(dateFrom)); - } - if (dateTo != null) { - resource = resource.queryParam("date_to", - DateTimeUtil.formatDateTime(dateTo)); - } - return resource.get(new GenericType>() { - }); - } -} +package com.podio.stream; + +import java.util.List; + +import org.joda.time.DateTime; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.Reference; +import com.podio.serialize.DateTimeUtil; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; + +/** + * Subscriptions allows the user to be notified when an object is created, + * updated, delete, comments added to it or rated. + */ +public class StreamAPI extends BaseAPI { + + public StreamAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Returns an object (item or status) as a stream object. This is useful + * when a new status has been posted and should be rendered directly in the + * stream without reloading the entire stream. + * + * @param reference + * The reference to the item + * @return The stream object + */ + public StreamObject getStreamObject(Reference reference) { + return getResourceFactory().getApiResource( + "/stream/" + reference.toURLFragment(false)).get( + StreamObject.class); + } + + /** + * Returns an object (item or status) as a stream object. This is useful + * when a new status has been posted and should be rendered directly in the + * stream without reloading the entire stream. + * + * @param reference + * The reference to the item + * @return The stream object + */ + public StreamObjectV2 getStreamObjectV2(Reference reference) { + return getResourceFactory().getApiResource( + "/stream/" + reference.toURLFragment(false) + "/v2").get( + StreamObjectV2.class); + } + + /** + * Returns the global stream. This includes items and statuses with + * comments, ratings, files and edits. + * + * @param limit + * How many objects should be returned, defaults to 10 + * @param offset + * How far should the objects be offset, defaults to 0 + * @param dateFrom + * The date and time that all events should be after, defaults to + * no limit + * @param dateTo + * The date and time that all events should be before, defaults + * to no limit + * @return The list of stream objects + */ + public List getGlobalStream(Integer limit, Integer offset, + DateTime dateFrom, DateTime dateTo) { + return getStream("/stream/", limit, offset, dateFrom, dateTo); + } + + /** + * Returns the global stream. The types of objects in the stream can be + * either "item", "status" or "task". + * + * @param limit + * How many objects should be returned, defaults to 10 + * @param offset + * How far should the objects be offset, defaults to 0 + * @param dateFrom + * The date and time that all events should be after, defaults to + * no limit + * @param dateTo + * The date and time that all events should be before, defaults + * to no limit + * @return The list of stream objects + */ + public List getGlobalStreamV2(Integer limit, + Integer offset, DateTime dateFrom, DateTime dateTo) { + return getStreamV2("/stream/v2/", limit, offset, dateFrom, dateTo); + } + + /** + * Returns the stream for the organization. Is identical to the global + * stream, but only returns objects in the organization. + * + * @param limit + * How many objects should be returned, defaults to 10 + * @param offset + * How far should the objects be offset, defaults to 0 + * @param dateFrom + * The date and time that all events should be after, defaults to + * no limit + * @param dateTo + * The date and time that all events should be before, defaults + * to no limit + * @return The list of stream objects + */ + public List getOrganizationStream(int orgId, Integer limit, + Integer offset, DateTime dateFrom, DateTime dateTo) { + return getStream("/stream/org/" + orgId + "/", limit, offset, dateFrom, + dateTo); + } + + /** + * Returns the stream for the organization. Is identical to the global + * stream, but only returns objects in the organization. + * + * @param limit + * How many objects should be returned, defaults to 10 + * @param offset + * How far should the objects be offset, defaults to 0 + * @param dateFrom + * The date and time that all events should be after, defaults to + * no limit + * @param dateTo + * The date and time that all events should be before, defaults + * to no limit + * @return The list of stream objects + */ + public List getOrganizationStreamV2(int orgId, + Integer limit, Integer offset, DateTime dateFrom, DateTime dateTo) { + return getStreamV2("/stream/org/" + orgId + "/v2/", limit, offset, + dateFrom, dateTo); + } + + /** + * Returns the stream for the space. Is identical to the global stream, but + * only returns objects in the space. + * + * @param limit + * How many objects should be returned, defaults to 10 + * @param offset + * How far should the objects be offset, defaults to 0 + * @param dateFrom + * The date and time that all events should be after, defaults to + * no limit + * @param dateTo + * The date and time that all events should be before, defaults + * to no limit + * @return The list of stream objects + */ + public List getSpaceStream(int spaceId, Integer limit, + Integer offset, DateTime dateFrom, DateTime dateTo) { + return getStream("/stream/space/" + spaceId + "/", limit, offset, + dateFrom, dateTo); + } + + /** + * Returns the stream for the space. Is identical to the global stream, but + * only returns objects in the space. + * + * @param limit + * How many objects should be returned, defaults to 10 + * @param offset + * How far should the objects be offset, defaults to 0 + * @param dateFrom + * The date and time that all events should be after, defaults to + * no limit + * @param dateTo + * The date and time that all events should be before, defaults + * to no limit + * @return The list of stream objects + */ + public List getSpaceStreamV2(int spaceId, Integer limit, + Integer offset, DateTime dateFrom, DateTime dateTo) { + return getStreamV2("/stream/space/" + spaceId + "/v2/", limit, offset, + dateFrom, dateTo); + } + + /** + * Returns the stream for the app. Is identical to the global stream, but + * only returns objects in the app. + * + * @param limit + * How many objects should be returned, defaults to 10 + * @param offset + * How far should the objects be offset, defaults to 0 + * @param dateFrom + * The date and time that all events should be after, defaults to + * no limit + * @param dateTo + * The date and time that all events should be before, defaults + * to no limit + * @return The list of stream objects + */ + public List getAppStream(int appId, Integer limit, + Integer offset) { + return getStreamV2("/stream/app/" + appId + "/", limit, offset, null, + null); + } + + private List getStream(String path, Integer limit, + Integer offset, DateTime dateFrom, DateTime dateTo) { + WebResource resource = getResourceFactory().getApiResource(path); + if (limit != null) { + resource = resource.queryParam("limit", limit.toString()); + } + if (offset != null) { + resource = resource.queryParam("offset", offset.toString()); + } + if (dateFrom != null) { + resource = resource.queryParam("date_from", + DateTimeUtil.formatDateTime(dateFrom)); + } + if (dateTo != null) { + resource = resource.queryParam("date_to", + DateTimeUtil.formatDateTime(dateTo)); + } + return resource.get(new GenericType>() { + }); + } + + private List getStreamV2(String path, Integer limit, + Integer offset, DateTime dateFrom, DateTime dateTo) { + WebResource resource = getResourceFactory().getApiResource(path); + if (limit != null) { + resource = resource.queryParam("limit", limit.toString()); + } + if (offset != null) { + resource = resource.queryParam("offset", offset.toString()); + } + if (dateFrom != null) { + resource = resource.queryParam("date_from", + DateTimeUtil.formatDateTime(dateFrom)); + } + if (dateTo != null) { + resource = resource.queryParam("date_to", + DateTimeUtil.formatDateTime(dateTo)); + } + return resource.get(new GenericType>() { + }); + } +} diff --git a/src/main/java/com/podio/stream/StreamActivity.java b/src/main/java/com/podio/stream/StreamActivity.java index 3fa030d..f84ff1b 100644 --- a/src/main/java/com/podio/stream/StreamActivity.java +++ b/src/main/java/com/podio/stream/StreamActivity.java @@ -1,64 +1,64 @@ -package com.podio.stream; - -import java.util.HashMap; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.common.CreatedBase; -import com.podio.common.ReferenceType; - -public class StreamActivity extends CreatedBase { - - /** - * The type of object - */ - private ReferenceType type; - - /** - * The id of the object - */ - private int id; - - /** - * The type of activity - */ - private StreamActivityType activityType; - - /** - * The object itself in short form - */ - private HashMap data; - - public ReferenceType getType() { - return type; - } - - public void setType(ReferenceType type) { - this.type = type; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public StreamActivityType getActivityType() { - return activityType; - } - - @JsonProperty("activity_type") - public void setActivityType(StreamActivityType activityType) { - this.activityType = activityType; - } - - public HashMap getData() { - return data; - } - - public void setData(HashMap data) { - this.data = data; - } -} +package com.podio.stream; + +import java.util.HashMap; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.common.CreatedBase; +import com.podio.common.ReferenceType; + +public class StreamActivity extends CreatedBase { + + /** + * The type of object + */ + private ReferenceType type; + + /** + * The id of the object + */ + private int id; + + /** + * The type of activity + */ + private StreamActivityType activityType; + + /** + * The object itself in short form + */ + private HashMap data; + + public ReferenceType getType() { + return type; + } + + public void setType(ReferenceType type) { + this.type = type; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public StreamActivityType getActivityType() { + return activityType; + } + + @JsonProperty("activity_type") + public void setActivityType(StreamActivityType activityType) { + this.activityType = activityType; + } + + public HashMap getData() { + return data; + } + + public void setData(HashMap data) { + this.data = data; + } +} diff --git a/src/main/java/com/podio/stream/StreamActivityType.java b/src/main/java/com/podio/stream/StreamActivityType.java index bd390cb..53e1644 100644 --- a/src/main/java/com/podio/stream/StreamActivityType.java +++ b/src/main/java/com/podio/stream/StreamActivityType.java @@ -1,20 +1,20 @@ -package com.podio.stream; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum StreamActivityType { - - COMMENT, FILE, TASK, RATING, CREATION, UPDATE, ANSWER, MEETING, REFERENCE, GRANT, PARTICIPATION, VOTE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static StreamActivityType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.stream; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum StreamActivityType { + + COMMENT, FILE, TASK, RATING, CREATION, UPDATE, ANSWER, MEETING, REFERENCE, GRANT, PARTICIPATION, VOTE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static StreamActivityType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/stream/StreamObject.java b/src/main/java/com/podio/stream/StreamObject.java index 5f3ffbd..37408b3 100644 --- a/src/main/java/com/podio/stream/StreamObject.java +++ b/src/main/java/com/podio/stream/StreamObject.java @@ -1,163 +1,163 @@ -package com.podio.stream; - -import java.util.HashMap; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.comment.Comment; -import com.podio.common.ReferenceType; -import com.podio.file.File; -import com.podio.item.ItemRevision; -import com.podio.org.OrganizationMini; -import com.podio.rating.Rating; -import com.podio.space.SpaceMini; - -public class StreamObject { - - /** - * The type of object, either {@link ReferenceType.STATUS} or - * {@link ReferenceType.ITEM} - */ - private ReferenceType type; - - /** - * The id of the object - */ - private int id; - - /** - * The object itself in short form - */ - private HashMap object; - - /** - * true if comments are allowed, false otherwise - */ - private boolean allowComments; - - /** - * The space the object belongs to - */ - private SpaceMini space; - - /** - * The organization the object belongs to - */ - private OrganizationMini organization; - - /** - * The link to the object - */ - private String link; - - /** - * The comments on the object - */ - private List comments; - - /** - * Ratings within the last week - */ - private List ratings; - - /** - * Files attached to the object - */ - private List files; - - /** - * Revisions of the object, only valid for items - */ - private List revisions; - - public ReferenceType getType() { - return type; - } - - public void setType(ReferenceType type) { - this.type = type; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public HashMap getObject() { - return object; - } - - public void setObject(HashMap object) { - this.object = object; - } - - public boolean isAllowComments() { - return allowComments; - } - - @JsonProperty("allow_comments") - public void setAllowComments(boolean allowComments) { - this.allowComments = allowComments; - } - - public SpaceMini getSpace() { - return space; - } - - public void setSpace(SpaceMini space) { - this.space = space; - } - - public OrganizationMini getOrganization() { - return organization; - } - - @JsonProperty("org") - public void setOrganization(OrganizationMini organization) { - this.organization = organization; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public List getComments() { - return comments; - } - - public void setComments(List comments) { - this.comments = comments; - } - - public List getRatings() { - return ratings; - } - - public void setRatings(List ratings) { - this.ratings = ratings; - } - - public List getFiles() { - return files; - } - - public void setFiles(List files) { - this.files = files; - } - - public List getRevisions() { - return revisions; - } - - public void setRevisions(List revisions) { - this.revisions = revisions; - } -} +package com.podio.stream; + +import java.util.HashMap; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.comment.Comment; +import com.podio.common.ReferenceType; +import com.podio.file.File; +import com.podio.item.ItemRevision; +import com.podio.org.OrganizationMini; +import com.podio.rating.Rating; +import com.podio.space.SpaceMini; + +public class StreamObject { + + /** + * The type of object, either {@link ReferenceType.STATUS} or + * {@link ReferenceType.ITEM} + */ + private ReferenceType type; + + /** + * The id of the object + */ + private int id; + + /** + * The object itself in short form + */ + private HashMap object; + + /** + * true if comments are allowed, false otherwise + */ + private boolean allowComments; + + /** + * The space the object belongs to + */ + private SpaceMini space; + + /** + * The organization the object belongs to + */ + private OrganizationMini organization; + + /** + * The link to the object + */ + private String link; + + /** + * The comments on the object + */ + private List comments; + + /** + * Ratings within the last week + */ + private List ratings; + + /** + * Files attached to the object + */ + private List files; + + /** + * Revisions of the object, only valid for items + */ + private List revisions; + + public ReferenceType getType() { + return type; + } + + public void setType(ReferenceType type) { + this.type = type; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public HashMap getObject() { + return object; + } + + public void setObject(HashMap object) { + this.object = object; + } + + public boolean isAllowComments() { + return allowComments; + } + + @JsonProperty("allow_comments") + public void setAllowComments(boolean allowComments) { + this.allowComments = allowComments; + } + + public SpaceMini getSpace() { + return space; + } + + public void setSpace(SpaceMini space) { + this.space = space; + } + + public OrganizationMini getOrganization() { + return organization; + } + + @JsonProperty("org") + public void setOrganization(OrganizationMini organization) { + this.organization = organization; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public List getComments() { + return comments; + } + + public void setComments(List comments) { + this.comments = comments; + } + + public List getRatings() { + return ratings; + } + + public void setRatings(List ratings) { + this.ratings = ratings; + } + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + public List getRevisions() { + return revisions; + } + + public void setRevisions(List revisions) { + this.revisions = revisions; + } +} diff --git a/src/main/java/com/podio/stream/StreamObjectV2.java b/src/main/java/com/podio/stream/StreamObjectV2.java index c68142e..f02bb15 100644 --- a/src/main/java/com/podio/stream/StreamObjectV2.java +++ b/src/main/java/com/podio/stream/StreamObjectV2.java @@ -1,206 +1,206 @@ -package com.podio.stream; - -import java.util.HashMap; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.app.Application; -import com.podio.comment.Comment; -import com.podio.common.CreatedBase; -import com.podio.common.ReferenceType; -import com.podio.common.Right; -import com.podio.file.File; -import com.podio.org.OrganizationMini; -import com.podio.space.SpaceMini; - -public class StreamObjectV2 extends CreatedBase { - - /** - * The type of object, either {@link ReferenceType.STATUS}, - * {@link ReferenceType.ITEM} or {@link ReferenceType.TASK} - */ - private ReferenceType type; - - /** - * The id of the object - */ - private int id; - - /** - * The date and time the object was last updated - */ - private DateTime lastUpdateOn; - - /** - * The title of the object - */ - private String title; - - /** - * The link to the object - */ - private String link; - - /** - * The list of user rights on the status - */ - private List rights; - - /** - * The object itself in short form - */ - private HashMap data; - - /** - * true if comments are allowed, false otherwise - */ - private boolean commentsAllowed; - - /** - * The app this object belongs to, if any, - */ - private Application app; - - /** - * The space the object belongs to - */ - private SpaceMini space; - - /** - * The organization the object belongs to - */ - private OrganizationMini organization; - - /** - * The comments on the object - */ - private List comments; - - /** - * Files attached to the object - */ - private List files; - - /** - * The list of recent activities on the object - */ - private List activities; - - public ReferenceType getType() { - return type; - } - - public void setType(ReferenceType type) { - this.type = type; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public HashMap getData() { - return data; - } - - public void setData(HashMap data) { - this.data = data; - } - - public DateTime getLastUpdateOn() { - return lastUpdateOn; - } - - @JsonProperty("last_update_on") - public void setLastUpdateOn(DateTime lastUpdateOn) { - this.lastUpdateOn = lastUpdateOn; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public List getRights() { - return rights; - } - - public void setRights(List rights) { - this.rights = rights; - } - - public boolean isCommentsAllowed() { - return commentsAllowed; - } - - @JsonProperty("comments_allowed") - public void setCommentsAllowed(boolean commentsAllowed) { - this.commentsAllowed = commentsAllowed; - } - - public SpaceMini getSpace() { - return space; - } - - public void setSpace(SpaceMini space) { - this.space = space; - } - - public OrganizationMini getOrganization() { - return organization; - } - - @JsonProperty("org") - public void setOrganization(OrganizationMini organization) { - this.organization = organization; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public List getComments() { - return comments; - } - - public void setComments(List comments) { - this.comments = comments; - } - - public List getFiles() { - return files; - } - - public void setFiles(List files) { - this.files = files; - } - - public Application getApp() { - return app; - } - - public void setApp(Application app) { - this.app = app; - } - - public List getActivities() { - return activities; - } - - @JsonProperty("activity") - public void setActivities(List activities) { - this.activities = activities; - } -} +package com.podio.stream; + +import java.util.HashMap; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.app.Application; +import com.podio.comment.Comment; +import com.podio.common.CreatedBase; +import com.podio.common.ReferenceType; +import com.podio.common.Right; +import com.podio.file.File; +import com.podio.org.OrganizationMini; +import com.podio.space.SpaceMini; + +public class StreamObjectV2 extends CreatedBase { + + /** + * The type of object, either {@link ReferenceType.STATUS}, + * {@link ReferenceType.ITEM} or {@link ReferenceType.TASK} + */ + private ReferenceType type; + + /** + * The id of the object + */ + private int id; + + /** + * The date and time the object was last updated + */ + private DateTime lastUpdateOn; + + /** + * The title of the object + */ + private String title; + + /** + * The link to the object + */ + private String link; + + /** + * The list of user rights on the status + */ + private List rights; + + /** + * The object itself in short form + */ + private HashMap data; + + /** + * true if comments are allowed, false otherwise + */ + private boolean commentsAllowed; + + /** + * The app this object belongs to, if any, + */ + private Application app; + + /** + * The space the object belongs to + */ + private SpaceMini space; + + /** + * The organization the object belongs to + */ + private OrganizationMini organization; + + /** + * The comments on the object + */ + private List comments; + + /** + * Files attached to the object + */ + private List files; + + /** + * The list of recent activities on the object + */ + private List activities; + + public ReferenceType getType() { + return type; + } + + public void setType(ReferenceType type) { + this.type = type; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public HashMap getData() { + return data; + } + + public void setData(HashMap data) { + this.data = data; + } + + public DateTime getLastUpdateOn() { + return lastUpdateOn; + } + + @JsonProperty("last_update_on") + public void setLastUpdateOn(DateTime lastUpdateOn) { + this.lastUpdateOn = lastUpdateOn; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public List getRights() { + return rights; + } + + public void setRights(List rights) { + this.rights = rights; + } + + public boolean isCommentsAllowed() { + return commentsAllowed; + } + + @JsonProperty("comments_allowed") + public void setCommentsAllowed(boolean commentsAllowed) { + this.commentsAllowed = commentsAllowed; + } + + public SpaceMini getSpace() { + return space; + } + + public void setSpace(SpaceMini space) { + this.space = space; + } + + public OrganizationMini getOrganization() { + return organization; + } + + @JsonProperty("org") + public void setOrganization(OrganizationMini organization) { + this.organization = organization; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public List getComments() { + return comments; + } + + public void setComments(List comments) { + this.comments = comments; + } + + public List getFiles() { + return files; + } + + public void setFiles(List files) { + this.files = files; + } + + public Application getApp() { + return app; + } + + public void setApp(Application app) { + this.app = app; + } + + public List getActivities() { + return activities; + } + + @JsonProperty("activity") + public void setActivities(List activities) { + this.activities = activities; + } +} diff --git a/src/main/java/com/podio/subscription/Subscription.java b/src/main/java/com/podio/subscription/Subscription.java index e101d2a..bbb6a39 100644 --- a/src/main/java/com/podio/subscription/Subscription.java +++ b/src/main/java/com/podio/subscription/Subscription.java @@ -1,51 +1,51 @@ -package com.podio.subscription; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.common.Reference; - -public class Subscription { - - /** - * When the subscription started - */ - private DateTime startedOn; - - /** - * The number of notifications created on this subscription - */ - private int notifications; - - /** - * The object this subscription is on - */ - private Reference reference; - - public DateTime getStartedOn() { - return startedOn; - } - - @JsonProperty("started_on") - public void setStartedOn(DateTime startedOn) { - this.startedOn = startedOn; - } - - public int getNotifications() { - return notifications; - } - - public void setNotifications(int notifications) { - this.notifications = notifications; - } - - @JsonProperty("ref") - public Reference getReference() { - return reference; - } - - @JsonProperty("ref") - public void setReference(Reference reference) { - this.reference = reference; - } -} +package com.podio.subscription; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.common.Reference; + +public class Subscription { + + /** + * When the subscription started + */ + private DateTime startedOn; + + /** + * The number of notifications created on this subscription + */ + private int notifications; + + /** + * The object this subscription is on + */ + private Reference reference; + + public DateTime getStartedOn() { + return startedOn; + } + + @JsonProperty("started_on") + public void setStartedOn(DateTime startedOn) { + this.startedOn = startedOn; + } + + public int getNotifications() { + return notifications; + } + + public void setNotifications(int notifications) { + this.notifications = notifications; + } + + @JsonProperty("ref") + public Reference getReference() { + return reference; + } + + @JsonProperty("ref") + public void setReference(Reference reference) { + this.reference = reference; + } +} diff --git a/src/main/java/com/podio/subscription/SubscriptionAPI.java b/src/main/java/com/podio/subscription/SubscriptionAPI.java index 8a9beb2..3e2e3c1 100644 --- a/src/main/java/com/podio/subscription/SubscriptionAPI.java +++ b/src/main/java/com/podio/subscription/SubscriptionAPI.java @@ -1,81 +1,81 @@ -package com.podio.subscription; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.Empty; -import com.podio.common.Reference; - -/** - * Subscriptions allows the user to be notified when an object is created, - * updated, delete, comments added to it or rated. - */ -public class SubscriptionAPI extends BaseAPI { - - public SubscriptionAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Returns the subscription with the given id - * - * @param susbcriptionId - * The id of the subscription - * @return The subscription - */ - public Subscription getSubscription(int susbcriptionId) { - return getResourceFactory().getApiResource( - "/subscription/" + susbcriptionId).get(Subscription.class); - } - - /** - * Get the subscription for the given object - * - * @param reference - * The reference to object - * @return The subscription on the object - */ - public Subscription getSubscription(Reference reference) { - return getResourceFactory().getApiResource( - "/subscription/" + reference.toURLFragment(false)).get( - Subscription.class); - } - - /** - * Subscribes the user to the given object. Based on the object type, the - * user will receive notifications when actions are performed on the object. - * See the area for more details. - * - * @param reference - * The reference to the object to subscribe to - */ - public void subscribe(Reference reference) { - getResourceFactory() - .getApiResource( - "/subscription/" + reference.toURLFragment(false)) - .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Stops the subscription with the given id - * - * @param subscriptionId - * The id of the subscription - */ - public void unsubscribe(int subscriptionId) { - getResourceFactory().getApiResource("/subscription/" + subscriptionId) - .delete(); - } - - /** - * Unsubscribe from getting notifications on actions on the given object. - * - * @param reference - * The reference to the object - */ - public void unsubscribe(Reference reference) { - getResourceFactory().getApiResource( - "/subscription/" + reference.toURLFragment(false)).delete(); - } -} +package com.podio.subscription; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.Empty; +import com.podio.common.Reference; + +/** + * Subscriptions allows the user to be notified when an object is created, + * updated, delete, comments added to it or rated. + */ +public class SubscriptionAPI extends BaseAPI { + + public SubscriptionAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Returns the subscription with the given id + * + * @param susbcriptionId + * The id of the subscription + * @return The subscription + */ + public Subscription getSubscription(int susbcriptionId) { + return getResourceFactory().getApiResource( + "/subscription/" + susbcriptionId).get(Subscription.class); + } + + /** + * Get the subscription for the given object + * + * @param reference + * The reference to object + * @return The subscription on the object + */ + public Subscription getSubscription(Reference reference) { + return getResourceFactory().getApiResource( + "/subscription/" + reference.toURLFragment(false)).get( + Subscription.class); + } + + /** + * Subscribes the user to the given object. Based on the object type, the + * user will receive notifications when actions are performed on the object. + * See the area for more details. + * + * @param reference + * The reference to the object to subscribe to + */ + public void subscribe(Reference reference) { + getResourceFactory() + .getApiResource( + "/subscription/" + reference.toURLFragment(false)) + .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Stops the subscription with the given id + * + * @param subscriptionId + * The id of the subscription + */ + public void unsubscribe(int subscriptionId) { + getResourceFactory().getApiResource("/subscription/" + subscriptionId) + .delete(); + } + + /** + * Unsubscribe from getting notifications on actions on the given object. + * + * @param reference + * The reference to the object + */ + public void unsubscribe(Reference reference) { + getResourceFactory().getApiResource( + "/subscription/" + reference.toURLFragment(false)).delete(); + } +} diff --git a/src/main/java/com/podio/tag/TagAPI.java b/src/main/java/com/podio/tag/TagAPI.java index dd337b8..f491ca6 100644 --- a/src/main/java/com/podio/tag/TagAPI.java +++ b/src/main/java/com/podio/tag/TagAPI.java @@ -1,317 +1,317 @@ -package com.podio.tag; - -import java.util.Arrays; -import java.util.Collection; -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 - * a more detailed explanation, see this wikipedia article: - * http://en.wikipedia.org/wiki/Tag_(metadata) - * - * Podio supports tags on statuses and items and tags that include spaces. - */ -public class TagAPI extends BaseAPI { - - public TagAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Add a new set of tags to the object. If a tag with the same text is - * already present, the tag will be ignored. - * - * @param reference - * The object the tags should be added to - * @param tags - * The tags that should be added - */ - public void createTags(Reference reference, Collection tags) { - getResourceFactory() - .getApiResource("/tag/" + reference.toURLFragment()) - .entity(tags, MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Add a new set of tags to the object. If a tag with the same text is - * already present, the tag will be ignored. - * - * @param reference - * The object the tags should be added to - * @param tags - * The tags that should be added - */ - public void createTags(Reference reference, String... tags) { - createTags(reference, Arrays.asList(tags)); - } - - /** - * Update the tags on the objects - * - * @param reference - * The object the tags should be updated on - * @param tags - * The tags that should now be set on the object - */ - public void updateTags(Reference reference, Collection tags) { - getResourceFactory() - .getApiResource("/tag/" + reference.toURLFragment()) - .entity(tags, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Update the tags on the objects - * - * @param reference - * The object the tags should be updated on - * @param tags - * The tags that should now be set on the object - */ - public void updateTags(Reference reference, String... tags) { - updateTags(reference, Arrays.asList(tags)); - } - - /** - * Removes a single tag from an object. - * - * @param reference - * The object the tag should be removed from - * @param tag - * The tag to remove - */ - public void removeTag(Reference reference, String tag) { - getResourceFactory() - .getApiResource("/tag/" + reference.toURLFragment()) - .queryParam("text", tag).delete(); - } - - /** - * 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 * - * @return The list of tags with their count - */ - public List getTagsOnApp(int appId) { - return getResourceFactory().getApiResource("/tag/app/" + appId + "/") - .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); - } - - /** - * 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 - * 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 - * @return The list of tags with their count - */ - public List getTagsOnSpace(int spaceId) { - 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); - } - - /** - * Returns the objects that are tagged with the given text on the app. The - * objects are returned sorted descending by the time the tag was added. - * - * @param appId - * The id of the app to search within - * @param text - * The tag to search for - * @return The list of objects in the app that have the given tag - */ - public List getTagsOnAppWithText(int appId, String text) { - return getResourceFactory() - .getApiResource("/tag/app/" + appId + "/search/") - .queryParam("text", 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 - * objects are returned sorted descending by the time the tag was added. - * - * @param spaceId - * The id of the space to search within - * @param text - * The tag to search for - * @return The list of objects in the space that have the given tag - */ - public List getTagsOnSpaceWithText(int spaceId, String text) { - return getResourceFactory() - .getApiResource("/tag/space/" + spaceId + "/search/") - .queryParam("text", text) - .get(new GenericType>() { - }); - } -} +package com.podio.tag; + +import java.util.Arrays; +import java.util.Collection; +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 + * a more detailed explanation, see this wikipedia article: + * http://en.wikipedia.org/wiki/Tag_(metadata) + * + * Podio supports tags on statuses and items and tags that include spaces. + */ +public class TagAPI extends BaseAPI { + + public TagAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Add a new set of tags to the object. If a tag with the same text is + * already present, the tag will be ignored. + * + * @param reference + * The object the tags should be added to + * @param tags + * The tags that should be added + */ + public void createTags(Reference reference, Collection tags) { + getResourceFactory() + .getApiResource("/tag/" + reference.toURLFragment()) + .entity(tags, MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Add a new set of tags to the object. If a tag with the same text is + * already present, the tag will be ignored. + * + * @param reference + * The object the tags should be added to + * @param tags + * The tags that should be added + */ + public void createTags(Reference reference, String... tags) { + createTags(reference, Arrays.asList(tags)); + } + + /** + * Update the tags on the objects + * + * @param reference + * The object the tags should be updated on + * @param tags + * The tags that should now be set on the object + */ + public void updateTags(Reference reference, Collection tags) { + getResourceFactory() + .getApiResource("/tag/" + reference.toURLFragment()) + .entity(tags, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Update the tags on the objects + * + * @param reference + * The object the tags should be updated on + * @param tags + * The tags that should now be set on the object + */ + public void updateTags(Reference reference, String... tags) { + updateTags(reference, Arrays.asList(tags)); + } + + /** + * Removes a single tag from an object. + * + * @param reference + * The object the tag should be removed from + * @param tag + * The tag to remove + */ + public void removeTag(Reference reference, String tag) { + getResourceFactory() + .getApiResource("/tag/" + reference.toURLFragment()) + .queryParam("text", tag).delete(); + } + + /** + * 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 * + * @return The list of tags with their count + */ + public List getTagsOnApp(int appId) { + return getResourceFactory().getApiResource("/tag/app/" + appId + "/") + .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); + } + + /** + * 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 + * 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 + * @return The list of tags with their count + */ + public List getTagsOnSpace(int spaceId) { + 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); + } + + /** + * Returns the objects that are tagged with the given text on the app. The + * objects are returned sorted descending by the time the tag was added. + * + * @param appId + * The id of the app to search within + * @param text + * The tag to search for + * @return The list of objects in the app that have the given tag + */ + public List getTagsOnAppWithText(int appId, String text) { + return getResourceFactory() + .getApiResource("/tag/app/" + appId + "/search/") + .queryParam("text", 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 + * objects are returned sorted descending by the time the tag was added. + * + * @param spaceId + * The id of the space to search within + * @param text + * The tag to search for + * @return The list of objects in the space that have the given tag + */ + public List getTagsOnSpaceWithText(int spaceId, String text) { + return getResourceFactory() + .getApiResource("/tag/space/" + spaceId + "/search/") + .queryParam("text", text) + .get(new GenericType>() { + }); + } +} diff --git a/src/main/java/com/podio/tag/TagCount.java b/src/main/java/com/podio/tag/TagCount.java index 1631b0d..71fb3b7 100644 --- a/src/main/java/com/podio/tag/TagCount.java +++ b/src/main/java/com/podio/tag/TagCount.java @@ -1,24 +1,24 @@ -package com.podio.tag; - -public class TagCount { - - private String text; - - private int count; - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } -} +package com.podio.tag; + +public class TagCount { + + private String text; + + private int count; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/src/main/java/com/podio/tag/TagReference.java b/src/main/java/com/podio/tag/TagReference.java index 84eb7c6..7c2b3ba 100644 --- a/src/main/java/com/podio/tag/TagReference.java +++ b/src/main/java/com/podio/tag/TagReference.java @@ -1,77 +1,77 @@ -package com.podio.tag; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -import com.podio.common.ReferenceType; - -public class TagReference { - - /** - * The type of object - */ - private ReferenceType type; - - /** - * The id of the object - */ - private int id; - - /** - * The title of the object - */ - private String title; - - /** - * When the object was created - */ - private DateTime createdOn; - - /** - * The link to the object - */ - private String link; - - public ReferenceType getType() { - return type; - } - - @JsonProperty("type") - public void setType(ReferenceType type) { - this.type = type; - } - - public int getId() { - return id; - } - - @JsonProperty("id") - public void setId(int id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } -} +package com.podio.tag; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +import com.podio.common.ReferenceType; + +public class TagReference { + + /** + * The type of object + */ + private ReferenceType type; + + /** + * The id of the object + */ + private int id; + + /** + * The title of the object + */ + private String title; + + /** + * When the object was created + */ + private DateTime createdOn; + + /** + * The link to the object + */ + private String link; + + public ReferenceType getType() { + return type; + } + + @JsonProperty("type") + public void setType(ReferenceType type) { + this.type = type; + } + + public int getId() { + return id; + } + + @JsonProperty("id") + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } +} diff --git a/src/main/java/com/podio/task/AssignValue.java b/src/main/java/com/podio/task/AssignValue.java index a89f7ec..0704494 100644 --- a/src/main/java/com/podio/task/AssignValue.java +++ b/src/main/java/com/podio/task/AssignValue.java @@ -1,15 +1,15 @@ -package com.podio.task; - -public class AssignValue { - - private final int responsible; - - public AssignValue(int responsible) { - super(); - this.responsible = responsible; - } - - public int getResponsible() { - return responsible; - } -} +package com.podio.task; + +public class AssignValue { + + private final int responsible; + + public AssignValue(int responsible) { + super(); + this.responsible = responsible; + } + + public int getResponsible() { + return responsible; + } +} diff --git a/src/main/java/com/podio/task/Task.java b/src/main/java/com/podio/task/Task.java index a1ab9fb..2fa3486 100644 --- a/src/main/java/com/podio/task/Task.java +++ b/src/main/java/com/podio/task/Task.java @@ -1,225 +1,225 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; - -import com.podio.common.AuthorizationEntity; -import com.podio.common.CreatedBase; -import com.podio.common.ReferenceType; -import com.podio.contact.ProfileMini; - -public class Task extends CreatedBase { - - /** - * The id of the task - */ - private int id; - - /** - * The status of the task - */ - private TaskStatus status; - - /** - * The text of the task - */ - private String text; - - /** - * True if the task is private, false otherwise - */ - private boolean priv; - - /** - * The due date of the task, if any - */ - private LocalDate dueDate; - - /** - * The user responsible for the task - */ - private ProfileMini responsible; - - /** - * The id of the space the task is on, if any - */ - private Integer spaceId; - - /** - * The link to the task - */ - private String link; - - /** - * The date and time the task was completed - */ - private DateTime completedOn; - - /** - * The user who created the task - */ - private AuthorizationEntity completedBy; - - /** - * The type of the reference, if any - */ - private ReferenceType referenceType; - - /** - * The id of the reference, if any - */ - private Integer referenceId; - - /** - * The title of the reference, if any - */ - private String referenceTitle; - - /** - * The direct link to the reference, if any - */ - private String referenceLink; - - @Override - public String toString() { - return "Task [id=" + id + ", status=" + status + ", text=" + text - + ", priv=" + priv + ", dueDate=" + dueDate + ", responsible=" - + responsible + ", spaceId=" + spaceId + ", link=" + link - + ", referenceType=" + referenceType + ", referenceId=" - + referenceId + ", referenceTitle=" + referenceTitle - + ", referenceLink=" + referenceLink + "]"; - } - - @JsonProperty("task_id") - public int getId() { - return id; - } - - @JsonProperty("task_id") - public void setId(int id) { - this.id = id; - } - - public TaskStatus getStatus() { - return status; - } - - public void setStatus(TaskStatus status) { - this.status = status; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - @JsonProperty("private") - public boolean isPrivate() { - return priv; - } - - @JsonProperty("private") - public void setPrivate(boolean priv) { - this.priv = priv; - } - - @JsonProperty("due_date") - public LocalDate getDueDate() { - return dueDate; - } - - @JsonProperty("due_date") - public void setDueDate(LocalDate dueDate) { - this.dueDate = dueDate; - } - - public ProfileMini getResponsible() { - return responsible; - } - - public void setResponsible(ProfileMini responsible) { - this.responsible = responsible; - } - - @JsonProperty("space_id") - public Integer getSpaceId() { - return spaceId; - } - - @JsonProperty("space_id") - public void setSpaceId(Integer spaceId) { - this.spaceId = spaceId; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - @JsonProperty("completed_on") - public DateTime getCompletedOn() { - return completedOn; - } - - @JsonProperty("completed_on") - public void setCompletedOn(DateTime completedOn) { - this.completedOn = completedOn; - } - - @JsonProperty("completed_by") - public AuthorizationEntity getCompletedBy() { - return completedBy; - } - - @JsonProperty("completed_by") - public void setCompletedBy(AuthorizationEntity completedBy) { - this.completedBy = completedBy; - } - - @JsonProperty("ref_type") - public ReferenceType getReferenceType() { - return referenceType; - } - - @JsonProperty("ref_type") - public void setReferenceType(ReferenceType refeferenceType) { - this.referenceType = refeferenceType; - } - - @JsonProperty("ref_id") - public Integer getReferenceId() { - return referenceId; - } - - @JsonProperty("ref_id") - public void setReferenceId(Integer referenceId) { - this.referenceId = referenceId; - } - - @JsonProperty("ref_title") - public String getReferenceTitle() { - return referenceTitle; - } - - @JsonProperty("ref_title") - public void setReferenceTitle(String referenceTitle) { - this.referenceTitle = referenceTitle; - } - - @JsonProperty("ref_link") - public String getReferenceLink() { - return referenceLink; - } - - @JsonProperty("ref_link") - public void setReferenceLink(String referenceLink) { - this.referenceLink = referenceLink; - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; + +import com.podio.common.AuthorizationEntity; +import com.podio.common.CreatedBase; +import com.podio.common.ReferenceType; +import com.podio.contact.ProfileMini; + +public class Task extends CreatedBase { + + /** + * The id of the task + */ + private int id; + + /** + * The status of the task + */ + private TaskStatus status; + + /** + * The text of the task + */ + private String text; + + /** + * True if the task is private, false otherwise + */ + private boolean priv; + + /** + * The due date of the task, if any + */ + private LocalDate dueDate; + + /** + * The user responsible for the task + */ + private ProfileMini responsible; + + /** + * The id of the space the task is on, if any + */ + private Integer spaceId; + + /** + * The link to the task + */ + private String link; + + /** + * The date and time the task was completed + */ + private DateTime completedOn; + + /** + * The user who created the task + */ + private AuthorizationEntity completedBy; + + /** + * The type of the reference, if any + */ + private ReferenceType referenceType; + + /** + * The id of the reference, if any + */ + private Integer referenceId; + + /** + * The title of the reference, if any + */ + private String referenceTitle; + + /** + * The direct link to the reference, if any + */ + private String referenceLink; + + @Override + public String toString() { + return "Task [id=" + id + ", status=" + status + ", text=" + text + + ", priv=" + priv + ", dueDate=" + dueDate + ", responsible=" + + responsible + ", spaceId=" + spaceId + ", link=" + link + + ", referenceType=" + referenceType + ", referenceId=" + + referenceId + ", referenceTitle=" + referenceTitle + + ", referenceLink=" + referenceLink + "]"; + } + + @JsonProperty("task_id") + public int getId() { + return id; + } + + @JsonProperty("task_id") + public void setId(int id) { + this.id = id; + } + + public TaskStatus getStatus() { + return status; + } + + public void setStatus(TaskStatus status) { + this.status = status; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + @JsonProperty("private") + public boolean isPrivate() { + return priv; + } + + @JsonProperty("private") + public void setPrivate(boolean priv) { + this.priv = priv; + } + + @JsonProperty("due_date") + public LocalDate getDueDate() { + return dueDate; + } + + @JsonProperty("due_date") + public void setDueDate(LocalDate dueDate) { + this.dueDate = dueDate; + } + + public ProfileMini getResponsible() { + return responsible; + } + + public void setResponsible(ProfileMini responsible) { + this.responsible = responsible; + } + + @JsonProperty("space_id") + public Integer getSpaceId() { + return spaceId; + } + + @JsonProperty("space_id") + public void setSpaceId(Integer spaceId) { + this.spaceId = spaceId; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + @JsonProperty("completed_on") + public DateTime getCompletedOn() { + return completedOn; + } + + @JsonProperty("completed_on") + public void setCompletedOn(DateTime completedOn) { + this.completedOn = completedOn; + } + + @JsonProperty("completed_by") + public AuthorizationEntity getCompletedBy() { + return completedBy; + } + + @JsonProperty("completed_by") + public void setCompletedBy(AuthorizationEntity completedBy) { + this.completedBy = completedBy; + } + + @JsonProperty("ref_type") + public ReferenceType getReferenceType() { + return referenceType; + } + + @JsonProperty("ref_type") + public void setReferenceType(ReferenceType refeferenceType) { + this.referenceType = refeferenceType; + } + + @JsonProperty("ref_id") + public Integer getReferenceId() { + return referenceId; + } + + @JsonProperty("ref_id") + public void setReferenceId(Integer referenceId) { + this.referenceId = referenceId; + } + + @JsonProperty("ref_title") + public String getReferenceTitle() { + return referenceTitle; + } + + @JsonProperty("ref_title") + public void setReferenceTitle(String referenceTitle) { + this.referenceTitle = referenceTitle; + } + + @JsonProperty("ref_link") + public String getReferenceLink() { + return referenceLink; + } + + @JsonProperty("ref_link") + public void setReferenceLink(String referenceLink) { + this.referenceLink = referenceLink; + } +} diff --git a/src/main/java/com/podio/task/TaskAPI.java b/src/main/java/com/podio/task/TaskAPI.java index 72ed120..b95e405 100644 --- a/src/main/java/com/podio/task/TaskAPI.java +++ b/src/main/java/com/podio/task/TaskAPI.java @@ -1,278 +1,278 @@ -package com.podio.task; - -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import org.joda.time.LocalDate; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.common.Empty; -import com.podio.common.Reference; -import com.sun.jersey.api.client.GenericType; - -/** - * Tasks are used to track what work has to be done. Tasks have the following - * properties: - * - *
    - *
  • Tasks can be stand-alone or can be attached to other objects. - *
  • Tasks can be delegated to other users of Hoist. - *
  • Tasks can be private or public. When private, only the creator, the - * assignee and assignor can see the task. - *
  • Tasks can have a due date, which is the target date for completion. When - * tasks miss their due date, they become over-due. - *
  • Tasks can be started on or not started on. This is used to indicate to - * other users if the task is in progress. - *
- * - * A task can be in one of the following states: - * - *
    - *
  • active: The task is active and not yet completed - *
  • completed: The task is completed - *
- * - * The following actions can be performed on a task: - *
    - *
  • assign: Reassign the task to another user to make that user responsible - * for the task - *
  • update due date: Update the due date of the task - *
  • update text: Update the text of the task - *
  • update private: Make the task private or public - *
  • start: Indicate that worked have started on the task - *
  • stop: Indicate that work have been stopped - *
  • complete: Mark the task as completed - *
  • incomplete: Mark the task as being incomplete - *
- */ -public class TaskAPI extends BaseAPI { - - public TaskAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Returns the task with the given id. - * - * @param taskId - * The id of the task to retrieve - * @return The retrieved task - */ - public Task getTask(int taskId) { - return getResourceFactory().getApiResource("/task/" + taskId).get( - Task.class); - } - - /** - * Assigns the task to another user. This makes the user responsible for the - * task and its completion. - * - * @param taskId - * The id of the task to assign - * @param responsible - * The id of the user the task should be assigned to - */ - public void assignTask(int taskId, int responsible) { - getResourceFactory() - .getApiResource("/task/" + taskId + "/assign") - .entity(new AssignValue(responsible), - MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Mark the given task as completed. - * - * @param taskId - * The id of the task to nark as complete - */ - public void completeTask(int taskId) { - getResourceFactory().getApiResource("/task/" + taskId + "/complete") - .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Mark the completed task as no longer being completed. - * - * @param taskId - * The id of the task to mark as incomplete - */ - public void incompleteTask(int taskId) { - getResourceFactory().getApiResource("/task/" + taskId + "/incomplete") - .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); - } - - /** - * Updates the due date of the task to the given value - * - * @param taskId - * The id of the task - * @param dueDate - * The new due date of the task - */ - public void updateDueDate(int taskId, LocalDate dueDate) { - getResourceFactory() - .getApiResource("/task/" + taskId + "/due_date") - .entity(new TaskDueDate(dueDate), - MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Update the private flag on the given task. - * - * @param taskId - * The id of the task - * @param priv - * true if the task should be private, - * false otherwise - */ - public void updatePrivate(int taskId, boolean priv) { - getResourceFactory().getApiResource("/task/" + taskId + "/private") - .entity(new TaskPrivate(priv), MediaType.APPLICATION_JSON_TYPE) - .put(); - } - - /** - * Updates the text of the task. - * - * @param taskId - * The id of the task - * @param text - * The new text of the task - */ - public void updateText(int taskId, String text) { - getResourceFactory().getApiResource("/task/" + taskId + "/text") - .entity(new TaskText(text), MediaType.APPLICATION_JSON_TYPE) - .put(); - } - - /** - * Creates a new task with no reference to other objects. - * - * @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); - - return response.getId(); - } - - /** - * 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 - * @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(); - } - - /** - * Gets a list of tasks with a reference to the given object. This will - * return both active and completed tasks. The reference will not be set on - * the individual tasks. - * - * @param reference - * The object on which to return tasks - * @return The list of tasks - */ - public List getTasksWithReference(Reference reference) { - return getResourceFactory().getApiResource( - "/task/" + reference.getType().name().toLowerCase() + "/" - + reference.getId() + "/").get( - new GenericType>() { - }); - } - - /** - * Returns the active tasks of the user. This is the tasks where the user is - * responsible. - * - * The tasks will be sorted by due date and creation time, and grouped by - * their due date status. - * - * @return The tasks grouped by due date - */ - public TasksByDue getActiveTasks() { - return getResourceFactory().getApiResource("/task/active/").get( - TasksByDue.class); - } - - /** - * Returns the tasks that the user has assigned to another user. - * - * @return The tasks grouped by due date - */ - public TasksByDue getAssignedActiveTasks() { - return getResourceFactory().getApiResource("/task/assigned/active/") - .get(TasksByDue.class); - } - - /** - * Returns the tasks that is completed and where the active user is - * responsible. - * - * @return The list of tasks ordered by date of completion - */ - public List getCompletedTasks() { - return getResourceFactory().getApiResource("/task/completed/").get( - new GenericType>() { - }); - } -} +package com.podio.task; + +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import org.joda.time.LocalDate; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.common.Empty; +import com.podio.common.Reference; +import com.sun.jersey.api.client.GenericType; + +/** + * Tasks are used to track what work has to be done. Tasks have the following + * properties: + * + *
    + *
  • Tasks can be stand-alone or can be attached to other objects. + *
  • Tasks can be delegated to other users of Hoist. + *
  • Tasks can be private or public. When private, only the creator, the + * assignee and assignor can see the task. + *
  • Tasks can have a due date, which is the target date for completion. When + * tasks miss their due date, they become over-due. + *
  • Tasks can be started on or not started on. This is used to indicate to + * other users if the task is in progress. + *
+ * + * A task can be in one of the following states: + * + *
    + *
  • active: The task is active and not yet completed + *
  • completed: The task is completed + *
+ * + * The following actions can be performed on a task: + *
    + *
  • assign: Reassign the task to another user to make that user responsible + * for the task + *
  • update due date: Update the due date of the task + *
  • update text: Update the text of the task + *
  • update private: Make the task private or public + *
  • start: Indicate that worked have started on the task + *
  • stop: Indicate that work have been stopped + *
  • complete: Mark the task as completed + *
  • incomplete: Mark the task as being incomplete + *
+ */ +public class TaskAPI extends BaseAPI { + + public TaskAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Returns the task with the given id. + * + * @param taskId + * The id of the task to retrieve + * @return The retrieved task + */ + public Task getTask(int taskId) { + return getResourceFactory().getApiResource("/task/" + taskId).get( + Task.class); + } + + /** + * Assigns the task to another user. This makes the user responsible for the + * task and its completion. + * + * @param taskId + * The id of the task to assign + * @param responsible + * The id of the user the task should be assigned to + */ + public void assignTask(int taskId, int responsible) { + getResourceFactory() + .getApiResource("/task/" + taskId + "/assign") + .entity(new AssignValue(responsible), + MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Mark the given task as completed. + * + * @param taskId + * The id of the task to nark as complete + */ + public void completeTask(int taskId) { + getResourceFactory().getApiResource("/task/" + taskId + "/complete") + .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Mark the completed task as no longer being completed. + * + * @param taskId + * The id of the task to mark as incomplete + */ + public void incompleteTask(int taskId) { + getResourceFactory().getApiResource("/task/" + taskId + "/incomplete") + .entity(new Empty(), MediaType.APPLICATION_JSON_TYPE).post(); + } + + /** + * Updates the due date of the task to the given value + * + * @param taskId + * The id of the task + * @param dueDate + * The new due date of the task + */ + public void updateDueDate(int taskId, LocalDate dueDate) { + getResourceFactory() + .getApiResource("/task/" + taskId + "/due_date") + .entity(new TaskDueDate(dueDate), + MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Update the private flag on the given task. + * + * @param taskId + * The id of the task + * @param priv + * true if the task should be private, + * false otherwise + */ + public void updatePrivate(int taskId, boolean priv) { + getResourceFactory().getApiResource("/task/" + taskId + "/private") + .entity(new TaskPrivate(priv), MediaType.APPLICATION_JSON_TYPE) + .put(); + } + + /** + * Updates the text of the task. + * + * @param taskId + * The id of the task + * @param text + * The new text of the task + */ + public void updateText(int taskId, String text) { + getResourceFactory().getApiResource("/task/" + taskId + "/text") + .entity(new TaskText(text), MediaType.APPLICATION_JSON_TYPE) + .put(); + } + + /** + * Creates a new task with no reference to other objects. + * + * @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); + + return response.getId(); + } + + /** + * 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 + * @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(); + } + + /** + * Gets a list of tasks with a reference to the given object. This will + * return both active and completed tasks. The reference will not be set on + * the individual tasks. + * + * @param reference + * The object on which to return tasks + * @return The list of tasks + */ + public List getTasksWithReference(Reference reference) { + return getResourceFactory().getApiResource( + "/task/" + reference.getType().name().toLowerCase() + "/" + + reference.getId() + "/").get( + new GenericType>() { + }); + } + + /** + * Returns the active tasks of the user. This is the tasks where the user is + * responsible. + * + * The tasks will be sorted by due date and creation time, and grouped by + * their due date status. + * + * @return The tasks grouped by due date + */ + public TasksByDue getActiveTasks() { + return getResourceFactory().getApiResource("/task/active/").get( + TasksByDue.class); + } + + /** + * Returns the tasks that the user has assigned to another user. + * + * @return The tasks grouped by due date + */ + public TasksByDue getAssignedActiveTasks() { + return getResourceFactory().getApiResource("/task/assigned/active/") + .get(TasksByDue.class); + } + + /** + * Returns the tasks that is completed and where the active user is + * responsible. + * + * @return The list of tasks ordered by date of completion + */ + public List getCompletedTasks() { + return getResourceFactory().getApiResource("/task/completed/").get( + new GenericType>() { + }); + } +} diff --git a/src/main/java/com/podio/task/TaskActionType.java b/src/main/java/com/podio/task/TaskActionType.java index 8b4e908..afe269f 100644 --- a/src/main/java/com/podio/task/TaskActionType.java +++ b/src/main/java/com/podio/task/TaskActionType.java @@ -1,27 +1,27 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum TaskActionType { - - START, - STOP, - ASSIGN, - COMPLETE, - INCOMPLETE, - UPDATE_TEXT, - UPDATE_DUE_DATE, - UPDATE_PRIVATE; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static TaskActionType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum TaskActionType { + + START, + STOP, + ASSIGN, + COMPLETE, + INCOMPLETE, + UPDATE_TEXT, + UPDATE_DUE_DATE, + UPDATE_PRIVATE; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static TaskActionType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/task/TaskCreate.java b/src/main/java/com/podio/task/TaskCreate.java index e875175..1a80936 100644 --- a/src/main/java/com/podio/task/TaskCreate.java +++ b/src/main/java/com/podio/task/TaskCreate.java @@ -1,85 +1,85 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.LocalDate; - -public class TaskCreate { - - /** - * The text of the task - */ - private String text; - - /** - * The description of the task - */ - private String description; - - /** - * True if the task should be private, false otherwise - */ - private boolean priv; - - /** - * The due date of the task, if any - */ - private LocalDate dueDate; - - /** - * The user responsible for the task, no value will make the active user - * responsible - */ - private int responsible; - - public TaskCreate(String text, String description, boolean priv, - LocalDate dueDate, int responsible) { - super(); - this.text = text; - this.description = description; - this.priv = priv; - this.dueDate = dueDate; - this.responsible = responsible; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public boolean isPrivate() { - return priv; - } - - public void setPrivate(boolean priv) { - this.priv = priv; - } - - @JsonProperty("due_date") - public LocalDate getDueDate() { - return dueDate; - } - - @JsonProperty("due_date") - public void setDueDate(LocalDate dueDate) { - this.dueDate = dueDate; - } - - public int getResponsible() { - return responsible; - } - - public void setResponsible(int responsible) { - this.responsible = responsible; - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.LocalDate; + +public class TaskCreate { + + /** + * The text of the task + */ + private String text; + + /** + * The description of the task + */ + private String description; + + /** + * True if the task should be private, false otherwise + */ + private boolean priv; + + /** + * The due date of the task, if any + */ + private LocalDate dueDate; + + /** + * The user responsible for the task, no value will make the active user + * responsible + */ + private int responsible; + + public TaskCreate(String text, String description, boolean priv, + LocalDate dueDate, int responsible) { + super(); + this.text = text; + this.description = description; + this.priv = priv; + this.dueDate = dueDate; + this.responsible = responsible; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isPrivate() { + return priv; + } + + public void setPrivate(boolean priv) { + this.priv = priv; + } + + @JsonProperty("due_date") + public LocalDate getDueDate() { + return dueDate; + } + + @JsonProperty("due_date") + public void setDueDate(LocalDate dueDate) { + this.dueDate = dueDate; + } + + public int getResponsible() { + return responsible; + } + + public void setResponsible(int responsible) { + this.responsible = responsible; + } +} diff --git a/src/main/java/com/podio/task/TaskCreateResponse.java b/src/main/java/com/podio/task/TaskCreateResponse.java index 6bf7729..20dadb0 100644 --- a/src/main/java/com/podio/task/TaskCreateResponse.java +++ b/src/main/java/com/podio/task/TaskCreateResponse.java @@ -1,18 +1,18 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class TaskCreateResponse { - - private int id; - - @JsonProperty("task_id") - public int getId() { - return id; - } - - @JsonProperty("task_id") - public void setId(int id) { - this.id = id; - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class TaskCreateResponse { + + private int id; + + @JsonProperty("task_id") + public int getId() { + return id; + } + + @JsonProperty("task_id") + public void setId(int id) { + this.id = id; + } +} diff --git a/src/main/java/com/podio/task/TaskDueDate.java b/src/main/java/com/podio/task/TaskDueDate.java index 85d7f92..922efb5 100644 --- a/src/main/java/com/podio/task/TaskDueDate.java +++ b/src/main/java/com/podio/task/TaskDueDate.java @@ -1,19 +1,19 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.LocalDate; - -public class TaskDueDate { - - private final LocalDate dueDate; - - public TaskDueDate(LocalDate dueDate) { - super(); - this.dueDate = dueDate; - } - - @JsonProperty("due_date") - public LocalDate getDueDate() { - return dueDate; - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.LocalDate; + +public class TaskDueDate { + + private final LocalDate dueDate; + + public TaskDueDate(LocalDate dueDate) { + super(); + this.dueDate = dueDate; + } + + @JsonProperty("due_date") + public LocalDate getDueDate() { + return dueDate; + } +} diff --git a/src/main/java/com/podio/task/TaskDueStatus.java b/src/main/java/com/podio/task/TaskDueStatus.java index 8db9882..52f854d 100644 --- a/src/main/java/com/podio/task/TaskDueStatus.java +++ b/src/main/java/com/podio/task/TaskDueStatus.java @@ -1,23 +1,23 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum TaskDueStatus { - - OVERDUE, - TODAY, - TOMORROW, - UPCOMING; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static TaskDueStatus getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum TaskDueStatus { + + OVERDUE, + TODAY, + TOMORROW, + UPCOMING; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static TaskDueStatus getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/task/TaskPrivate.java b/src/main/java/com/podio/task/TaskPrivate.java index cc8a8d1..9eda380 100644 --- a/src/main/java/com/podio/task/TaskPrivate.java +++ b/src/main/java/com/podio/task/TaskPrivate.java @@ -1,16 +1,16 @@ -package com.podio.task; - - -public class TaskPrivate { - - private final boolean priv; - - public TaskPrivate(boolean priv) { - super(); - this.priv = priv; - } - - public boolean isPrivate() { - return priv; - } -} +package com.podio.task; + + +public class TaskPrivate { + + private final boolean priv; + + public TaskPrivate(boolean priv) { + super(); + this.priv = priv; + } + + public boolean isPrivate() { + return priv; + } +} diff --git a/src/main/java/com/podio/task/TaskStatus.java b/src/main/java/com/podio/task/TaskStatus.java index 1ed09bf..b581d8d 100644 --- a/src/main/java/com/podio/task/TaskStatus.java +++ b/src/main/java/com/podio/task/TaskStatus.java @@ -1,20 +1,20 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum TaskStatus { - - ACTIVE, COMPLETED, DELETED; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static TaskStatus getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum TaskStatus { + + ACTIVE, COMPLETED, DELETED; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static TaskStatus getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/task/TaskText.java b/src/main/java/com/podio/task/TaskText.java index 145ccbd..b654a1e 100644 --- a/src/main/java/com/podio/task/TaskText.java +++ b/src/main/java/com/podio/task/TaskText.java @@ -1,16 +1,16 @@ -package com.podio.task; - - -public class TaskText { - - private final String text; - - public TaskText(String text) { - super(); - this.text = text; - } - - public String getText() { - return text; - } -} +package com.podio.task; + + +public class TaskText { + + private final String text; + + public TaskText(String text) { + super(); + this.text = text; + } + + public String getText() { + return text; + } +} diff --git a/src/main/java/com/podio/task/TaskTotal.java b/src/main/java/com/podio/task/TaskTotal.java index 2e10d81..e6f0b31 100644 --- a/src/main/java/com/podio/task/TaskTotal.java +++ b/src/main/java/com/podio/task/TaskTotal.java @@ -1,62 +1,62 @@ -package com.podio.task; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class TaskTotal { - - /** - * The total number of overdue tasks - */ - private int overDue; - - /** - * The total number tasks due today - */ - private int dueToday; - - /** - * The total number of tasks on which work has started - */ - private int started; - - /** - * The total number of active tasks - */ - private int total; - - @JsonProperty("over_due") - public int getOverDue() { - return overDue; - } - - @JsonProperty("over_due") - public void setOverDue(int overDue) { - this.overDue = overDue; - } - - @JsonProperty("due_today") - public int getDueToday() { - return dueToday; - } - - @JsonProperty("due_today") - public void setDueToday(int dueToday) { - this.dueToday = dueToday; - } - - public int getStarted() { - return started; - } - - public void setStarted(int started) { - this.started = started; - } - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } -} +package com.podio.task; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class TaskTotal { + + /** + * The total number of overdue tasks + */ + private int overDue; + + /** + * The total number tasks due today + */ + private int dueToday; + + /** + * The total number of tasks on which work has started + */ + private int started; + + /** + * The total number of active tasks + */ + private int total; + + @JsonProperty("over_due") + public int getOverDue() { + return overDue; + } + + @JsonProperty("over_due") + public void setOverDue(int overDue) { + this.overDue = overDue; + } + + @JsonProperty("due_today") + public int getDueToday() { + return dueToday; + } + + @JsonProperty("due_today") + public void setDueToday(int dueToday) { + this.dueToday = dueToday; + } + + public int getStarted() { + return started; + } + + public void setStarted(int started) { + this.started = started; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } +} diff --git a/src/main/java/com/podio/task/TaskTotals.java b/src/main/java/com/podio/task/TaskTotals.java index 9262326..4c8ea38 100644 --- a/src/main/java/com/podio/task/TaskTotals.java +++ b/src/main/java/com/podio/task/TaskTotals.java @@ -1,30 +1,30 @@ -package com.podio.task; - -public class TaskTotals { - - /** - * The task totals where the active user is responsible - */ - private TaskTotal responsible; - - /** - * The tasks that the active user have created and delegated to others - */ - private TaskTotal delegated; - - public TaskTotal getResponsible() { - return responsible; - } - - public void setResponsible(TaskTotal responsible) { - this.responsible = responsible; - } - - public TaskTotal getDelegated() { - return delegated; - } - - public void setDelegated(TaskTotal delegated) { - this.delegated = delegated; - } -} +package com.podio.task; + +public class TaskTotals { + + /** + * The task totals where the active user is responsible + */ + private TaskTotal responsible; + + /** + * The tasks that the active user have created and delegated to others + */ + private TaskTotal delegated; + + public TaskTotal getResponsible() { + return responsible; + } + + public void setResponsible(TaskTotal responsible) { + this.responsible = responsible; + } + + public TaskTotal getDelegated() { + return delegated; + } + + public void setDelegated(TaskTotal delegated) { + this.delegated = delegated; + } +} diff --git a/src/main/java/com/podio/task/TasksByDue.java b/src/main/java/com/podio/task/TasksByDue.java index 156b204..ae687e8 100644 --- a/src/main/java/com/podio/task/TasksByDue.java +++ b/src/main/java/com/podio/task/TasksByDue.java @@ -1,26 +1,26 @@ -package com.podio.task; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonAnySetter; - -public class TasksByDue { - - private Map> map = new HashMap>(); - - @Override - public String toString() { - return "TasksByDue [map=" + map + "]"; - } - - public List getByDueStatus(TaskDueStatus status) { - return map.get(status); - } - - @JsonAnySetter - public void setByDueStatus(String status, List tasks) { - map.put(TaskDueStatus.getByName(status), tasks); - } -} +package com.podio.task; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonAnySetter; + +public class TasksByDue { + + private Map> map = new HashMap>(); + + @Override + public String toString() { + return "TasksByDue [map=" + map + "]"; + } + + public List getByDueStatus(TaskDueStatus status) { + return map.get(status); + } + + @JsonAnySetter + public void setByDueStatus(String status, List tasks) { + map.put(TaskDueStatus.getByName(status), tasks); + } +} diff --git a/src/main/java/com/podio/task/TasksWithResponsible.java b/src/main/java/com/podio/task/TasksWithResponsible.java index 8967dfc..2451f64 100644 --- a/src/main/java/com/podio/task/TasksWithResponsible.java +++ b/src/main/java/com/podio/task/TasksWithResponsible.java @@ -1,28 +1,28 @@ -package com.podio.task; - -import java.util.List; - -import com.podio.contact.ProfileMini; - -public class TasksWithResponsible { - - private ProfileMini responsible; - - private List tasks; - - public ProfileMini getResponsible() { - return responsible; - } - - public void setResponsible(ProfileMini responsible) { - this.responsible = responsible; - } - - public List getTasks() { - return tasks; - } - - public void setTasks(List tasks) { - this.tasks = tasks; - } -} +package com.podio.task; + +import java.util.List; + +import com.podio.contact.ProfileMini; + +public class TasksWithResponsible { + + private ProfileMini responsible; + + private List tasks; + + public ProfileMini getResponsible() { + return responsible; + } + + public void setResponsible(ProfileMini responsible) { + this.responsible = responsible; + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } +} diff --git a/src/main/java/com/podio/user/ProfileFieldMultiValue.java b/src/main/java/com/podio/user/ProfileFieldMultiValue.java index 4c14774..580554e 100644 --- a/src/main/java/com/podio/user/ProfileFieldMultiValue.java +++ b/src/main/java/com/podio/user/ProfileFieldMultiValue.java @@ -1,22 +1,22 @@ -package com.podio.user; - -import java.util.Collections; -import java.util.List; - -public class ProfileFieldMultiValue { - - private final List value; - - public ProfileFieldMultiValue(F value) { - this(Collections.singletonList(value)); - } - - public ProfileFieldMultiValue(List value) { - super(); - this.value = value; - } - - public List getValue() { - return value; - } -} +package com.podio.user; + +import java.util.Collections; +import java.util.List; + +public class ProfileFieldMultiValue { + + private final List value; + + public ProfileFieldMultiValue(F value) { + this(Collections.singletonList(value)); + } + + public ProfileFieldMultiValue(List value) { + super(); + this.value = value; + } + + public List getValue() { + return value; + } +} diff --git a/src/main/java/com/podio/user/ProfileFieldSingleValue.java b/src/main/java/com/podio/user/ProfileFieldSingleValue.java index 50ca88a..0870902 100644 --- a/src/main/java/com/podio/user/ProfileFieldSingleValue.java +++ b/src/main/java/com/podio/user/ProfileFieldSingleValue.java @@ -1,15 +1,15 @@ -package com.podio.user; - -public class ProfileFieldSingleValue { - - private final F value; - - public ProfileFieldSingleValue(F value) { - super(); - this.value = value; - } - - public F getValue() { - return value; - } -} +package com.podio.user; + +public class ProfileFieldSingleValue { + + private final F value; + + public ProfileFieldSingleValue(F value) { + super(); + this.value = value; + } + + public F getValue() { + return value; + } +} diff --git a/src/main/java/com/podio/user/PropertyValue.java b/src/main/java/com/podio/user/PropertyValue.java index ad7f1b3..b7d4ef5 100644 --- a/src/main/java/com/podio/user/PropertyValue.java +++ b/src/main/java/com/podio/user/PropertyValue.java @@ -1,23 +1,23 @@ -package com.podio.user; - -public class PropertyValue { - - private boolean value; - - public PropertyValue() { - super(); - } - - public PropertyValue(boolean value) { - super(); - this.value = value; - } - - public boolean getValue() { - return value; - } - - public void setValue(boolean value) { - this.value = value; - } -} +package com.podio.user; + +public class PropertyValue { + + private boolean value; + + public PropertyValue() { + super(); + } + + public PropertyValue(boolean value) { + super(); + this.value = value; + } + + public boolean getValue() { + return value; + } + + public void setValue(boolean value) { + this.value = value; + } +} diff --git a/src/main/java/com/podio/user/User.java b/src/main/java/com/podio/user/User.java index 0cc87b3..65b51d8 100644 --- a/src/main/java/com/podio/user/User.java +++ b/src/main/java/com/podio/user/User.java @@ -1,101 +1,101 @@ -package com.podio.user; - -import java.util.List; -import java.util.Locale; -import java.util.TimeZone; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.joda.time.DateTime; - -public class User { - - private int id; - - private String mail; - - private UserStatusType status; - - private Locale locale; - - private TimeZone timezone; - - private int invites; - - private List flags; - - private DateTime createdOn; - - @Override - public String toString() { - return "User [id=" + id + ", mail=" + mail + ", status=" + status - + ", locale=" + locale + ", timezone=" + timezone + "]"; - } - - @JsonProperty("user_id") - public int getId() { - return id; - } - - @JsonProperty("user_id") - public void setId(int id) { - this.id = id; - } - - public String getMail() { - return mail; - } - - public void setMail(String mail) { - this.mail = mail; - } - - public UserStatusType getStatus() { - return status; - } - - public void setStatus(UserStatusType status) { - this.status = status; - } - - public Locale getLocale() { - return locale; - } - - public void setLocale(Locale locale) { - this.locale = locale; - } - - public TimeZone getTimezone() { - return timezone; - } - - public void setTimezone(TimeZone timezone) { - this.timezone = timezone; - } - - public int getInvites() { - return invites; - } - - public void setInvites(int invites) { - this.invites = invites; - } - - public List getFlags() { - return flags; - } - - public void setFlags(List flags) { - this.flags = flags; - } - - @JsonProperty("created_on") - public DateTime getCreatedOn() { - return createdOn; - } - - @JsonProperty("created_on") - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } -} +package com.podio.user; + +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.joda.time.DateTime; + +public class User { + + private int id; + + private String mail; + + private UserStatusType status; + + private Locale locale; + + private TimeZone timezone; + + private int invites; + + private List flags; + + private DateTime createdOn; + + @Override + public String toString() { + return "User [id=" + id + ", mail=" + mail + ", status=" + status + + ", locale=" + locale + ", timezone=" + timezone + "]"; + } + + @JsonProperty("user_id") + public int getId() { + return id; + } + + @JsonProperty("user_id") + public void setId(int id) { + this.id = id; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + public UserStatusType getStatus() { + return status; + } + + public void setStatus(UserStatusType status) { + this.status = status; + } + + public Locale getLocale() { + return locale; + } + + public void setLocale(Locale locale) { + this.locale = locale; + } + + public TimeZone getTimezone() { + return timezone; + } + + public void setTimezone(TimeZone timezone) { + this.timezone = timezone; + } + + public int getInvites() { + return invites; + } + + public void setInvites(int invites) { + this.invites = invites; + } + + public List getFlags() { + return flags; + } + + public void setFlags(List flags) { + this.flags = flags; + } + + @JsonProperty("created_on") + public DateTime getCreatedOn() { + return createdOn; + } + + @JsonProperty("created_on") + public void setCreatedOn(DateTime createdOn) { + this.createdOn = createdOn; + } +} diff --git a/src/main/java/com/podio/user/UserAPI.java b/src/main/java/com/podio/user/UserAPI.java index 94a23ad..4421cea 100644 --- a/src/main/java/com/podio/user/UserAPI.java +++ b/src/main/java/com/podio/user/UserAPI.java @@ -1,203 +1,203 @@ -package com.podio.user; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import com.podio.BaseAPI; -import com.podio.ResourceFactory; -import com.podio.contact.Profile; -import com.podio.contact.ProfileField; -import com.podio.contact.ProfileFieldValues; -import com.podio.contact.ProfileUpdate; -import com.sun.jersey.api.client.GenericType; - -/** - * This area holds all the users which just includes basic operations. - */ -public class UserAPI extends BaseAPI { - - public UserAPI(ResourceFactory resourceFactory) { - super(resourceFactory); - } - - /** - * Updates the active user. The old and new password can be left out, in - * which case the password will not be changed. If the mail is changed, the - * old password has to be supplied as well. - */ - public void updateUser(UserUpdate update) { - getResourceFactory().getApiResource("/user/") - .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Returns the current status for the user. This includes the user data, - * profile data and notification data. - * - * @return The status of the user - */ - public UserStatus getStatus() { - return getResourceFactory().getApiResource("/user/status").get( - UserStatus.class); - } - - /** - * Returns the profile of the active user - * - * @return The profile for the user - */ - public Profile getProfile() { - return getResourceFactory().getApiResource("/user/profile/").get( - Profile.class); - } - - /** - * Returns the field of the profile for the given key from the active user. - * - * @param field - * The field to return the values for - * @return The values for the given field - */ - public List getProfileField(ProfileField field) { - List values = getResourceFactory().getApiResource( - "/user/profile/" + field.getName()).get( - new GenericType>() { - }); - - List formatted = new ArrayList(); - for (R value : values) { - formatted.add(field.parse(value)); - } - - return formatted; - } - - /** - * Updates the fields of an existing profile. All fields must be filled out, - * as any fields not included will not be part of the new revision. - * - * @param profile - * The updated profile - */ - public void updateProfile(ProfileUpdate profile) { - getResourceFactory().getApiResource("/user/profile/") - .entity(profile, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Updates a single field on the profile of the user - * - * @param field - * The field that should be updated - * @param value - * The new value of the field - */ - public void updateProfileField(ProfileField field, F value) { - if (field.isSingle()) { - getResourceFactory() - .getApiResource("/user/profile/" + field.getName()) - .entity(new ProfileFieldSingleValue(value), - MediaType.APPLICATION_JSON_TYPE).put(); - } else { - getResourceFactory() - .getApiResource("/user/profile/" + field.getName()) - .entity(new ProfileFieldMultiValue(value), - MediaType.APPLICATION_JSON_TYPE).put(); - } - } - - /** - * Updates a single field on the profile of the user - * - * @param field - * The field that should be updated - * @param values - * The new values of the field - */ - public void updateProfileField(ProfileField field, F... values) { - updateProfileField(field, Arrays.asList(values)); - } - - /** - * Updates a single field on the profile of the user - * - * @param field - * The field that should be updated - * @param values - * The new values of the field - */ - public void updateProfileField(ProfileField field, List values) { - if (field.isSingle()) { - throw new IllegalArgumentException( - "Field is only valid for single value"); - } else { - getResourceFactory() - .getApiResource("/user/profile/" + field.getName()) - .entity(new ProfileFieldMultiValue(values), - MediaType.APPLICATION_JSON_TYPE).put(); - } - } - - /** - * Updates the fields of an existing profile. Will only update the fields in - * the values. - * - * @param values - * The updated values for the profile - */ - public void updateProfile(ProfileFieldValues values) { - getResourceFactory().getApiResource("/user/profile/") - .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Gets the active user - * - * @return The active user - */ - public User getUser() { - return getResourceFactory().getApiResource("/user/").get(User.class); - } - - /** - * Returns the value of the property for the active user with the given - * name. The property is specific to the auth client used. - * - * @param key - * The key of the property - */ - public boolean getProperty(String key) { - return getResourceFactory().getApiResource("/user/property/" + key) - .get(PropertyValue.class).getValue(); - } - - /** - * Sets the value of the property for the active user with the given name. - * The property is specific to the auth client used. - * - * @param key - * The key of the property - * @param value - * The value of the property - */ - public void setProperty(String key, boolean value) { - getResourceFactory() - .getApiResource("/user/property/" + key) - .entity(new PropertyValue(value), - MediaType.APPLICATION_JSON_TYPE).put(); - } - - /** - * Deletes the property for the active user with the given name. The - * property is specific to the auth client used. - * - * @param key - * The key of the property that should be deleted - */ - public void deleteProperty(String key) { - getResourceFactory().getApiResource("/user/property/" + key).delete(); - } -} +package com.podio.user; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.ws.rs.core.MediaType; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.podio.contact.Profile; +import com.podio.contact.ProfileField; +import com.podio.contact.ProfileFieldValues; +import com.podio.contact.ProfileUpdate; +import com.sun.jersey.api.client.GenericType; + +/** + * This area holds all the users which just includes basic operations. + */ +public class UserAPI extends BaseAPI { + + public UserAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * Updates the active user. The old and new password can be left out, in + * which case the password will not be changed. If the mail is changed, the + * old password has to be supplied as well. + */ + public void updateUser(UserUpdate update) { + getResourceFactory().getApiResource("/user/") + .entity(update, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Returns the current status for the user. This includes the user data, + * profile data and notification data. + * + * @return The status of the user + */ + public UserStatus getStatus() { + return getResourceFactory().getApiResource("/user/status").get( + UserStatus.class); + } + + /** + * Returns the profile of the active user + * + * @return The profile for the user + */ + public Profile getProfile() { + return getResourceFactory().getApiResource("/user/profile/").get( + Profile.class); + } + + /** + * Returns the field of the profile for the given key from the active user. + * + * @param field + * The field to return the values for + * @return The values for the given field + */ + public List getProfileField(ProfileField field) { + List values = getResourceFactory().getApiResource( + "/user/profile/" + field.getName()).get( + new GenericType>() { + }); + + List formatted = new ArrayList(); + for (R value : values) { + formatted.add(field.parse(value)); + } + + return formatted; + } + + /** + * Updates the fields of an existing profile. All fields must be filled out, + * as any fields not included will not be part of the new revision. + * + * @param profile + * The updated profile + */ + public void updateProfile(ProfileUpdate profile) { + getResourceFactory().getApiResource("/user/profile/") + .entity(profile, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Updates a single field on the profile of the user + * + * @param field + * The field that should be updated + * @param value + * The new value of the field + */ + public void updateProfileField(ProfileField field, F value) { + if (field.isSingle()) { + getResourceFactory() + .getApiResource("/user/profile/" + field.getName()) + .entity(new ProfileFieldSingleValue(value), + MediaType.APPLICATION_JSON_TYPE).put(); + } else { + getResourceFactory() + .getApiResource("/user/profile/" + field.getName()) + .entity(new ProfileFieldMultiValue(value), + MediaType.APPLICATION_JSON_TYPE).put(); + } + } + + /** + * Updates a single field on the profile of the user + * + * @param field + * The field that should be updated + * @param values + * The new values of the field + */ + public void updateProfileField(ProfileField field, F... values) { + updateProfileField(field, Arrays.asList(values)); + } + + /** + * Updates a single field on the profile of the user + * + * @param field + * The field that should be updated + * @param values + * The new values of the field + */ + public void updateProfileField(ProfileField field, List values) { + if (field.isSingle()) { + throw new IllegalArgumentException( + "Field is only valid for single value"); + } else { + getResourceFactory() + .getApiResource("/user/profile/" + field.getName()) + .entity(new ProfileFieldMultiValue(values), + MediaType.APPLICATION_JSON_TYPE).put(); + } + } + + /** + * Updates the fields of an existing profile. Will only update the fields in + * the values. + * + * @param values + * The updated values for the profile + */ + public void updateProfile(ProfileFieldValues values) { + getResourceFactory().getApiResource("/user/profile/") + .entity(values, MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Gets the active user + * + * @return The active user + */ + public User getUser() { + return getResourceFactory().getApiResource("/user/").get(User.class); + } + + /** + * Returns the value of the property for the active user with the given + * name. The property is specific to the auth client used. + * + * @param key + * The key of the property + */ + public boolean getProperty(String key) { + return getResourceFactory().getApiResource("/user/property/" + key) + .get(PropertyValue.class).getValue(); + } + + /** + * Sets the value of the property for the active user with the given name. + * The property is specific to the auth client used. + * + * @param key + * The key of the property + * @param value + * The value of the property + */ + public void setProperty(String key, boolean value) { + getResourceFactory() + .getApiResource("/user/property/" + key) + .entity(new PropertyValue(value), + MediaType.APPLICATION_JSON_TYPE).put(); + } + + /** + * Deletes the property for the active user with the given name. The + * property is specific to the auth client used. + * + * @param key + * The key of the property that should be deleted + */ + public void deleteProperty(String key) { + getResourceFactory().getApiResource("/user/property/" + key).delete(); + } +} diff --git a/src/main/java/com/podio/user/UserMini.java b/src/main/java/com/podio/user/UserMini.java index 154fbf4..3149ceb 100644 --- a/src/main/java/com/podio/user/UserMini.java +++ b/src/main/java/com/podio/user/UserMini.java @@ -1,28 +1,28 @@ -package com.podio.user; - -import org.codehaus.jackson.annotate.JsonProperty; - -public class UserMini { - - private int id; - - private String mail; - - @JsonProperty("user_id") - public int getId() { - return id; - } - - @JsonProperty("user_id") - public void setId(int id) { - this.id = id; - } - - public String getMail() { - return mail; - } - - public void setMail(String mail) { - this.mail = mail; - } -} +package com.podio.user; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class UserMini { + + private int id; + + private String mail; + + @JsonProperty("user_id") + public int getId() { + return id; + } + + @JsonProperty("user_id") + public void setId(int id) { + this.id = id; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } +} diff --git a/src/main/java/com/podio/user/UserStatus.java b/src/main/java/com/podio/user/UserStatus.java index 3d70ff5..cf52759 100644 --- a/src/main/java/com/podio/user/UserStatus.java +++ b/src/main/java/com/podio/user/UserStatus.java @@ -1,84 +1,84 @@ -package com.podio.user; - -import java.util.Map; - -import org.codehaus.jackson.annotate.JsonProperty; - -import com.podio.contact.Profile; - -public class UserStatus { - - private User user; - - private Profile profile; - - private Map> properties; - - private int inboxNew; - - private int messageUnreadCount; - - private String calendarCode; - - private String mailbox; - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Profile getProfile() { - return profile; - } - - public void setProfile(Profile profile) { - this.profile = profile; - } - - public Map> getProperties() { - return properties; - } - - public void setProperties(Map> properties) { - this.properties = properties; - } - - @JsonProperty("inbox_new") - public int getInboxNew() { - return inboxNew; - } - - public void setInboxNew(int inboxNew) { - this.inboxNew = inboxNew; - } - - @JsonProperty("message_unread_count") - public int getMessageUnreadCount() { - return messageUnreadCount; - } - - public void setMessageUnreadCount(int messageUnreadCount) { - this.messageUnreadCount = messageUnreadCount; - } - - @JsonProperty("calendar_code") - public String getCalendarCode() { - return calendarCode; - } - - public void setCalendarCode(String calendarCode) { - this.calendarCode = calendarCode; - } - - @JsonProperty("mailbox") - public String getMailbox() { - return mailbox; - } - - public void setMailbox(String mailbox) { - this.mailbox = mailbox; - } -} +package com.podio.user; + +import java.util.Map; + +import org.codehaus.jackson.annotate.JsonProperty; + +import com.podio.contact.Profile; + +public class UserStatus { + + private User user; + + private Profile profile; + + private Map> properties; + + private int inboxNew; + + private int messageUnreadCount; + + private String calendarCode; + + private String mailbox; + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Profile getProfile() { + return profile; + } + + public void setProfile(Profile profile) { + this.profile = profile; + } + + public Map> getProperties() { + return properties; + } + + public void setProperties(Map> properties) { + this.properties = properties; + } + + @JsonProperty("inbox_new") + public int getInboxNew() { + return inboxNew; + } + + public void setInboxNew(int inboxNew) { + this.inboxNew = inboxNew; + } + + @JsonProperty("message_unread_count") + public int getMessageUnreadCount() { + return messageUnreadCount; + } + + public void setMessageUnreadCount(int messageUnreadCount) { + this.messageUnreadCount = messageUnreadCount; + } + + @JsonProperty("calendar_code") + public String getCalendarCode() { + return calendarCode; + } + + public void setCalendarCode(String calendarCode) { + this.calendarCode = calendarCode; + } + + @JsonProperty("mailbox") + public String getMailbox() { + return mailbox; + } + + public void setMailbox(String mailbox) { + this.mailbox = mailbox; + } +} diff --git a/src/main/java/com/podio/user/UserStatusType.java b/src/main/java/com/podio/user/UserStatusType.java index 3851cc1..2e83369 100644 --- a/src/main/java/com/podio/user/UserStatusType.java +++ b/src/main/java/com/podio/user/UserStatusType.java @@ -1,22 +1,22 @@ -package com.podio.user; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum UserStatusType { - - INACTIVE, - ACTIVE, - BLACKLISTED; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static UserStatusType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.user; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum UserStatusType { + + INACTIVE, + ACTIVE, + BLACKLISTED; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static UserStatusType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/user/UserType.java b/src/main/java/com/podio/user/UserType.java index f39076e..0151767 100644 --- a/src/main/java/com/podio/user/UserType.java +++ b/src/main/java/com/podio/user/UserType.java @@ -1,22 +1,22 @@ -package com.podio.user; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - -public enum UserType { - - LIGHT, - REGULAR, - ADMIN; - - @Override - @JsonValue - public String toString() { - return name().toLowerCase(); - } - - @JsonCreator - public static UserType getByName(String value) { - return valueOf(value.toUpperCase()); - } -} +package com.podio.user; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonValue; + +public enum UserType { + + LIGHT, + REGULAR, + ADMIN; + + @Override + @JsonValue + public String toString() { + return name().toLowerCase(); + } + + @JsonCreator + public static UserType getByName(String value) { + return valueOf(value.toUpperCase()); + } +} diff --git a/src/main/java/com/podio/user/UserUpdate.java b/src/main/java/com/podio/user/UserUpdate.java index 0cd36df..2ed20a5 100644 --- a/src/main/java/com/podio/user/UserUpdate.java +++ b/src/main/java/com/podio/user/UserUpdate.java @@ -1,103 +1,103 @@ -package com.podio.user; - -import java.util.Locale; -import java.util.TimeZone; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; - -public class UserUpdate { - - /** - * The new email of the user - */ - private String mail; - - /** - * The users current password - */ - private String oldPassword; - - /** - * The users new password - */ - private String newPassword; - - /** - * The locale of the user - */ - private Locale locale; - - /** - * The timezone of the user - */ - private TimeZone timezone; - - public UserUpdate() { - super(); - } - - public UserUpdate(String mail, String oldPassword, String newPassword, - Locale locale, TimeZone timezone) { - super(); - this.mail = mail; - this.oldPassword = oldPassword; - this.newPassword = newPassword; - this.locale = locale; - this.timezone = timezone; - } - - public UserUpdate(Locale locale, TimeZone timezone) { - super(); - this.locale = locale; - this.timezone = timezone; - } - - @JsonSerialize(include = Inclusion.NON_NULL) - public String getMail() { - return mail; - } - - public void setMail(String mail) { - this.mail = mail; - } - - @JsonProperty("old_password") - @JsonSerialize(include = Inclusion.NON_NULL) - public String getOldPassword() { - return oldPassword; - } - - @JsonProperty("old_password") - public void setOldPassword(String oldPassword) { - this.oldPassword = oldPassword; - } - - @JsonProperty("new_password") - @JsonSerialize(include = Inclusion.NON_NULL) - public String getNewPassword() { - return newPassword; - } - - @JsonProperty("new_password") - public void setNewPassword(String newPassword) { - this.newPassword = newPassword; - } - - public Locale getLocale() { - return locale; - } - - public void setLocale(Locale locale) { - this.locale = locale; - } - - public TimeZone getTimezone() { - return timezone; - } - - public void setTimezone(TimeZone timezone) { - this.timezone = timezone; - } -} +package com.podio.user; + +import java.util.Locale; +import java.util.TimeZone; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; + +public class UserUpdate { + + /** + * The new email of the user + */ + private String mail; + + /** + * The users current password + */ + private String oldPassword; + + /** + * The users new password + */ + private String newPassword; + + /** + * The locale of the user + */ + private Locale locale; + + /** + * The timezone of the user + */ + private TimeZone timezone; + + public UserUpdate() { + super(); + } + + public UserUpdate(String mail, String oldPassword, String newPassword, + Locale locale, TimeZone timezone) { + super(); + this.mail = mail; + this.oldPassword = oldPassword; + this.newPassword = newPassword; + this.locale = locale; + this.timezone = timezone; + } + + public UserUpdate(Locale locale, TimeZone timezone) { + super(); + this.locale = locale; + this.timezone = timezone; + } + + @JsonSerialize(include = Inclusion.NON_NULL) + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + @JsonProperty("old_password") + @JsonSerialize(include = Inclusion.NON_NULL) + public String getOldPassword() { + return oldPassword; + } + + @JsonProperty("old_password") + public void setOldPassword(String oldPassword) { + this.oldPassword = oldPassword; + } + + @JsonProperty("new_password") + @JsonSerialize(include = Inclusion.NON_NULL) + public String getNewPassword() { + return newPassword; + } + + @JsonProperty("new_password") + public void setNewPassword(String newPassword) { + this.newPassword = newPassword; + } + + public Locale getLocale() { + return locale; + } + + public void setLocale(Locale locale) { + this.locale = locale; + } + + public TimeZone getTimezone() { + return timezone; + } + + public void setTimezone(TimeZone timezone) { + this.timezone = timezone; + } +} diff --git a/src/main/java/com/podio/view/View.java b/src/main/java/com/podio/view/View.java new file mode 100644 index 0000000..712d03f --- /dev/null +++ b/src/main/java/com/podio/view/View.java @@ -0,0 +1,66 @@ +package com.podio.view; + +public class View +{ + private int view_id; + private int filter_id; + private String name; + private ViewGroupings groupings; + + /** + * @return the view_id + */ + public int getView_id() + { + return view_id; + } + /** + * @param view_id the view_id to set + */ + public void setView_id( int view_id ) + { + this.view_id = view_id; + } + /** + * @return the filter_id + */ + public int getFilter_id() + { + return filter_id; + } + /** + * @param filter_id the filter_id to set + */ + public void setFilter_id( int filter_id ) + { + this.filter_id = filter_id; + } + /** + * @return the name + */ + public String getName() + { + return name; + } + /** + * @param name the name to set + */ + public void setName( String name ) + { + this.name = name; + } + /** + * @return the groupings + */ + public ViewGroupings getGroupings() + { + return groupings; + } + /** + * @param groupings the groupings to set + */ + public void setGroupings( ViewGroupings groupings ) + { + this.groupings = groupings; + } +} diff --git a/src/main/java/com/podio/view/ViewAPI.java b/src/main/java/com/podio/view/ViewAPI.java new file mode 100644 index 0000000..cc6963c --- /dev/null +++ b/src/main/java/com/podio/view/ViewAPI.java @@ -0,0 +1,39 @@ +package com.podio.view; + +import java.util.List; + +import com.podio.BaseAPI; +import com.podio.ResourceFactory; +import com.sun.jersey.api.client.GenericType; + +public class ViewAPI extends BaseAPI{ + public ViewAPI(ResourceFactory resourceFactory) { + super(resourceFactory); + } + + /** + * returns the views for the given app + * + * @param appId + * the id of the app + * @return The list of views of the given app + */ + public List getViews(int appId) { + return getResourceFactory().getApiResource("/view/app/" + appId).get( + new GenericType>() { + }); + } + + public View getView( int appId, int viewId ) { + return getResourceFactory().getApiResource("/view/app/" + appId + "/" + viewId).get( + new GenericType() { + }); + } + + public View getView( int appId, String viewId ) { + return getResourceFactory().getApiResource("/view/app/" + appId + "/" + viewId).get( + new GenericType() { + }); + } + +} diff --git a/src/main/java/com/podio/view/ViewGroupings.java b/src/main/java/com/podio/view/ViewGroupings.java new file mode 100644 index 0000000..f30bc1c --- /dev/null +++ b/src/main/java/com/podio/view/ViewGroupings.java @@ -0,0 +1,25 @@ +package com.podio.view; + +import java.util.List; + +public class ViewGroupings +{ + private List groups; + + /** + * @return the groups + */ + public List getGroups() + { + return groups; + } + + /** + * @param groups the groups to set + */ + public void setGroups( List groups ) + { + this.groups = groups; + } + +} diff --git a/src/main/java/com/podio/view/ViewGroups.java b/src/main/java/com/podio/view/ViewGroups.java new file mode 100644 index 0000000..a430beb --- /dev/null +++ b/src/main/java/com/podio/view/ViewGroups.java @@ -0,0 +1,39 @@ +package com.podio.view; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class ViewGroups +{ + @JsonProperty("value") + private Object id; + private String label; + + /** + * @return the id + */ + public Object getId() + { + return id; + } + /** + * @param id the id to set + */ + public void setId( Object id ) + { + this.id = id; + } + /** + * @return the label + */ + public String getLabel() + { + return label; + } + /** + * @param label the label to set + */ + public void setLabel( String label ) + { + this.label = label; + } +} diff --git a/src/test/java/com/podio/APIFactoryProvider.java b/src/test/java/com/podio/APIFactoryProvider.java index d98baca..b9edec1 100644 --- a/src/test/java/com/podio/APIFactoryProvider.java +++ b/src/test/java/com/podio/APIFactoryProvider.java @@ -1,19 +1,19 @@ -package com.podio; - -public final class APIFactoryProvider { - - private APIFactoryProvider() { - } - - public static APIFactory getDefault() { - return new APIFactory(ResourceFactoryProvider.getDefault()); - } - - public static APIFactory get(int userId) { - return new APIFactory(ResourceFactoryProvider.getUser(userId)); - } - - public static APIFactory getApp(int appId) { - return new APIFactory(ResourceFactoryProvider.getApp(appId)); - } -} +package com.podio; + +public final class APIFactoryProvider { + + private APIFactoryProvider() { + } + + public static APIFactory getDefault() { + return new APIFactory(ResourceFactoryProvider.getDefault()); + } + + public static APIFactory get(int userId) { + return new APIFactory(ResourceFactoryProvider.getUser(userId)); + } + + public static APIFactory getApp(int appId) { + return new APIFactory(ResourceFactoryProvider.getApp(appId)); + } +} diff --git a/src/test/java/com/podio/app/AppAPITest.java b/src/test/java/com/podio/app/AppAPITest.java index 1c1a2d1..62c89c5 100644 --- a/src/test/java/com/podio/app/AppAPITest.java +++ b/src/test/java/com/podio/app/AppAPITest.java @@ -1,194 +1,194 @@ -package com.podio.app; - -import java.util.Arrays; -import java.util.List; - -import org.codehaus.jettison.json.JSONException; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIApplicationException; -import com.podio.APIFactoryProvider; -import com.sun.jersey.api.client.ClientResponse.Status; - -public class AppAPITest { - - private AppAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(AppAPI.class); - } - - @Test - public void getNonExistingApp() { - try { - getAPI().getApp(222); - Assert.fail(); - } catch (APIApplicationException e) { - Assert.assertEquals(e.getStatus(), Status.NOT_FOUND); - Assert.assertEquals(e.getError(), "not_found"); - Assert.assertEquals(e.getDescription(), "Object not found"); - Assert.assertEquals(e.getParameters(), null); - } - } - - @Test - public void getAppFull() throws JSONException { - Application app = getAPI().getApp(1); - - Assert.assertEquals(app.getId(), 1); - Assert.assertNotNull(app.getConfiguration()); - Assert.assertEquals(app.getConfiguration().getDefaultView(), - ApplicationViewType.BADGE); - - Assert.assertTrue(app.getFields().size() >= 21); - - ApplicationField stateField = app.getFields().get(0); - Assert.assertEquals(stateField.getStatus(), ApplicationFieldStatus.ACTIVE); - Assert.assertEquals(stateField.getType(), ApplicationFieldType.CATEGORY); - Assert.assertEquals(stateField.getConfiguration().getLabel(), - "Is hired?"); - Assert.assertEquals(stateField.getConfiguration().getSettings().getOptions().get(0).getText(), "yes"); - - ApplicationField categoryField = app.getFields().get(15); - Assert.assertEquals(categoryField.getType(), ApplicationFieldType.CATEGORY); - Assert.assertEquals(categoryField.getConfiguration().getSettings().getMultiple(), true); - Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getId(), 1); - Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getStatus(), CategoryOptionStatus.ACTIVE); - Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getText(), "Indie"); - Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getColor(), "DCEBD8"); - } - - @Test - public void addApp() { - int appId = getAPI().addApp( - new ApplicationCreate(1, new ApplicationConfigurationCreate( - "Tests", "Test", "Description", "Usage", "ExternalId", - "23.png", true, ApplicationViewType.BADGE, true, true, - false, null, false, false, null, false, null, false, - null, Arrays.asList(new ApplicationTaskCreate("Task 1", - 1), new ApplicationTaskCreate("Task 2"))), - Arrays.asList(new ApplicationFieldCreate( - ApplicationFieldType.TEXT, - new ApplicationFieldConfiguration("Title", - "Description", 0, null, true))))); - Assert.assertTrue(appId > 0); - } - - @Test - public void updateApp() { - getAPI().updateApp( - 1, - new ApplicationUpdate( - new ApplicationConfigurationCreate("Tests", "Test", - "Description", "Usage", "ExternalId", "23.png", - true, ApplicationViewType.BADGE, true, true, - false, null, false, false, null, false, null, - false, null, Arrays.asList( - new ApplicationTaskCreate("Task 1", 1), - new ApplicationTaskCreate("Task 2"))), - Arrays.asList(new ApplicationFieldUpdate(1, - new ApplicationFieldConfiguration("Is hired?", - "Description", 10, - ApplicationFieldSettings - .getState(Arrays.asList("yes", - "no", "maybe")), true))))); - } - - @Test - public void getField() { - ApplicationField field = getAPI().getField(1, 1); - - Assert.assertEquals(field.getId(), 1); - Assert.assertEquals(field.getType(), ApplicationFieldType.CATEGORY); - Assert.assertEquals(field.getExternalId(), "is-hired"); - Assert.assertEquals(field.getConfiguration().getLabel(), "Is hired?"); - Assert.assertEquals(field.getConfiguration().getDelta(), 0); - Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getId(), 1); - Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getStatus(), CategoryOptionStatus.ACTIVE); - Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getText(), "yes"); - Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getColor(), "D2E4EB"); - } - - @Test - public void addField() { - int fieldId = getAPI().addField( - 1, - new ApplicationFieldCreate(ApplicationFieldType.TEXT, - new ApplicationFieldConfiguration("Description", - "Field description", 0, - ApplicationFieldSettings - .getText(TextFieldSize.LARGE), true))); - Assert.assertTrue(fieldId > 10); - } - - @Test - public void updateField() { - getAPI().updateField( - 1, - 1, - new ApplicationFieldConfiguration("Is hired?", "Description", - 10, ApplicationFieldSettings.getState(Arrays.asList( - "yes", "no", "maybe")), true)); - } - - @Test - public void deleteField() { - getAPI().deleteField(1, 1); - } - - @Test - public void installApp() { - int appId = getAPI().install(1, 1); - Assert.assertTrue(appId > 1); - - } - - @Test - public void updateOrder() { - getAPI().updateOrder(1, Arrays.asList(1, 2)); - } - - @Test - public void getAppsInSpace() { - List apps = getAPI().getAppsOnSpace(1); - - Assert.assertEquals(apps.size(), 2); - Assert.assertEquals(apps.get(0).getId(), 20); - Assert.assertEquals(apps.get(1).getId(), 1); - } - - @Test - public void getTopApps() { - List apps = getAPI().getTopApps(null); - - Assert.assertEquals(apps.size(), 1); - Assert.assertEquals(apps.get(0).getId(), 1); - } - - @Test - public void getApps() { - List apps = getAPI().getApps(); - Assert.assertEquals(apps.size(), 3); - - Assert.assertEquals(apps.get(0).getId(), 1); - } - - @Test - public void getAppDependencies() { - Dependencies dependencies = getAPI().getDependencies(2); - - Assert.assertEquals(dependencies.getApps().size(), 2); - Assert.assertEquals(dependencies.getDependencies().size(), 2); - Assert.assertEquals(dependencies.getDependencies().get(1).get(0) - .intValue(), 3); - } - - @Test - public void deactivateApp() { - getAPI().deactivateApp(1); - } - - @Test - public void activateApp() { - getAPI().activateApp(2); - } -} +package com.podio.app; + +import java.util.Arrays; +import java.util.List; + +import org.codehaus.jettison.json.JSONException; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIApplicationException; +import com.podio.APIFactoryProvider; +import com.sun.jersey.api.client.ClientResponse.Status; + +public class AppAPITest { + + private AppAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(AppAPI.class); + } + + @Test + public void getNonExistingApp() { + try { + getAPI().getApp(222); + Assert.fail(); + } catch (APIApplicationException e) { + Assert.assertEquals(e.getStatus(), Status.NOT_FOUND); + Assert.assertEquals(e.getError(), "not_found"); + Assert.assertEquals(e.getDescription(), "Object not found"); + Assert.assertEquals(e.getParameters(), null); + } + } + + @Test + public void getAppFull() throws JSONException { + Application app = getAPI().getApp(1); + + Assert.assertEquals(app.getId(), 1); + Assert.assertNotNull(app.getConfiguration()); + Assert.assertEquals(app.getConfiguration().getDefaultView(), + ApplicationViewType.BADGE); + + Assert.assertTrue(app.getFields().size() >= 21); + + ApplicationField stateField = app.getFields().get(0); + Assert.assertEquals(stateField.getStatus(), ApplicationFieldStatus.ACTIVE); + Assert.assertEquals(stateField.getType(), ApplicationFieldType.CATEGORY); + Assert.assertEquals(stateField.getConfiguration().getLabel(), + "Is hired?"); + Assert.assertEquals(stateField.getConfiguration().getSettings().getOptions().get(0).getText(), "yes"); + + ApplicationField categoryField = app.getFields().get(15); + Assert.assertEquals(categoryField.getType(), ApplicationFieldType.CATEGORY); + Assert.assertEquals(categoryField.getConfiguration().getSettings().getMultiple(), true); + Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getId(), 1); + Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getStatus(), CategoryOptionStatus.ACTIVE); + Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getText(), "Indie"); + Assert.assertEquals(categoryField.getConfiguration().getSettings().getOptions().get(0).getColor(), "DCEBD8"); + } + + @Test + public void addApp() { + int appId = getAPI().addApp( + new ApplicationCreate(1, new ApplicationConfigurationCreate( + "Tests", "Test", "Description", "Usage", "ExternalId", + "23.png", true, ApplicationViewType.BADGE, true, true, + false, null, false, false, null, false, null, false, + null, Arrays.asList(new ApplicationTaskCreate("Task 1", + 1), new ApplicationTaskCreate("Task 2"))), + Arrays.asList(new ApplicationFieldCreate( + ApplicationFieldType.TEXT, + new ApplicationFieldConfiguration("Title", + "Description", 0, null, true))))); + Assert.assertTrue(appId > 0); + } + + @Test + public void updateApp() { + getAPI().updateApp( + 1, + new ApplicationUpdate( + new ApplicationConfigurationCreate("Tests", "Test", + "Description", "Usage", "ExternalId", "23.png", + true, ApplicationViewType.BADGE, true, true, + false, null, false, false, null, false, null, + false, null, Arrays.asList( + new ApplicationTaskCreate("Task 1", 1), + new ApplicationTaskCreate("Task 2"))), + Arrays.asList(new ApplicationFieldUpdate(1, + new ApplicationFieldConfiguration("Is hired?", + "Description", 10, + ApplicationFieldSettings + .getState(Arrays.asList("yes", + "no", "maybe")), true))))); + } + + @Test + public void getField() { + ApplicationField field = getAPI().getField(1, 1); + + Assert.assertEquals(field.getId(), 1); + Assert.assertEquals(field.getType(), ApplicationFieldType.CATEGORY); + Assert.assertEquals(field.getExternalId(), "is-hired"); + Assert.assertEquals(field.getConfiguration().getLabel(), "Is hired?"); + Assert.assertEquals(field.getConfiguration().getDelta(), 0); + Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getId(), 1); + Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getStatus(), CategoryOptionStatus.ACTIVE); + Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getText(), "yes"); + Assert.assertEquals(field.getConfiguration().getSettings().getOptions().get(0).getColor(), "D2E4EB"); + } + + @Test + public void addField() { + int fieldId = getAPI().addField( + 1, + new ApplicationFieldCreate(ApplicationFieldType.TEXT, + new ApplicationFieldConfiguration("Description", + "Field description", 0, + ApplicationFieldSettings + .getText(TextFieldSize.LARGE), true))); + Assert.assertTrue(fieldId > 10); + } + + @Test + public void updateField() { + getAPI().updateField( + 1, + 1, + new ApplicationFieldConfiguration("Is hired?", "Description", + 10, ApplicationFieldSettings.getState(Arrays.asList( + "yes", "no", "maybe")), true)); + } + + @Test + public void deleteField() { + getAPI().deleteField(1, 1); + } + + @Test + public void installApp() { + int appId = getAPI().install(1, 1); + Assert.assertTrue(appId > 1); + + } + + @Test + public void updateOrder() { + getAPI().updateOrder(1, Arrays.asList(1, 2)); + } + + @Test + public void getAppsInSpace() { + List apps = getAPI().getAppsOnSpace(1); + + Assert.assertEquals(apps.size(), 2); + Assert.assertEquals(apps.get(0).getId(), 20); + Assert.assertEquals(apps.get(1).getId(), 1); + } + + @Test + public void getTopApps() { + List apps = getAPI().getTopApps(null); + + Assert.assertEquals(apps.size(), 1); + Assert.assertEquals(apps.get(0).getId(), 1); + } + + @Test + public void getApps() { + List apps = getAPI().getApps(); + Assert.assertEquals(apps.size(), 3); + + Assert.assertEquals(apps.get(0).getId(), 1); + } + + @Test + public void getAppDependencies() { + Dependencies dependencies = getAPI().getDependencies(2); + + Assert.assertEquals(dependencies.getApps().size(), 2); + Assert.assertEquals(dependencies.getDependencies().size(), 2); + Assert.assertEquals(dependencies.getDependencies().get(1).get(0) + .intValue(), 3); + } + + @Test + public void deactivateApp() { + getAPI().deactivateApp(1); + } + + @Test + public void activateApp() { + getAPI().activateApp(2); + } +} diff --git a/src/test/java/com/podio/calendar/CalendarAPITest.java b/src/test/java/com/podio/calendar/CalendarAPITest.java index 86d95dc..2ca106f 100644 --- a/src/test/java/com/podio/calendar/CalendarAPITest.java +++ b/src/test/java/com/podio/calendar/CalendarAPITest.java @@ -1,58 +1,58 @@ -package com.podio.calendar; - -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.LocalDate; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.ReferenceType; - -public class CalendarAPITest { - - private CalendarAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(CalendarAPI.class); - } - - @Test - public void getAppCalendar() { - List events = getAPI().getApp(1, new LocalDate(2010, 8, 1), - new LocalDate(2010, 8, 31)); - - Assert.assertEquals(events.size(), 3); - Event event = events.get(0); - Assert.assertEquals(event.getRefType(), ReferenceType.ITEM); - Assert.assertEquals(event.getRefId(), 1); - Assert.assertEquals(event.getUID(), "item_1_2"); - Assert.assertEquals(event.getTitle(), "no & yes"); - Assert.assertEquals(event.getDescription(), "æøå"); - Assert.assertEquals(event.getLocation(), null); - Assert.assertEquals(event.getVersion(), 0); - Assert.assertEquals(event.isBusy(), false); - Assert.assertEquals(event.getStatus(), null); - Assert.assertEquals(event.getStart(), new DateTime(2010, 8, 4, 9, 0, 0, - 0, DateTimeZone.UTC)); - Assert.assertEquals(event.getEnd(), new DateTime(2010, 8, 4, 10, 0, 0, - 0, DateTimeZone.UTC)); - Assert.assertEquals(event.getLink(), - "https://podio.com/hoist/api/apps/bugs/items/1"); - Assert.assertEquals(event.getApplication().getId(), 1); - } - - @Test - public void getSpaceCalendar() { - List events = getAPI().getSpace(1, new LocalDate(2010, 8, 1), - new LocalDate(2010, 8, 31)); - Assert.assertEquals(events.size(), 3); - } - - @Test - public void getGlobalCalendar() { - List events = getAPI().getGlobal(new LocalDate(2010, 8, 1), - new LocalDate(2010, 8, 31), null); - Assert.assertEquals(events.size(), 4); - } -} +package com.podio.calendar; + +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.LocalDate; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.ReferenceType; + +public class CalendarAPITest { + + private CalendarAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(CalendarAPI.class); + } + + @Test + public void getAppCalendar() { + List events = getAPI().getApp(1, new LocalDate(2010, 8, 1), + new LocalDate(2010, 8, 31)); + + Assert.assertEquals(events.size(), 3); + Event event = events.get(0); + Assert.assertEquals(event.getRefType(), ReferenceType.ITEM); + Assert.assertEquals(event.getRefId(), 1); + Assert.assertEquals(event.getUID(), "item_1_2"); + Assert.assertEquals(event.getTitle(), "no & yes"); + Assert.assertEquals(event.getDescription(), "æøå"); + Assert.assertEquals(event.getLocation(), null); + Assert.assertEquals(event.getVersion(), 0); + Assert.assertEquals(event.isBusy(), false); + Assert.assertEquals(event.getStatus(), null); + Assert.assertEquals(event.getStart(), new DateTime(2010, 8, 4, 9, 0, 0, + 0, DateTimeZone.UTC)); + Assert.assertEquals(event.getEnd(), new DateTime(2010, 8, 4, 10, 0, 0, + 0, DateTimeZone.UTC)); + Assert.assertEquals(event.getLink(), + "https://podio.com/hoist/api/apps/bugs/items/1"); + Assert.assertEquals(event.getApplication().getId(), 1); + } + + @Test + public void getSpaceCalendar() { + List events = getAPI().getSpace(1, new LocalDate(2010, 8, 1), + new LocalDate(2010, 8, 31)); + Assert.assertEquals(events.size(), 3); + } + + @Test + public void getGlobalCalendar() { + List events = getAPI().getGlobal(new LocalDate(2010, 8, 1), + new LocalDate(2010, 8, 31), null); + Assert.assertEquals(events.size(), 4); + } +} diff --git a/src/test/java/com/podio/comment/CommentAPITest.java b/src/test/java/com/podio/comment/CommentAPITest.java index 8ebd69c..334e00d 100644 --- a/src/test/java/com/podio/comment/CommentAPITest.java +++ b/src/test/java/com/podio/comment/CommentAPITest.java @@ -1,77 +1,77 @@ -package com.podio.comment; - -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.AuthorizationEntityType; -import com.podio.common.AvatarType; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class CommentAPITest { - - private CommentAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(CommentAPI.class); - } - - @Test - public void getComment() { - Comment comment = getAPI().getComment(1); - - Assert.assertEquals(comment.getId(), 1); - Assert.assertEquals( - comment.getValue(), - "Hoist rules, but we need to do more.\n\n@Andreas Haugstrup Can you fix the javascript popup problem?"); - Assert.assertEquals(comment.getExternalId(), "c1"); - // Assert.assertEquals(comment.getAlerts().size(), 1); - // Assert.assertEquals(comment.getAlerts().get(0).getId(), 2); - Assert.assertEquals(comment.getCreatedOn(), new DateTime(2010, 8, 5, 9, - 8, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(comment.getFiles().size(), 0); - Assert.assertEquals(comment.getCreatedBy().getId(), 1); - Assert.assertEquals(comment.getCreatedBy().getType(), - AuthorizationEntityType.USER); - Assert.assertEquals(comment.getCreatedBy().getName(), "Christian Holm"); - Assert.assertEquals(comment.getCreatedBy().getAvatarType(), - AvatarType.FILE); - Assert.assertEquals(comment.getCreatedBy().getAvatarId().intValue(), 9); - Assert.assertEquals(comment.getCreatedBy().getUrl().toString(), - "https://podio.com/users/1"); - Assert.assertEquals(comment.getCreatedVia().getId(), 1); - Assert.assertEquals(comment.getCreatedVia().getName(), "Podio Web"); - Assert.assertEquals(comment.getCreatedVia().getUrl(), null); - } - - @Test - public void getComments() { - List comments = getAPI().getComments( - new Reference(ReferenceType.ITEM, 1)); - - Assert.assertEquals(comments.size(), 2); - Assert.assertEquals(comments.get(0).getId(), 1); - } - - @Test - public void addComment() { - int commentId = getAPI().addComment( - new Reference(ReferenceType.ITEM, 1), - new CommentCreate("Testing"), false, false); - - Assert.assertTrue(commentId > 5); - } - - @Test - public void updateComment() { - getAPI().updateComment(1, new CommentUpdate("Test")); - } - - @Test - public void deleteComment() { - getAPI().deleteComment(1); - } -} +package com.podio.comment; + +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.AuthorizationEntityType; +import com.podio.common.AvatarType; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class CommentAPITest { + + private CommentAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(CommentAPI.class); + } + + @Test + public void getComment() { + Comment comment = getAPI().getComment(1); + + Assert.assertEquals(comment.getId(), 1); + Assert.assertEquals( + comment.getValue(), + "Hoist rules, but we need to do more.\n\n@Andreas Haugstrup Can you fix the javascript popup problem?"); + Assert.assertEquals(comment.getExternalId(), "c1"); + // Assert.assertEquals(comment.getAlerts().size(), 1); + // Assert.assertEquals(comment.getAlerts().get(0).getId(), 2); + Assert.assertEquals(comment.getCreatedOn(), new DateTime(2010, 8, 5, 9, + 8, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(comment.getFiles().size(), 0); + Assert.assertEquals(comment.getCreatedBy().getId(), 1); + Assert.assertEquals(comment.getCreatedBy().getType(), + AuthorizationEntityType.USER); + Assert.assertEquals(comment.getCreatedBy().getName(), "Christian Holm"); + Assert.assertEquals(comment.getCreatedBy().getAvatarType(), + AvatarType.FILE); + Assert.assertEquals(comment.getCreatedBy().getAvatarId().intValue(), 9); + Assert.assertEquals(comment.getCreatedBy().getUrl().toString(), + "https://podio.com/users/1"); + Assert.assertEquals(comment.getCreatedVia().getId(), 1); + Assert.assertEquals(comment.getCreatedVia().getName(), "Podio Web"); + Assert.assertEquals(comment.getCreatedVia().getUrl(), null); + } + + @Test + public void getComments() { + List comments = getAPI().getComments( + new Reference(ReferenceType.ITEM, 1)); + + Assert.assertEquals(comments.size(), 2); + Assert.assertEquals(comments.get(0).getId(), 1); + } + + @Test + public void addComment() { + int commentId = getAPI().addComment( + new Reference(ReferenceType.ITEM, 1), + new CommentCreate("Testing"), false, false); + + Assert.assertTrue(commentId > 5); + } + + @Test + public void updateComment() { + getAPI().updateComment(1, new CommentUpdate("Test")); + } + + @Test + public void deleteComment() { + getAPI().deleteComment(1); + } +} diff --git a/src/test/java/com/podio/contact/ContactAPITest.java b/src/test/java/com/podio/contact/ContactAPITest.java index 0d3056d..734a92b 100644 --- a/src/test/java/com/podio/contact/ContactAPITest.java +++ b/src/test/java/com/podio/contact/ContactAPITest.java @@ -1,90 +1,90 @@ -package com.podio.contact; - -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.LocalDate; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; - -public class ContactAPITest { - - private ContactAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(ContactAPI.class); - } - - @Test - public void getContact() { - Profile contact = getAPI().getContact(1); - - Assert.assertEquals(contact.getUserId().intValue(), 1); - Assert.assertEquals(contact.getName(), "Christian Holm"); - Assert.assertEquals(contact.getAvatar(), new Integer(9)); - Assert.assertEquals(contact.getBirthdate(), new LocalDate(1978, 12, 11)); - Assert.assertEquals(contact.getSkype(), "cho@cubitech.dk"); - Assert.assertEquals(contact.getAbout(), "King of the API, baby!"); - Assert.assertEquals(contact.getAddresses().get(0), - "Borgergade 144, 1.tv."); - Assert.assertEquals(contact.getAddresses().get(1), "1300 København K"); - Assert.assertEquals(contact.getIms(), null); - Assert.assertEquals(contact.getLocations().get(0), "København"); - Assert.assertEquals(contact.getMails().get(0), "dev@hoisthq.com"); - Assert.assertEquals(contact.getMails().get(1), "holm@hoisthq.com"); - Assert.assertEquals(contact.getPhones().get(0), "26217563"); - Assert.assertEquals(contact.getTitles().get(0), "Develoment Team Lead"); - Assert.assertEquals(contact.getUrls().get(0), - "http://www.facebook.com/profile.php?id=504601663"); - Assert.assertEquals(contact.getLastSeenOn(), new DateTime(2011, 7, 23, 13, - 0, 0, 0, DateTimeZone.UTC)); - } - - @Test - public void getContactFieldName() { - List names = getAPI().getContactField(1, ProfileField.NAME); - Assert.assertEquals(names.size(), 1); - Assert.assertEquals(names.get(0), "Christian Holm"); - } - - @Test - public void getContactFieldMail() { - List mails = getAPI().getContactField(1, ProfileField.MAIL); - Assert.assertEquals(mails.size(), 3); - Assert.assertEquals(mails.get(0), "dev@hoisthq.com"); - } - - @Test - public void getContactFieldAvatar() { - List avatars = getAPI() - .getContactField(1, ProfileField.AVATAR); - Assert.assertEquals(avatars.size(), 1); - Assert.assertEquals(avatars.get(0).intValue(), 9); - } - - @Test - public void getContactFieldBirthdate() { - List birthdates = getAPI().getContactField(1, - ProfileField.BIRTHDATE); - Assert.assertEquals(birthdates.size(), 1); - Assert.assertEquals(birthdates.get(0), new LocalDate(1978, 12, 11)); - } - - @Test - public void getContactTotals() { - ContactTotal total = getAPI().getContactTotal(); - - Assert.assertEquals(total.getUser().getCount(), 5); - } - - @Test - public void getSpaceContactsByMail() { - List contacts = getAPI().getSpaceContacts(1, - ProfileField.MAIL, "haugstrup@hoisthq.com", null, null, - ProfileType.FULL, null, ContactType.SPACE); - - Assert.assertEquals(contacts.size(), 1); - Assert.assertEquals(contacts.get(0).getUserId().intValue(), 2); - } -} +package com.podio.contact; + +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.LocalDate; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; + +public class ContactAPITest { + + private ContactAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(ContactAPI.class); + } + + @Test + public void getContact() { + Profile contact = getAPI().getContact(1); + + Assert.assertEquals(contact.getUserId().intValue(), 1); + Assert.assertEquals(contact.getName(), "Christian Holm"); + Assert.assertEquals(contact.getAvatar(), new Integer(9)); + Assert.assertEquals(contact.getBirthdate(), new LocalDate(1978, 12, 11)); + Assert.assertEquals(contact.getSkype(), "cho@cubitech.dk"); + Assert.assertEquals(contact.getAbout(), "King of the API, baby!"); + Assert.assertEquals(contact.getAddresses().get(0), + "Borgergade 144, 1.tv."); + Assert.assertEquals(contact.getAddresses().get(1), "1300 København K"); + Assert.assertEquals(contact.getIms(), null); + Assert.assertEquals(contact.getLocations().get(0), "København"); + Assert.assertEquals(contact.getMails().get(0), "dev@hoisthq.com"); + Assert.assertEquals(contact.getMails().get(1), "holm@hoisthq.com"); + Assert.assertEquals(contact.getPhones().get(0), "26217563"); + Assert.assertEquals(contact.getTitles().get(0), "Develoment Team Lead"); + Assert.assertEquals(contact.getUrls().get(0), + "http://www.facebook.com/profile.php?id=504601663"); + Assert.assertEquals(contact.getLastSeenOn(), new DateTime(2011, 7, 23, 13, + 0, 0, 0, DateTimeZone.UTC)); + } + + @Test + public void getContactFieldName() { + List names = getAPI().getContactField(1, ProfileField.NAME); + Assert.assertEquals(names.size(), 1); + Assert.assertEquals(names.get(0), "Christian Holm"); + } + + @Test + public void getContactFieldMail() { + List mails = getAPI().getContactField(1, ProfileField.MAIL); + Assert.assertEquals(mails.size(), 3); + Assert.assertEquals(mails.get(0), "dev@hoisthq.com"); + } + + @Test + public void getContactFieldAvatar() { + List avatars = getAPI() + .getContactField(1, ProfileField.AVATAR); + Assert.assertEquals(avatars.size(), 1); + Assert.assertEquals(avatars.get(0).intValue(), 9); + } + + @Test + public void getContactFieldBirthdate() { + List birthdates = getAPI().getContactField(1, + ProfileField.BIRTHDATE); + Assert.assertEquals(birthdates.size(), 1); + Assert.assertEquals(birthdates.get(0), new LocalDate(1978, 12, 11)); + } + + @Test + public void getContactTotals() { + ContactTotal total = getAPI().getContactTotal(); + + Assert.assertEquals(total.getUser().getCount(), 5); + } + + @Test + public void getSpaceContactsByMail() { + List contacts = getAPI().getSpaceContacts(1, + ProfileField.MAIL, "haugstrup@hoisthq.com", null, null, + ProfileType.FULL, null, ContactType.SPACE); + + Assert.assertEquals(contacts.size(), 1); + Assert.assertEquals(contacts.get(0).getUserId().intValue(), 2); + } +} diff --git a/src/test/java/com/podio/conversation/ConversationAPITest.java b/src/test/java/com/podio/conversation/ConversationAPITest.java index 2275da5..5864f4d 100644 --- a/src/test/java/com/podio/conversation/ConversationAPITest.java +++ b/src/test/java/com/podio/conversation/ConversationAPITest.java @@ -1,67 +1,67 @@ -package com.podio.conversation; - -import java.util.Arrays; -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class ConversationAPITest { - - private ConversationAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(ConversationAPI.class); - } - - @Test - public void createConversation() { - int conversationId = getAPI().createConversation("Subject", "Message", - Arrays.asList(2, 4)); - - Assert.assertTrue(conversationId > 1); - } - - @Test - public void createConversationOnObject() { - int conversation_id = getAPI().createConversation("Subject", "Message", - Arrays.asList(2, 4), new Reference(ReferenceType.ITEM, 1)); - - Assert.assertTrue(conversation_id > 1); - } - - @Test - public void getConversation() { - Conversation conversation = getAPI().getConversation(1); - - Assert.assertEquals(conversation.getId(), 1); - Assert.assertEquals(conversation.getSubject(), - "Isn't all these notification types annoying?"); - Assert.assertEquals(conversation.getParticipants().size(), 2); - Assert.assertEquals(conversation.getParticipants().get(0).getUserId() - .intValue(), 1); - Assert.assertEquals(conversation.getParticipants().get(1).getUserId() - .intValue(), 2); - } - - @Test - public void getConversationsOnObject() { - List conversations = getAPI().getConversationsOnObject( - new Reference(ReferenceType.ITEM, 1)); - - Assert.assertEquals(conversations.size(), 2); - Assert.assertEquals(conversations.get(0).getId(), 6); - Assert.assertEquals(conversations.get(1).getId(), 1); - } - - @Test - public void addReply() { - int messageId = getAPI().addReply(1, "My reply"); - - Assert.assertTrue(messageId > 1); - } -} +package com.podio.conversation; + +import java.util.Arrays; +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class ConversationAPITest { + + private ConversationAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(ConversationAPI.class); + } + + @Test + public void createConversation() { + int conversationId = getAPI().createConversation("Subject", "Message", + Arrays.asList(2, 4)); + + Assert.assertTrue(conversationId > 1); + } + + @Test + public void createConversationOnObject() { + int conversation_id = getAPI().createConversation("Subject", "Message", + Arrays.asList(2, 4), new Reference(ReferenceType.ITEM, 1)); + + Assert.assertTrue(conversation_id > 1); + } + + @Test + public void getConversation() { + Conversation conversation = getAPI().getConversation(1); + + Assert.assertEquals(conversation.getId(), 1); + Assert.assertEquals(conversation.getSubject(), + "Isn't all these notification types annoying?"); + Assert.assertEquals(conversation.getParticipants().size(), 2); + Assert.assertEquals(conversation.getParticipants().get(0).getUserId() + .intValue(), 1); + Assert.assertEquals(conversation.getParticipants().get(1).getUserId() + .intValue(), 2); + } + + @Test + public void getConversationsOnObject() { + List conversations = getAPI().getConversationsOnObject( + new Reference(ReferenceType.ITEM, 1)); + + Assert.assertEquals(conversations.size(), 2); + Assert.assertEquals(conversations.get(0).getId(), 6); + Assert.assertEquals(conversations.get(1).getId(), 1); + } + + @Test + public void addReply() { + int messageId = getAPI().addReply(1, "My reply"); + + Assert.assertTrue(messageId > 1); + } +} diff --git a/src/test/java/com/podio/device/DeviceAPITest.java b/src/test/java/com/podio/device/DeviceAPITest.java index f474851..d8862dc 100644 --- a/src/test/java/com/podio/device/DeviceAPITest.java +++ b/src/test/java/com/podio/device/DeviceAPITest.java @@ -1,15 +1,15 @@ -package com.podio.device; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; - -public class DeviceAPITest { - - private DeviceAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(DeviceAPI.class); - } -} +package com.podio.device; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; + +public class DeviceAPITest { + + private DeviceAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(DeviceAPI.class); + } +} diff --git a/src/test/java/com/podio/embed/EmbedAPITest.java b/src/test/java/com/podio/embed/EmbedAPITest.java index 11d84ad..29fd741 100644 --- a/src/test/java/com/podio/embed/EmbedAPITest.java +++ b/src/test/java/com/podio/embed/EmbedAPITest.java @@ -1,25 +1,25 @@ -package com.podio.embed; - -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; - -public class EmbedAPITest { - - private EmbedAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(EmbedAPI.class); - } - - @Test - public void createEmbed() { - Embed embed = getAPI().createEmbed("https://podio.com"); - - Assert.assertEquals(embed.getUrl(), "https://podio.com"); - Assert.assertEquals(embed.getType(), EmbedType.LINK); - Assert.assertEquals(embed.getTitle(), "Podio - There's a Better Way to Work"); - Assert.assertNotNull(embed.getDescription()); - Assert.assertTrue(embed.getFiles().size() > 0); - - } -} +package com.podio.embed; + +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; + +public class EmbedAPITest { + + private EmbedAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(EmbedAPI.class); + } + + @Test + public void createEmbed() { + Embed embed = getAPI().createEmbed("https://podio.com"); + + Assert.assertEquals(embed.getUrl(), "https://podio.com"); + Assert.assertEquals(embed.getType(), EmbedType.LINK); + Assert.assertEquals(embed.getTitle(), "Podio - There's a Better Way to Work"); + Assert.assertNotNull(embed.getDescription()); + Assert.assertTrue(embed.getFiles().size() > 0); + + } +} diff --git a/src/test/java/com/podio/file/FileAPITest.java b/src/test/java/com/podio/file/FileAPITest.java index 4d33b4d..0ae95b1 100644 --- a/src/test/java/com/podio/file/FileAPITest.java +++ b/src/test/java/com/podio/file/FileAPITest.java @@ -1,72 +1,72 @@ -package com.podio.file; - -import java.io.IOException; -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; - -public class FileAPITest { - - private FileAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(FileAPI.class); - } - - @Test - public void getFile() { - File file = getAPI().getFile(3); - - Assert.assertEquals(file.getId(), 3); - Assert.assertEquals(file.getDescription(), - "Party poster in PNG instead"); - Assert.assertEquals(file.getMimetype().getPrimaryType(), "image"); - Assert.assertEquals(file.getMimetype().getSubType(), "png"); - Assert.assertEquals(file.getName(), "party_poster.png"); - Assert.assertEquals(file.getLink(), "https://files.podio.com/3"); - Assert.assertEquals(file.getPermaLink(), null); - Assert.assertEquals(file.getThumbnailLink(), "https://files.podio.com/3"); - Assert.assertEquals(file.getSize(), 127445); - Assert.assertEquals(file.getCreatedBy().getId(), 1); - Assert.assertEquals(file.getCreatedOn(), new DateTime(2010, 8, 13, 14, - 46, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(file.getReplaces().size(), 1); - Assert.assertEquals(file.getReplaces().get(0).getId(), 2); - } - - @Test - public void deleteFile() { - getAPI().deleteFile(3); - } - - @Test - public void updateFile() { - getAPI().updateFile(3, new FileUpdate("New description")); - } - - @Test - public void getOnSpace() { - List files = getAPI().getOnSpace(1, null, null); - Assert.assertEquals(files.size(), 5); - - File file = files.get(0); - Assert.assertEquals(file.getId(), 31); - } - - @Test - public void getOnApp() { - List files = getAPI().getOnApp(1, null, null); - Assert.assertEquals(files.size(), 1); - - File file = files.get(0); - Assert.assertEquals(file.getId(), 1); - } - - @Test - public void uploadFile() throws IOException { - getAPI().uploadFile("test.txt", new java.io.File("pom.xml")); - } -} +package com.podio.file; + +import java.io.IOException; +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; + +public class FileAPITest { + + private FileAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(FileAPI.class); + } + + @Test + public void getFile() { + File file = getAPI().getFile(3); + + Assert.assertEquals(file.getId(), 3); + Assert.assertEquals(file.getDescription(), + "Party poster in PNG instead"); + Assert.assertEquals(file.getMimetype().getPrimaryType(), "image"); + Assert.assertEquals(file.getMimetype().getSubType(), "png"); + Assert.assertEquals(file.getName(), "party_poster.png"); + Assert.assertEquals(file.getLink(), "https://files.podio.com/3"); + Assert.assertEquals(file.getPermaLink(), null); + Assert.assertEquals(file.getThumbnailLink(), "https://files.podio.com/3"); + Assert.assertEquals(file.getSize(), 127445); + Assert.assertEquals(file.getCreatedBy().getId(), 1); + Assert.assertEquals(file.getCreatedOn(), new DateTime(2010, 8, 13, 14, + 46, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(file.getReplaces().size(), 1); + Assert.assertEquals(file.getReplaces().get(0).getId(), 2); + } + + @Test + public void deleteFile() { + getAPI().deleteFile(3); + } + + @Test + public void updateFile() { + getAPI().updateFile(3, new FileUpdate("New description")); + } + + @Test + public void getOnSpace() { + List files = getAPI().getOnSpace(1, null, null); + Assert.assertEquals(files.size(), 5); + + File file = files.get(0); + Assert.assertEquals(file.getId(), 31); + } + + @Test + public void getOnApp() { + List files = getAPI().getOnApp(1, null, null); + Assert.assertEquals(files.size(), 1); + + File file = files.get(0); + Assert.assertEquals(file.getId(), 1); + } + + @Test + public void uploadFile() throws IOException { + getAPI().uploadFile("test.txt", new java.io.File("pom.xml")); + } +} diff --git a/src/test/java/com/podio/hook/HookAPITest.java b/src/test/java/com/podio/hook/HookAPITest.java index ce69d30..045bf87 100644 --- a/src/test/java/com/podio/hook/HookAPITest.java +++ b/src/test/java/com/podio/hook/HookAPITest.java @@ -1,51 +1,51 @@ -package com.podio.hook; - -import java.util.List; - -import junit.framework.Assert; - -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class HookAPITest { - - private HookAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(HookAPI.class); - } - - @Test - public void create() { - int id = getAPI().create(new Reference(ReferenceType.APP, 1), - new HookCreate("http://foobar.com/test", HookType.ITEM_CREATE)); - Assert.assertTrue(id > 1); - } - - @Test - public void delete() { - getAPI().delete(1); - } - - @Test - public void requestVerification() { - getAPI().requestVerification(2); - } - - @Test - public void validateVerification() { - getAPI().validateVerification(2, "b9079247"); - } - - @Test - public void get() { - List hooks = getAPI().get(new Reference(ReferenceType.APP, 1)); - - Assert.assertEquals(hooks.size(), 9); - Assert.assertEquals(hooks.get(0).getId(), 1); - Assert.assertEquals(hooks.get(0).getUrl(), "http://foobar.com/nowhere"); - Assert.assertEquals(hooks.get(0).getStatus(), HookStatus.ACTIVE); - Assert.assertEquals(hooks.get(0).getType(), HookType.ITEM_CREATE); - } -} +package com.podio.hook; + +import java.util.List; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class HookAPITest { + + private HookAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(HookAPI.class); + } + + @Test + public void create() { + int id = getAPI().create(new Reference(ReferenceType.APP, 1), + new HookCreate("http://foobar.com/test", HookType.ITEM_CREATE)); + Assert.assertTrue(id > 1); + } + + @Test + public void delete() { + getAPI().delete(1); + } + + @Test + public void requestVerification() { + getAPI().requestVerification(2); + } + + @Test + public void validateVerification() { + getAPI().validateVerification(2, "b9079247"); + } + + @Test + public void get() { + List hooks = getAPI().get(new Reference(ReferenceType.APP, 1)); + + Assert.assertEquals(hooks.size(), 9); + Assert.assertEquals(hooks.get(0).getId(), 1); + Assert.assertEquals(hooks.get(0).getUrl(), "http://foobar.com/nowhere"); + Assert.assertEquals(hooks.get(0).getStatus(), HookStatus.ACTIVE); + Assert.assertEquals(hooks.get(0).getType(), HookType.ITEM_CREATE); + } +} diff --git a/src/test/java/com/podio/item/ItemAPITest.java b/src/test/java/com/podio/item/ItemAPITest.java index d4baa33..5697b79 100644 --- a/src/test/java/com/podio/item/ItemAPITest.java +++ b/src/test/java/com/podio/item/ItemAPITest.java @@ -1,281 +1,281 @@ -package com.podio.item; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.joda.time.LocalDate; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.app.ApplicationFieldType; -import com.podio.common.AuthorizationEntityType; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; -import com.podio.filter.CreatedByFilterBy; -import com.podio.filter.CreatedOnFilterBy; -import com.podio.filter.CreatedViaFilterBy; -import com.podio.filter.FilterByValue; -import com.podio.filter.PodioDateInterval; -import com.podio.rating.RatingType; -import com.podio.rating.RatingValue; - -public class ItemAPITest { - - private ItemAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(ItemAPI.class); - } - - @Test - public void addItem() { - int itemId = getAPI().addItem( - 1, - new ItemCreate(null, Arrays.asList(new FieldValuesUpdate(1, - "value", "yes")), Collections. emptyList(), - Collections. emptyList()), false); - - Assert.assertTrue(itemId > 1); - } - - @Test - public void addItemAsApp() { - int itemId = APIFactoryProvider - .getApp(1) - .getAPI(ItemAPI.class) - .addItem( - 1, - new ItemCreate(null, - Arrays.asList(new FieldValuesUpdate(1, "value", - "yes")), Collections - . emptyList(), Collections - . emptyList()), false); - - Assert.assertTrue(itemId > 1); - } - - @Test - public void updateItem() { - getAPI().updateItem( - 1, - new ItemUpdate(null, Arrays.asList(new FieldValuesUpdate(1, - "value", "no"))), false, false); - } - - @Test - public void updateItemExternalId() { - getAPI().updateItem( - 1, - new ItemUpdate(null, Arrays.asList(new FieldValuesUpdate( - "is-hired", "value", "no"))), false, false); - } - - @Test - public void updateItemValues() { - getAPI().updateItemValues(1, - Arrays.asList(new FieldValuesUpdate(1, "value", "no")), false, false); - } - - @Test - public void updateItemValuesExternalId() { - getAPI().updateItemValues( - 1, - Arrays.asList(new FieldValuesUpdate("is-hired", "value", "no")), - false, false); - } - - @Test - public void updateItemFieldValues() { - getAPI().updateItemFieldValues( - 1, - 1, - Collections.singletonList(Collections - . singletonMap("value", "no")), false, false); - } - - @Test - public void deleteItem() { - getAPI().deleteItem(1, false); - } - - @Test - public void getItem() { - Item item = getAPI().getItem(1); - - Assert.assertEquals(item.getId(), 1); - Assert.assertEquals(item.getExternalId(), "12"); - Assert.assertEquals(item.getApplication().getId(), 1); - Assert.assertEquals(item.getApplication().getConfiguration().getName(), "Bugs"); - Assert.assertEquals(item.getApplication().getConfiguration().getItemName(), "Bug"); - Assert.assertEquals(item.getApplication().getConfiguration().getIcon(), "23.png"); - Assert.assertTrue(item.getFields().size() >= 19); - FieldValuesView field = item.getFields().get(0); - Assert.assertEquals(field.getId(), 1); - Assert.assertEquals(field.getExternalId(), "is-hired"); - Assert.assertEquals(field.getType(), ApplicationFieldType.CATEGORY); - Assert.assertEquals(field.getLabel(), "Is hired?"); - Assert.assertEquals(field.getValues().size(), 2); - Assert.assertEquals(((Map) field.getValues().get(0).get("value")).get("text"), "no"); - Assert.assertEquals(field.getValues().get(0).size(), 1); - Assert.assertEquals(((Map)field.getValues().get(1).get("value")).get("text"), "yes"); - Assert.assertEquals(field.getValues().get(1).size(), 1); - Assert.assertEquals(item.getComments().size(), 2); - Assert.assertEquals(item.getRevisions().size(), 1); - Assert.assertEquals(item.getRatings().get(RatingType.APPROVED) - .getCounts(1).getTotal(), 1); - Assert.assertEquals(item.getRatings().get(RatingType.APPROVED) - .getCounts(1).getUsers().get(0).getUserId().intValue(), 2); - Assert.assertEquals(item.getFiles().size(), 1); - Assert.assertEquals(item.getFiles().get(0).getId(), 1); - Assert.assertEquals(item.getTags().size(), 2); - Assert.assertEquals(item.getTags().get(0), "release"); - Assert.assertEquals(item.getTags().get(1), "rollout"); - Assert.assertEquals(item.isSubscribed(), true); - Assert.assertEquals(item.getUserRatings().size(), 5); - Assert.assertEquals(item.getUserRating(RatingType.APPROVED), - new Integer(RatingValue.APPROVED_APPROVES)); - Assert.assertEquals(item.getUserRating(RatingType.FIVESTAR), - new Integer(RatingValue.FIVESTAR_1_STAR)); - Assert.assertEquals(item.getUserRating(RatingType.YESNO), new Integer( - RatingValue.YESNO_YES)); - Assert.assertEquals(item.getUserRating(RatingType.RSVP), new Integer( - RatingValue.RSVP_ATTEND)); - } - - @Test - public void getItemValues() { - List values = getAPI().getItemValues(1); - - Assert.assertTrue(values.size() >= 19); - Assert.assertEquals(values.get(4).getValues().size(), 1); - Assert.assertEquals(values.get(4).getValues().get(0).size(), 1); - Assert.assertEquals(((Map) values.get(4).getValues() - .get(0).get("value")).get("item_id"), 2); - Assert.assertEquals(((Map) values.get(4).getValues() - .get(0).get("value")).get("title"), "no"); - } - - @Test - public void getItemFieldValues() { - List> values = getAPI().getItemFieldValues(1, 5); - - Assert.assertEquals(values.size(), 1); - Assert.assertEquals(values.get(0).size(), 1); - Assert.assertEquals(((Map) values.get(0).get("value")) - .get("item_id"), 2); - Assert.assertEquals( - ((Map) values.get(0).get("value")).get("title"), - "no"); - } - - @Test - public void getItemReferences() { - List references = getAPI().getItemReference(2); - - Assert.assertEquals(references.size(), 1); - ItemReference reference = references.get(0); - Assert.assertEquals(reference.getApplication().getId(), 1); - Assert.assertEquals(reference.getItems().size(), 1); - ItemMicro item = reference.getItems().get(0); - Assert.assertEquals(item.getId(), 1); - Assert.assertEquals(item.getTitle(), "no & yes"); - } - - @Test - public void getItemRevision() { - ItemRevision revision = getAPI().getItemRevision(1, 0); - - Assert.assertEquals(revision.getCreatedBy().getType(), - AuthorizationEntityType.USER); - Assert.assertEquals(revision.getCreatedBy().getId(), 1); - } - - @Test - public void getItemRevisionDifference() { - List differences = getAPI() - .getItemRevisionDifference(2, 0, 1); - - Assert.assertEquals(differences.size(), 2); - Assert.assertEquals(differences.get(0).getId(), 1); - Assert.assertEquals(differences.get(0).getType(), - ApplicationFieldType.CATEGORY); - Assert.assertEquals(differences.get(0).getLabel(), "Is hired?"); - Assert.assertEquals(differences.get(0).getFrom().size(), 1); - Assert.assertEquals(((Map) differences.get(0).getFrom().get(0).get("value")).get("text"), - "yes"); - Assert.assertEquals(differences.get(0).getTo().size(), 1); - Assert.assertEquals(((Map) differences.get(0).getTo().get(0).get("value")).get("text"), - "no"); - } - - @Test - public void getItemRevisions() { - List revisions = getAPI().getItemRevisions(2); - - Assert.assertEquals(revisions.size(), 2); - } - - @Test - public void getItems() { - ItemsResponse response = getAPI().getItems(1, null, null, null, null); - - Assert.assertEquals(response.getTotal(), 2); - Assert.assertEquals(response.getFiltered(), 2); - Assert.assertEquals(response.getItems().size(), 2); - } - - @Test - public void getItemsByExternalId() { - ItemsResponse response = getAPI().getItemsByExternalId(1, "12"); - - Assert.assertEquals(response.getItems().size(), 1); - Assert.assertEquals(response.getItems().get(0).getId(), 1); - } - - @Test - public void getItemsFilterByCreatedBy() { - ItemsResponse response = getAPI().getItems( - 1, - null, - null, - null, - null, - new FilterByValue>(new CreatedByFilterBy(), - Arrays.asList(new Reference(ReferenceType.USER, 0)))); - - Assert.assertEquals(response.getItems().size(), 1); - Assert.assertEquals(response.getItems().get(0).getId(), 1); - } - - @Test - public void getItemsFilterByCreatedVia() { - ItemsResponse response = getAPI().getItems( - 1, - null, - null, - null, - null, - new FilterByValue>(new CreatedViaFilterBy(), - Arrays.asList(2))); - - Assert.assertEquals(response.getItems().size(), 1); - Assert.assertEquals(response.getItems().get(0).getId(), 2); - } - - @Test - public void getItemsFilterByCreatedOn() { - ItemsResponse response = getAPI().getItems( - 1, - null, - null, - null, - null, - new FilterByValue(new CreatedOnFilterBy(), - PodioDateInterval.absolute(new LocalDate(2010, 8, 2), new LocalDate(2010, 8, 5)))); - - Assert.assertEquals(response.getItems().size(), 2); - Assert.assertEquals(response.getItems().get(0).getId(), 2); - Assert.assertEquals(response.getItems().get(1).getId(), 1); - } -} +package com.podio.item; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.joda.time.LocalDate; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.app.ApplicationFieldType; +import com.podio.common.AuthorizationEntityType; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; +import com.podio.filter.CreatedByFilterBy; +import com.podio.filter.CreatedOnFilterBy; +import com.podio.filter.CreatedViaFilterBy; +import com.podio.filter.FilterByValue; +import com.podio.filter.PodioDateInterval; +import com.podio.rating.RatingType; +import com.podio.rating.RatingValue; + +public class ItemAPITest { + + private ItemAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(ItemAPI.class); + } + + @Test + public void addItem() { + int itemId = getAPI().addItem( + 1, + new ItemCreate(null, Arrays.asList(new FieldValuesUpdate(1, + "value", "yes")), Collections. emptyList(), + Collections. emptyList()), false); + + Assert.assertTrue(itemId > 1); + } + + @Test + public void addItemAsApp() { + int itemId = APIFactoryProvider + .getApp(1) + .getAPI(ItemAPI.class) + .addItem( + 1, + new ItemCreate(null, + Arrays.asList(new FieldValuesUpdate(1, "value", + "yes")), Collections + . emptyList(), Collections + . emptyList()), false); + + Assert.assertTrue(itemId > 1); + } + + @Test + public void updateItem() { + getAPI().updateItem( + 1, + new ItemUpdate(null, Arrays.asList(new FieldValuesUpdate(1, + "value", "no"))), false, false); + } + + @Test + public void updateItemExternalId() { + getAPI().updateItem( + 1, + new ItemUpdate(null, Arrays.asList(new FieldValuesUpdate( + "is-hired", "value", "no"))), false, false); + } + + @Test + public void updateItemValues() { + getAPI().updateItemValues(1, + Arrays.asList(new FieldValuesUpdate(1, "value", "no")), false, false); + } + + @Test + public void updateItemValuesExternalId() { + getAPI().updateItemValues( + 1, + Arrays.asList(new FieldValuesUpdate("is-hired", "value", "no")), + false, false); + } + + @Test + public void updateItemFieldValues() { + getAPI().updateItemFieldValues( + 1, + 1, + Collections.singletonList(Collections + . singletonMap("value", "no")), false, false); + } + + @Test + public void deleteItem() { + getAPI().deleteItem(1, false); + } + + @Test + public void getItem() { + Item item = getAPI().getItem(1); + + Assert.assertEquals(item.getId(), 1); + Assert.assertEquals(item.getExternalId(), "12"); + Assert.assertEquals(item.getApplication().getId(), 1); + Assert.assertEquals(item.getApplication().getConfiguration().getName(), "Bugs"); + Assert.assertEquals(item.getApplication().getConfiguration().getItemName(), "Bug"); + Assert.assertEquals(item.getApplication().getConfiguration().getIcon(), "23.png"); + Assert.assertTrue(item.getFields().size() >= 19); + FieldValuesView field = item.getFields().get(0); + Assert.assertEquals(field.getId(), 1); + Assert.assertEquals(field.getExternalId(), "is-hired"); + Assert.assertEquals(field.getType(), ApplicationFieldType.CATEGORY); + Assert.assertEquals(field.getLabel(), "Is hired?"); + Assert.assertEquals(field.getValues().size(), 2); + Assert.assertEquals(((Map) field.getValues().get(0).get("value")).get("text"), "no"); + Assert.assertEquals(field.getValues().get(0).size(), 1); + Assert.assertEquals(((Map)field.getValues().get(1).get("value")).get("text"), "yes"); + Assert.assertEquals(field.getValues().get(1).size(), 1); + Assert.assertEquals(item.getComments().size(), 2); + Assert.assertEquals(item.getRevisions().size(), 1); + Assert.assertEquals(item.getRatings().get(RatingType.APPROVED) + .getCounts(1).getTotal(), 1); + Assert.assertEquals(item.getRatings().get(RatingType.APPROVED) + .getCounts(1).getUsers().get(0).getUserId().intValue(), 2); + Assert.assertEquals(item.getFiles().size(), 1); + Assert.assertEquals(item.getFiles().get(0).getId(), 1); + Assert.assertEquals(item.getTags().size(), 2); + Assert.assertEquals(item.getTags().get(0), "release"); + Assert.assertEquals(item.getTags().get(1), "rollout"); + Assert.assertEquals(item.isSubscribed(), true); + Assert.assertEquals(item.getUserRatings().size(), 5); + Assert.assertEquals(item.getUserRating(RatingType.APPROVED), + new Integer(RatingValue.APPROVED_APPROVES)); + Assert.assertEquals(item.getUserRating(RatingType.FIVESTAR), + new Integer(RatingValue.FIVESTAR_1_STAR)); + Assert.assertEquals(item.getUserRating(RatingType.YESNO), new Integer( + RatingValue.YESNO_YES)); + Assert.assertEquals(item.getUserRating(RatingType.RSVP), new Integer( + RatingValue.RSVP_ATTEND)); + } + + @Test + public void getItemValues() { + List values = getAPI().getItemValues(1); + + Assert.assertTrue(values.size() >= 19); + Assert.assertEquals(values.get(4).getValues().size(), 1); + Assert.assertEquals(values.get(4).getValues().get(0).size(), 1); + Assert.assertEquals(((Map) values.get(4).getValues() + .get(0).get("value")).get("item_id"), 2); + Assert.assertEquals(((Map) values.get(4).getValues() + .get(0).get("value")).get("title"), "no"); + } + + @Test + public void getItemFieldValues() { + List> values = getAPI().getItemFieldValues(1, 5); + + Assert.assertEquals(values.size(), 1); + Assert.assertEquals(values.get(0).size(), 1); + Assert.assertEquals(((Map) values.get(0).get("value")) + .get("item_id"), 2); + Assert.assertEquals( + ((Map) values.get(0).get("value")).get("title"), + "no"); + } + + @Test + public void getItemReferences() { + List references = getAPI().getItemReference(2); + + Assert.assertEquals(references.size(), 1); + ItemReference reference = references.get(0); + Assert.assertEquals(reference.getApplication().getId(), 1); + Assert.assertEquals(reference.getItems().size(), 1); + ItemMicro item = reference.getItems().get(0); + Assert.assertEquals(item.getId(), 1); + Assert.assertEquals(item.getTitle(), "no & yes"); + } + + @Test + public void getItemRevision() { + ItemRevision revision = getAPI().getItemRevision(1, 0); + + Assert.assertEquals(revision.getCreatedBy().getType(), + AuthorizationEntityType.USER); + Assert.assertEquals(revision.getCreatedBy().getId(), 1); + } + + @Test + public void getItemRevisionDifference() { + List differences = getAPI() + .getItemRevisionDifference(2, 0, 1); + + Assert.assertEquals(differences.size(), 2); + Assert.assertEquals(differences.get(0).getId(), 1); + Assert.assertEquals(differences.get(0).getType(), + ApplicationFieldType.CATEGORY); + Assert.assertEquals(differences.get(0).getLabel(), "Is hired?"); + Assert.assertEquals(differences.get(0).getFrom().size(), 1); + Assert.assertEquals(((Map) differences.get(0).getFrom().get(0).get("value")).get("text"), + "yes"); + Assert.assertEquals(differences.get(0).getTo().size(), 1); + Assert.assertEquals(((Map) differences.get(0).getTo().get(0).get("value")).get("text"), + "no"); + } + + @Test + public void getItemRevisions() { + List revisions = getAPI().getItemRevisions(2); + + Assert.assertEquals(revisions.size(), 2); + } + + @Test + public void getItems() { + ItemsResponse response = getAPI().getItems(1, null, null, null, null); + + Assert.assertEquals(response.getTotal(), 2); + Assert.assertEquals(response.getFiltered(), 2); + Assert.assertEquals(response.getItems().size(), 2); + } + + @Test + public void getItemsByExternalId() { + ItemsResponse response = getAPI().getItemsByExternalId(1, "12"); + + Assert.assertEquals(response.getItems().size(), 1); + Assert.assertEquals(response.getItems().get(0).getId(), 1); + } + + @Test + public void getItemsFilterByCreatedBy() { + ItemsResponse response = getAPI().getItems( + 1, + null, + null, + null, + null, + new FilterByValue>(new CreatedByFilterBy(), + Arrays.asList(new Reference(ReferenceType.USER, 0)))); + + Assert.assertEquals(response.getItems().size(), 1); + Assert.assertEquals(response.getItems().get(0).getId(), 1); + } + + @Test + public void getItemsFilterByCreatedVia() { + ItemsResponse response = getAPI().getItems( + 1, + null, + null, + null, + null, + new FilterByValue>(new CreatedViaFilterBy(), + Arrays.asList(2))); + + Assert.assertEquals(response.getItems().size(), 1); + Assert.assertEquals(response.getItems().get(0).getId(), 2); + } + + @Test + public void getItemsFilterByCreatedOn() { + ItemsResponse response = getAPI().getItems( + 1, + null, + null, + null, + null, + new FilterByValue(new CreatedOnFilterBy(), + PodioDateInterval.absolute(new LocalDate(2010, 8, 2), new LocalDate(2010, 8, 5)))); + + Assert.assertEquals(response.getItems().size(), 2); + Assert.assertEquals(response.getItems().get(0).getId(), 2); + Assert.assertEquals(response.getItems().get(1).getId(), 1); + } +} diff --git a/src/test/java/com/podio/item/map/BugMap1.java b/src/test/java/com/podio/item/map/BugMap1.java index b52613e..320a6ff 100644 --- a/src/test/java/com/podio/item/map/BugMap1.java +++ b/src/test/java/com/podio/item/map/BugMap1.java @@ -1,99 +1,99 @@ -package com.podio.item.map; - -import java.math.BigDecimal; -import java.util.Set; - -import org.joda.money.Money; - -public class BugMap1 { - - private int externalId; - - private Set statuses; - - private Money alottaCash; - - private String writeAJoke; - - private BigDecimal importance; - - private int howFarAreWe; - - private String ignored; - - public BugMap1() { - super(); - } - - public BugMap1(int externalId, Set statuses, - Money alottaCash, String writeAJoke, BigDecimal importance, - int howFarAreWe, String ignored) { - super(); - this.externalId = externalId; - this.statuses = statuses; - this.alottaCash = alottaCash; - this.writeAJoke = writeAJoke; - this.importance = importance; - this.howFarAreWe = howFarAreWe; - this.ignored = ignored; - } - - @ExternalId - public int getExternalId() { - return externalId; - } - - public void setExternalId(int externalId) { - this.externalId = externalId; - } - - @Field("is-hired") - public Set getStatuses() { - return statuses; - } - - public void setStatuses(Set statuses) { - this.statuses = statuses; - } - - public Money getAlottaCash() { - return alottaCash; - } - - public void setAlottaCash(Money money) { - this.alottaCash = money; - } - - public String getWriteAJoke() { - return writeAJoke; - } - - public void setWriteAJoke(String writeAJoke) { - this.writeAJoke = writeAJoke; - } - - public BigDecimal getImportance() { - return importance; - } - - public void setImportance(BigDecimal importance) { - this.importance = importance; - } - - public int getHowFarAreWe() { - return howFarAreWe; - } - - public void setHowFarAreWe(int howFarAreWe) { - this.howFarAreWe = howFarAreWe; - } - - @Transient - public String getIgnored() { - return ignored; - } - - public void setIgnored(String ignored) { - this.ignored = ignored; - } +package com.podio.item.map; + +import java.math.BigDecimal; +import java.util.Set; + +import org.joda.money.Money; + +public class BugMap1 { + + private int externalId; + + private Set statuses; + + private Money alottaCash; + + private String writeAJoke; + + private BigDecimal importance; + + private int howFarAreWe; + + private String ignored; + + public BugMap1() { + super(); + } + + public BugMap1(int externalId, Set statuses, + Money alottaCash, String writeAJoke, BigDecimal importance, + int howFarAreWe, String ignored) { + super(); + this.externalId = externalId; + this.statuses = statuses; + this.alottaCash = alottaCash; + this.writeAJoke = writeAJoke; + this.importance = importance; + this.howFarAreWe = howFarAreWe; + this.ignored = ignored; + } + + @ExternalId + public int getExternalId() { + return externalId; + } + + public void setExternalId(int externalId) { + this.externalId = externalId; + } + + @Field("is-hired") + public Set getStatuses() { + return statuses; + } + + public void setStatuses(Set statuses) { + this.statuses = statuses; + } + + public Money getAlottaCash() { + return alottaCash; + } + + public void setAlottaCash(Money money) { + this.alottaCash = money; + } + + public String getWriteAJoke() { + return writeAJoke; + } + + public void setWriteAJoke(String writeAJoke) { + this.writeAJoke = writeAJoke; + } + + public BigDecimal getImportance() { + return importance; + } + + public void setImportance(BigDecimal importance) { + this.importance = importance; + } + + public int getHowFarAreWe() { + return howFarAreWe; + } + + public void setHowFarAreWe(int howFarAreWe) { + this.howFarAreWe = howFarAreWe; + } + + @Transient + public String getIgnored() { + return ignored; + } + + public void setIgnored(String ignored) { + this.ignored = ignored; + } } \ No newline at end of file diff --git a/src/test/java/com/podio/item/map/BugMap2.java b/src/test/java/com/podio/item/map/BugMap2.java index 14fdd6e..d50faed 100644 --- a/src/test/java/com/podio/item/map/BugMap2.java +++ b/src/test/java/com/podio/item/map/BugMap2.java @@ -1,73 +1,73 @@ -package com.podio.item.map; - -import java.math.BigDecimal; -import java.util.List; - -public class BugMap2 { - - private long externalId; - - private List statuses; - - private BigDecimal alottaCash; - - private double importance; - - private Short howFarAreWe; - - public BugMap2() { - super(); - } - - public BugMap2(long externalId, List statuses, - BigDecimal alottaCash, double importance, Short howFarAreWe) { - super(); - this.externalId = externalId; - this.statuses = statuses; - this.alottaCash = alottaCash; - this.importance = importance; - this.howFarAreWe = howFarAreWe; - } - - @ExternalId - public long getExternalId() { - return externalId; - } - - public void setExternalId(long externalId) { - this.externalId = externalId; - } - - @Field("is-hired") - public List getStatuses() { - return statuses; - } - - public void setStatuses(List statuses) { - this.statuses = statuses; - } - - public BigDecimal getAlottaCash() { - return alottaCash; - } - - public void setAlottaCash(BigDecimal amount) { - this.alottaCash = amount; - } - - public double getImportance() { - return importance; - } - - public void setImportance(double importance) { - this.importance = importance; - } - - public Short getHowFarAreWe() { - return howFarAreWe; - } - - public void setHowFarAreWe(Short howFarAreWe) { - this.howFarAreWe = howFarAreWe; - } +package com.podio.item.map; + +import java.math.BigDecimal; +import java.util.List; + +public class BugMap2 { + + private long externalId; + + private List statuses; + + private BigDecimal alottaCash; + + private double importance; + + private Short howFarAreWe; + + public BugMap2() { + super(); + } + + public BugMap2(long externalId, List statuses, + BigDecimal alottaCash, double importance, Short howFarAreWe) { + super(); + this.externalId = externalId; + this.statuses = statuses; + this.alottaCash = alottaCash; + this.importance = importance; + this.howFarAreWe = howFarAreWe; + } + + @ExternalId + public long getExternalId() { + return externalId; + } + + public void setExternalId(long externalId) { + this.externalId = externalId; + } + + @Field("is-hired") + public List getStatuses() { + return statuses; + } + + public void setStatuses(List statuses) { + this.statuses = statuses; + } + + public BigDecimal getAlottaCash() { + return alottaCash; + } + + public void setAlottaCash(BigDecimal amount) { + this.alottaCash = amount; + } + + public double getImportance() { + return importance; + } + + public void setImportance(double importance) { + this.importance = importance; + } + + public Short getHowFarAreWe() { + return howFarAreWe; + } + + public void setHowFarAreWe(Short howFarAreWe) { + this.howFarAreWe = howFarAreWe; + } } \ No newline at end of file diff --git a/src/test/java/com/podio/item/map/BugMap3.java b/src/test/java/com/podio/item/map/BugMap3.java index afb1cad..3083ffa 100644 --- a/src/test/java/com/podio/item/map/BugMap3.java +++ b/src/test/java/com/podio/item/map/BugMap3.java @@ -1,63 +1,63 @@ -package com.podio.item.map; - -import java.util.Collection; - -public class BugMap3 { - - private String externalId; - - private Collection statuses; - - private double amount; - - private float importance; - - public BugMap3() { - super(); - } - - public BugMap3(String externalId, Collection statuses, - double amount, float importance) { - super(); - this.externalId = externalId; - this.statuses = statuses; - this.amount = amount; - this.importance = importance; - } - - @ExternalId - public String getExternalId() { - return externalId; - } - - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - @Field("is-hired") - public Collection getStatuses() { - return statuses; - } - - public void setStatuses(Collection statuses) { - this.statuses = statuses; - } - - @MoneyField(currency = "EUR") - @Field("alotta-cash") - public double getAmount() { - return amount; - } - - public void setAmount(double amount) { - this.amount = amount; - } - - public float getImportance() { - return importance; - } - - public void setImportance(float importance) { - this.importance = importance; - } +package com.podio.item.map; + +import java.util.Collection; + +public class BugMap3 { + + private String externalId; + + private Collection statuses; + + private double amount; + + private float importance; + + public BugMap3() { + super(); + } + + public BugMap3(String externalId, Collection statuses, + double amount, float importance) { + super(); + this.externalId = externalId; + this.statuses = statuses; + this.amount = amount; + this.importance = importance; + } + + @ExternalId + public String getExternalId() { + return externalId; + } + + public void setExternalId(String externalId) { + this.externalId = externalId; + } + + @Field("is-hired") + public Collection getStatuses() { + return statuses; + } + + public void setStatuses(Collection statuses) { + this.statuses = statuses; + } + + @MoneyField(currency = "EUR") + @Field("alotta-cash") + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } + + public float getImportance() { + return importance; + } + + public void setImportance(float importance) { + this.importance = importance; + } } \ No newline at end of file diff --git a/src/test/java/com/podio/item/map/HireStatus.java b/src/test/java/com/podio/item/map/HireStatus.java index 07179e9..a61cf9a 100644 --- a/src/test/java/com/podio/item/map/HireStatus.java +++ b/src/test/java/com/podio/item/map/HireStatus.java @@ -1,7 +1,7 @@ -package com.podio.item.map; - -public enum HireStatus { - - YES, - NO; -} +package com.podio.item.map; + +public enum HireStatus { + + YES, + NO; +} diff --git a/src/test/java/com/podio/item/map/ItemMapTest.java b/src/test/java/com/podio/item/map/ItemMapTest.java index ceb047f..6ebaa78 100644 --- a/src/test/java/com/podio/item/map/ItemMapTest.java +++ b/src/test/java/com/podio/item/map/ItemMapTest.java @@ -1,130 +1,130 @@ -package com.podio.item.map; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; - -import org.joda.money.CurrencyUnit; -import org.joda.money.Money; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.app.AppAPI; -import com.podio.app.Application; -import com.podio.item.FieldValuesUpdate; -import com.podio.item.Item; -import com.podio.item.ItemAPI; -import com.podio.item.ItemCreate; -import com.podio.item.ItemUpdate; - -public class ItemMapTest { - - @Test - public void mapTest1() { - ItemCreate create = getCreate( - 1, - new BugMap1(1, Collections.singleton(HireStatus.YES), Money.of( - CurrencyUnit.EUR, new BigDecimal("123.45")), - "A mexican in a bar", new BigDecimal("1.2"), 30, - "Ignored")); - Assert.assertEquals(create.getExternalId(), "1"); - checkValue(create.getFields(), "is-hired", 0, "value", 1); - checkValue(create.getFields(), "alotta-cash", 0, "value", "123.45"); - checkValue(create.getFields(), "alotta-cash", 0, "currency", "EUR"); - checkValue(create.getFields(), "write-a-joke", 0, "value", - "A mexican in a bar"); - checkValue(create.getFields(), "importance", 0, "value", "1.2"); - checkValue(create.getFields(), "how-far-are-we", 0, "value", 30); - Assert.assertEquals(create.getFileIds().size(), 0); - Assert.assertEquals(create.getTags().size(), 0); - - BugMap1 model = getView(1, 1, BugMap1.class); - Assert.assertEquals(model.getExternalId(), 12); - Assert.assertTrue(model.getStatuses().contains(HireStatus.YES)); - Assert.assertEquals(model.getAlottaCash().getAmount(), new BigDecimal( - "256.50")); - Assert.assertEquals(model.getAlottaCash().getCurrencyUnit() - .getCurrencyCode(), "DKK"); - Assert.assertEquals(model.getWriteAJoke(), "

æøå

"); - Assert.assertEquals(model.getImportance(), new BigDecimal("2.2000")); - Assert.assertEquals(model.getHowFarAreWe(), 15); - } - - @Test - public void mapTest2() { - ItemCreate create = getCreate(1, - new BugMap2(2, Collections.singletonList("yes"), - new BigDecimal("123.45"), 1.2d, (short) 30)); - Assert.assertEquals(create.getExternalId(), "2"); - checkValue(create.getFields(), "is-hired", 0, "value", 1); - checkValue(create.getFields(), "alotta-cash", 0, "value", "123.45"); - checkValue(create.getFields(), "alotta-cash", 0, "currency", "DKK"); - checkValue(create.getFields(), "importance", 0, "value", "1.2"); - checkValue(create.getFields(), "how-far-are-we", 0, "value", 30); - Assert.assertEquals(create.getFileIds().size(), 0); - Assert.assertEquals(create.getTags().size(), 0); - - BugMap2 model = getView(1, 1, BugMap2.class); - Assert.assertEquals(model.getExternalId(), 12); - Assert.assertTrue(model.getStatuses().contains("yes")); - Assert.assertEquals(model.getAlottaCash(), new BigDecimal("256.5000")); - Assert.assertEquals(model.getImportance(), 2.2d, 0); - Assert.assertEquals(model.getHowFarAreWe(), new Short((short) 15)); - } - - @Test - public void mapTest3() { - ItemCreate create = getCreate(1, - new BugMap3("3", Collections.singleton("yes"), 123.45, 1.2f)); - Assert.assertEquals(create.getExternalId(), "3"); - checkValue(create.getFields(), "is-hired", 0, "value", 1); - checkValue(create.getFields(), "alotta-cash", 0, "value", "123.45"); - checkValue(create.getFields(), "alotta-cash", 0, "currency", "EUR"); - checkValue(create.getFields(), "importance", 0, "value", "1.2"); - Assert.assertEquals(create.getFileIds().size(), 0); - Assert.assertEquals(create.getTags().size(), 0); - - BugMap3 model = getView(1, 1, BugMap3.class); - Assert.assertEquals(model.getExternalId(), "12"); - Assert.assertTrue(model.getStatuses().contains("yes")); - Assert.assertEquals(model.getAmount(), 256.5, 0); - Assert.assertEquals(model.getImportance(), 2.2f, 0); - } - - private ItemMap getMap(int appId, Class cls) { - Application application = APIFactoryProvider.getDefault() - .getAPI(AppAPI.class).getApp(appId); - - ItemMap itemMap = (ItemMap) ItemMap.get(application, cls); - return itemMap; - } - - private ItemCreate getCreate(int appId, T value) { - return getMap(appId, value.getClass()).getCreate(value); - } - - private ItemUpdate getUpdate(int appId, T value) { - return getMap(appId, value.getClass()).getUpdate(value); - } - - private T getView(int appId, int itemId, Class cls) { - Item item = APIFactoryProvider.getDefault().getAPI(ItemAPI.class) - .getItem(itemId); - - return (T) getMap(appId, cls).getView(item); - } - - private void checkValue(List updates, String externalId, - int delta, String key, Object value) { - for (FieldValuesUpdate update : updates) { - if (update.getExternalId().equals(externalId)) { - Assert.assertEquals(update.getValues().get(delta).get(key), - value); - return; - } - } - - Assert.fail("No field found with external id " + externalId); - } -} +package com.podio.item.map; + +import java.math.BigDecimal; +import java.util.Collections; +import java.util.List; + +import org.joda.money.CurrencyUnit; +import org.joda.money.Money; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.app.AppAPI; +import com.podio.app.Application; +import com.podio.item.FieldValuesUpdate; +import com.podio.item.Item; +import com.podio.item.ItemAPI; +import com.podio.item.ItemCreate; +import com.podio.item.ItemUpdate; + +public class ItemMapTest { + + @Test + public void mapTest1() { + ItemCreate create = getCreate( + 1, + new BugMap1(1, Collections.singleton(HireStatus.YES), Money.of( + CurrencyUnit.EUR, new BigDecimal("123.45")), + "A mexican in a bar", new BigDecimal("1.2"), 30, + "Ignored")); + Assert.assertEquals(create.getExternalId(), "1"); + checkValue(create.getFields(), "is-hired", 0, "value", 1); + checkValue(create.getFields(), "alotta-cash", 0, "value", "123.45"); + checkValue(create.getFields(), "alotta-cash", 0, "currency", "EUR"); + checkValue(create.getFields(), "write-a-joke", 0, "value", + "A mexican in a bar"); + checkValue(create.getFields(), "importance", 0, "value", "1.2"); + checkValue(create.getFields(), "how-far-are-we", 0, "value", 30); + Assert.assertEquals(create.getFileIds().size(), 0); + Assert.assertEquals(create.getTags().size(), 0); + + BugMap1 model = getView(1, 1, BugMap1.class); + Assert.assertEquals(model.getExternalId(), 12); + Assert.assertTrue(model.getStatuses().contains(HireStatus.YES)); + Assert.assertEquals(model.getAlottaCash().getAmount(), new BigDecimal( + "256.50")); + Assert.assertEquals(model.getAlottaCash().getCurrencyUnit() + .getCurrencyCode(), "DKK"); + Assert.assertEquals(model.getWriteAJoke(), "

æøå

"); + Assert.assertEquals(model.getImportance(), new BigDecimal("2.2000")); + Assert.assertEquals(model.getHowFarAreWe(), 15); + } + + @Test + public void mapTest2() { + ItemCreate create = getCreate(1, + new BugMap2(2, Collections.singletonList("yes"), + new BigDecimal("123.45"), 1.2d, (short) 30)); + Assert.assertEquals(create.getExternalId(), "2"); + checkValue(create.getFields(), "is-hired", 0, "value", 1); + checkValue(create.getFields(), "alotta-cash", 0, "value", "123.45"); + checkValue(create.getFields(), "alotta-cash", 0, "currency", "DKK"); + checkValue(create.getFields(), "importance", 0, "value", "1.2"); + checkValue(create.getFields(), "how-far-are-we", 0, "value", 30); + Assert.assertEquals(create.getFileIds().size(), 0); + Assert.assertEquals(create.getTags().size(), 0); + + BugMap2 model = getView(1, 1, BugMap2.class); + Assert.assertEquals(model.getExternalId(), 12); + Assert.assertTrue(model.getStatuses().contains("yes")); + Assert.assertEquals(model.getAlottaCash(), new BigDecimal("256.5000")); + Assert.assertEquals(model.getImportance(), 2.2d, 0); + Assert.assertEquals(model.getHowFarAreWe(), new Short((short) 15)); + } + + @Test + public void mapTest3() { + ItemCreate create = getCreate(1, + new BugMap3("3", Collections.singleton("yes"), 123.45, 1.2f)); + Assert.assertEquals(create.getExternalId(), "3"); + checkValue(create.getFields(), "is-hired", 0, "value", 1); + checkValue(create.getFields(), "alotta-cash", 0, "value", "123.45"); + checkValue(create.getFields(), "alotta-cash", 0, "currency", "EUR"); + checkValue(create.getFields(), "importance", 0, "value", "1.2"); + Assert.assertEquals(create.getFileIds().size(), 0); + Assert.assertEquals(create.getTags().size(), 0); + + BugMap3 model = getView(1, 1, BugMap3.class); + Assert.assertEquals(model.getExternalId(), "12"); + Assert.assertTrue(model.getStatuses().contains("yes")); + Assert.assertEquals(model.getAmount(), 256.5, 0); + Assert.assertEquals(model.getImportance(), 2.2f, 0); + } + + private ItemMap getMap(int appId, Class cls) { + Application application = APIFactoryProvider.getDefault() + .getAPI(AppAPI.class).getApp(appId); + + ItemMap itemMap = (ItemMap) ItemMap.get(application, cls); + return itemMap; + } + + private ItemCreate getCreate(int appId, T value) { + return getMap(appId, value.getClass()).getCreate(value); + } + + private ItemUpdate getUpdate(int appId, T value) { + return getMap(appId, value.getClass()).getUpdate(value); + } + + private T getView(int appId, int itemId, Class cls) { + Item item = APIFactoryProvider.getDefault().getAPI(ItemAPI.class) + .getItem(itemId); + + return (T) getMap(appId, cls).getView(item); + } + + private void checkValue(List updates, String externalId, + int delta, String key, Object value) { + for (FieldValuesUpdate update : updates) { + if (update.getExternalId().equals(externalId)) { + Assert.assertEquals(update.getValues().get(delta).get(key), + value); + return; + } + } + + Assert.fail("No field found with external id " + externalId); + } +} diff --git a/src/test/java/com/podio/item/map/MappedItemAPITest.java b/src/test/java/com/podio/item/map/MappedItemAPITest.java index 18efa57..0690557 100644 --- a/src/test/java/com/podio/item/map/MappedItemAPITest.java +++ b/src/test/java/com/podio/item/map/MappedItemAPITest.java @@ -1,42 +1,42 @@ -package com.podio.item.map; - -import java.math.BigDecimal; -import java.util.Collections; - -import org.joda.money.CurrencyUnit; -import org.joda.money.Money; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; - -public class MappedItemAPITest { - - private MappedItemAPI getMappedAPI(Class cls) { - return new MappedItemAPI(APIFactoryProvider.getDefault(), 1, cls); - } - - @Test - public void getItem() { - BugMap1 bug = getMappedAPI(BugMap1.class).get(12); - - Assert.assertEquals(bug.getExternalId(), 12); - Assert.assertTrue(bug.getStatuses().contains(HireStatus.YES)); - Assert.assertEquals(bug.getAlottaCash().getAmount(), new BigDecimal( - "256.50")); - Assert.assertEquals(bug.getAlottaCash().getCurrencyUnit() - .getCurrencyCode(), "DKK"); - Assert.assertEquals(bug.getWriteAJoke(), "

æøå

"); - Assert.assertEquals(bug.getImportance(), new BigDecimal("2.2000")); - Assert.assertEquals(bug.getHowFarAreWe(), 15); - } - - @Test - public void createItem() { - BugMap1 bug = new BugMap1(1, Collections.singleton(HireStatus.YES), - Money.of(CurrencyUnit.EUR, new BigDecimal("123.45")), - "A mexican in a bar", new BigDecimal("1.2"), 30, "Ignored"); - int itemId = getMappedAPI(BugMap1.class).insert(bug, true); - Assert.assertTrue(itemId > 0); - } -} +package com.podio.item.map; + +import java.math.BigDecimal; +import java.util.Collections; + +import org.joda.money.CurrencyUnit; +import org.joda.money.Money; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; + +public class MappedItemAPITest { + + private MappedItemAPI getMappedAPI(Class cls) { + return new MappedItemAPI(APIFactoryProvider.getDefault(), 1, cls); + } + + @Test + public void getItem() { + BugMap1 bug = getMappedAPI(BugMap1.class).get(12); + + Assert.assertEquals(bug.getExternalId(), 12); + Assert.assertTrue(bug.getStatuses().contains(HireStatus.YES)); + Assert.assertEquals(bug.getAlottaCash().getAmount(), new BigDecimal( + "256.50")); + Assert.assertEquals(bug.getAlottaCash().getCurrencyUnit() + .getCurrencyCode(), "DKK"); + Assert.assertEquals(bug.getWriteAJoke(), "

æøå

"); + Assert.assertEquals(bug.getImportance(), new BigDecimal("2.2000")); + Assert.assertEquals(bug.getHowFarAreWe(), 15); + } + + @Test + public void createItem() { + BugMap1 bug = new BugMap1(1, Collections.singleton(HireStatus.YES), + Money.of(CurrencyUnit.EUR, new BigDecimal("123.45")), + "A mexican in a bar", new BigDecimal("1.2"), 30, "Ignored"); + int itemId = getMappedAPI(BugMap1.class).insert(bug, true); + Assert.assertTrue(itemId > 0); + } +} diff --git a/src/test/java/com/podio/item/map/NameUtilTest.java b/src/test/java/com/podio/item/map/NameUtilTest.java index bd2e575..8fc00c7 100644 --- a/src/test/java/com/podio/item/map/NameUtilTest.java +++ b/src/test/java/com/podio/item/map/NameUtilTest.java @@ -1,21 +1,21 @@ -package com.podio.item.map; - -import org.junit.Assert; -import org.junit.Test; - -public class NameUtilTest { - - @Test - public void toJava() { - Assert.assertEquals(NameUtil.toJava("is-hired"), "isHired"); - Assert.assertEquals(NameUtil.toJava("hired"), "hired"); - Assert.assertEquals(NameUtil.toJava("is-hired-ok"), "isHiredOk"); - } - - @Test - public void toAPI() { - Assert.assertEquals(NameUtil.toAPI("isHired"), "is-hired"); - Assert.assertEquals(NameUtil.toAPI("hired"), "hired"); - Assert.assertEquals(NameUtil.toAPI("isHiredOk"), "is-hired-ok"); - } -} +package com.podio.item.map; + +import org.junit.Assert; +import org.junit.Test; + +public class NameUtilTest { + + @Test + public void toJava() { + Assert.assertEquals(NameUtil.toJava("is-hired"), "isHired"); + Assert.assertEquals(NameUtil.toJava("hired"), "hired"); + Assert.assertEquals(NameUtil.toJava("is-hired-ok"), "isHiredOk"); + } + + @Test + public void toAPI() { + Assert.assertEquals(NameUtil.toAPI("isHired"), "is-hired"); + Assert.assertEquals(NameUtil.toAPI("hired"), "hired"); + Assert.assertEquals(NameUtil.toAPI("isHiredOk"), "is-hired-ok"); + } +} diff --git a/src/test/java/com/podio/item/map/converter/MoneyConverterTest.java b/src/test/java/com/podio/item/map/converter/MoneyConverterTest.java index 7eeefd0..64ec933 100644 --- a/src/test/java/com/podio/item/map/converter/MoneyConverterTest.java +++ b/src/test/java/com/podio/item/map/converter/MoneyConverterTest.java @@ -1,31 +1,31 @@ -package com.podio.item.map.converter; - -import java.math.BigDecimal; -import java.util.Map; - -import org.joda.money.CurrencyUnit; -import org.joda.money.Money; -import org.junit.Assert; -import org.junit.Test; - -public class MoneyConverterTest { - - @Test - public void fromModel() { - MoneyConverter converter = new MoneyConverter(CurrencyUnit.of("DKK")); - - Map result = converter.fromModel(Money.of( - CurrencyUnit.of("EUR"), new BigDecimal("123.45"))); - Assert.assertEquals(result.get("value"), "123.45"); - Assert.assertEquals(result.get("currency"), "EUR"); - - result = converter.fromModel(new BigDecimal("123.45")); - Assert.assertEquals(result.get("value"), "123.45"); - Assert.assertEquals(result.get("currency"), "DKK"); - - result = converter.fromModel(123l); - Assert.assertEquals(result.get("value"), "123"); - Assert.assertEquals(result.get("currency"), "DKK"); - - } -} +package com.podio.item.map.converter; + +import java.math.BigDecimal; +import java.util.Map; + +import org.joda.money.CurrencyUnit; +import org.joda.money.Money; +import org.junit.Assert; +import org.junit.Test; + +public class MoneyConverterTest { + + @Test + public void fromModel() { + MoneyConverter converter = new MoneyConverter(CurrencyUnit.of("DKK")); + + Map result = converter.fromModel(Money.of( + CurrencyUnit.of("EUR"), new BigDecimal("123.45"))); + Assert.assertEquals(result.get("value"), "123.45"); + Assert.assertEquals(result.get("currency"), "EUR"); + + result = converter.fromModel(new BigDecimal("123.45")); + Assert.assertEquals(result.get("value"), "123.45"); + Assert.assertEquals(result.get("currency"), "DKK"); + + result = converter.fromModel(123l); + Assert.assertEquals(result.get("value"), "123"); + Assert.assertEquals(result.get("currency"), "DKK"); + + } +} diff --git a/src/test/java/com/podio/notification/NotificationAPITest.java b/src/test/java/com/podio/notification/NotificationAPITest.java index 4600821..e66d524 100644 --- a/src/test/java/com/podio/notification/NotificationAPITest.java +++ b/src/test/java/com/podio/notification/NotificationAPITest.java @@ -1,25 +1,25 @@ -package com.podio.notification; - -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; - -public class NotificationAPITest { - - private NotificationAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(NotificationAPI.class); - } - - @Test - public void getInboxNewCount() { - int count = getAPI().getInboxNewCount(); - - Assert.assertEquals(count, 59); - } - - @Test - public void markAsViewed() { - getAPI().markAsViewed(4); - } -} +package com.podio.notification; + +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; + +public class NotificationAPITest { + + private NotificationAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(NotificationAPI.class); + } + + @Test + public void getInboxNewCount() { + int count = getAPI().getInboxNewCount(); + + Assert.assertEquals(count, 59); + } + + @Test + public void markAsViewed() { + getAPI().markAsViewed(4); + } +} diff --git a/src/test/java/com/podio/org/OrgAPITest.java b/src/test/java/com/podio/org/OrgAPITest.java index 2964aed..58148d9 100644 --- a/src/test/java/com/podio/org/OrgAPITest.java +++ b/src/test/java/com/podio/org/OrgAPITest.java @@ -1,149 +1,149 @@ -package com.podio.org; - -import java.net.URISyntaxException; -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Role; -import com.podio.space.Space; -import com.podio.space.SpaceMini; - -public class OrgAPITest { - - private OrgAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(OrgAPI.class); - } - - @Test - public void createOrganization() { - OrganizationCreateResponse response = getAPI().createOrganization( - new OrganizationCreate("CubiTech2", null)); - - Assert.assertTrue(response.getId() > 1); - Assert.assertEquals(response.getUrl(), "https://podio.com/cubitech2"); - } - - @Test - public void getOrganization() { - Organization org = getAPI().getOrganization(1); - - Assert.assertEquals(org.getId(), 1); - Assert.assertEquals(org.getName(), "Hoist"); - Assert.assertEquals(org.getUrl(), "https://podio.com/hoist"); - Assert.assertEquals(org.getLogo().intValue(), 10); - Assert.assertEquals(org.getStatus(), OrganizationStatus.ACTIVE); - Assert.assertEquals(org.getUserLimit(), 50); - Assert.assertEquals(org.getCreatedBy().getUserId().intValue(), 1); - Assert.assertEquals(org.getCreatedOn(), new DateTime(2010, 8, 6, 23, 1, - 0, 0, DateTimeZone.UTC)); - } - - @Test - public void updateOrganization() { - getAPI().updateOrganization(1, new OrganizationCreate("New name", null)); - } - - @Test - public void getOrganizations() throws URISyntaxException { - List organizations = getAPI() - .getOrganizations(); - Assert.assertEquals(organizations.size(), 4); - - OrganizationWithSpaces org = organizations.get(0); - Assert.assertEquals(org.getId(), 1); - Assert.assertEquals(org.getName(), "Hoist"); - List spaces = org.getSpaces(); - Assert.assertEquals(spaces.size(), 3); - SpaceMini space = spaces.get(0); - Assert.assertEquals(space.getId(), 1); - Assert.assertEquals(space.getName(), "API"); - } - - @Test - public void getOrganizationByURL() { - OrganizationMini org = getAPI().getOrganizationByURL( - "https://podio.com/hoist"); - - Assert.assertEquals(org.getId(), 1); - } - - @Test - public void getSharedOrganizations() { - List organizations = getAPI() - .getSharedOrganizations(2); - - Assert.assertEquals(organizations.size(), 3); - Assert.assertEquals(organizations.get(0).getId(), 1); - Assert.assertEquals(organizations.get(0).getSpaces().size(), 3); - Assert.assertEquals(organizations.get(0).getSpaces().get(0).getId(), 1); - } - - @Test - public void getSpaceByURL() { - Space space = getAPI().getSpaceByURL(1, "api"); - - Assert.assertEquals(space.getId(), 1); - } - - @Test - public void getSpaces() { - List spaces = getAPI().getSpaces(1); - - Assert.assertEquals(spaces.size(), 3); - Assert.assertEquals(spaces.get(0).getId(), 1); - } - - @Test - public void getMembers() { - List members = getAPI().getMembers(1); - - Assert.assertEquals(members.size(), 4); - OrganizationMember member = members.get(0); - Assert.assertEquals(member.getUser().getId(), 4); - Assert.assertEquals(member.getProfile().getProfileId(), 4); - Assert.assertEquals(member.getRole(), Role.REGULAR); - Assert.assertEquals(member.getSpaceMemberships(), 1); - } - - @Test - public void getMemberByUserId() { - OrganizationMember member = getAPI().getMember(1, 2); - - Assert.assertEquals(member.getUser().getId(), 2); - Assert.assertEquals(member.getProfile().getProfileId(), 2); - Assert.assertEquals(member.getRole(), Role.REGULAR); - Assert.assertEquals(member.getSpaceMemberships(), 3); - } - - @Test - public void getMemberByMail() { - OrganizationMember member = getAPI().getMemberByMail(1, "haugstrup@hoisthq.com"); - - Assert.assertEquals(member.getUser().getId(), 2); - Assert.assertEquals(member.getProfile().getProfileId(), 2); - Assert.assertEquals(member.getRole(), Role.REGULAR); - Assert.assertEquals(member.getSpaceMemberships(), 3); - } - - @Test - public void getEndMemberInfo() { - EndMemberInfo endMemberInfo = getAPI().getEndMemberInfo(1, 2); - - Assert.assertEquals(endMemberInfo.getToRemove().size(), 3); - Assert.assertEquals(endMemberInfo.getToRemove().get(0).getSpace().getId(), 1); - Assert.assertEquals(endMemberInfo.getToRemove().get(0).getRole(), Role.REGULAR); - Assert.assertEquals(endMemberInfo.getToRemove().get(0).getGrants(), 0); - Assert.assertEquals(endMemberInfo.getToPromote().size(), 1); - Assert.assertEquals(endMemberInfo.getToDelete().size(), 0); - } - - @Test - public void endMember() { - getAPI().endMember(1, 4); - } -} +package com.podio.org; + +import java.net.URISyntaxException; +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Role; +import com.podio.space.Space; +import com.podio.space.SpaceMini; + +public class OrgAPITest { + + private OrgAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(OrgAPI.class); + } + + @Test + public void createOrganization() { + OrganizationCreateResponse response = getAPI().createOrganization( + new OrganizationCreate("CubiTech2", null)); + + Assert.assertTrue(response.getId() > 1); + Assert.assertEquals(response.getUrl(), "https://podio.com/cubitech2"); + } + + @Test + public void getOrganization() { + Organization org = getAPI().getOrganization(1); + + Assert.assertEquals(org.getId(), 1); + Assert.assertEquals(org.getName(), "Hoist"); + Assert.assertEquals(org.getUrl(), "https://podio.com/hoist"); + Assert.assertEquals(org.getLogo().intValue(), 10); + Assert.assertEquals(org.getStatus(), OrganizationStatus.ACTIVE); + Assert.assertEquals(org.getUserLimit(), 50); + Assert.assertEquals(org.getCreatedBy().getUserId().intValue(), 1); + Assert.assertEquals(org.getCreatedOn(), new DateTime(2010, 8, 6, 23, 1, + 0, 0, DateTimeZone.UTC)); + } + + @Test + public void updateOrganization() { + getAPI().updateOrganization(1, new OrganizationCreate("New name", null)); + } + + @Test + public void getOrganizations() throws URISyntaxException { + List organizations = getAPI() + .getOrganizations(); + Assert.assertEquals(organizations.size(), 4); + + OrganizationWithSpaces org = organizations.get(0); + Assert.assertEquals(org.getId(), 1); + Assert.assertEquals(org.getName(), "Hoist"); + List spaces = org.getSpaces(); + Assert.assertEquals(spaces.size(), 3); + SpaceMini space = spaces.get(0); + Assert.assertEquals(space.getId(), 1); + Assert.assertEquals(space.getName(), "API"); + } + + @Test + public void getOrganizationByURL() { + OrganizationMini org = getAPI().getOrganizationByURL( + "https://podio.com/hoist"); + + Assert.assertEquals(org.getId(), 1); + } + + @Test + public void getSharedOrganizations() { + List organizations = getAPI() + .getSharedOrganizations(2); + + Assert.assertEquals(organizations.size(), 3); + Assert.assertEquals(organizations.get(0).getId(), 1); + Assert.assertEquals(organizations.get(0).getSpaces().size(), 3); + Assert.assertEquals(organizations.get(0).getSpaces().get(0).getId(), 1); + } + + @Test + public void getSpaceByURL() { + Space space = getAPI().getSpaceByURL(1, "api"); + + Assert.assertEquals(space.getId(), 1); + } + + @Test + public void getSpaces() { + List spaces = getAPI().getSpaces(1); + + Assert.assertEquals(spaces.size(), 3); + Assert.assertEquals(spaces.get(0).getId(), 1); + } + + @Test + public void getMembers() { + List members = getAPI().getMembers(1); + + Assert.assertEquals(members.size(), 4); + OrganizationMember member = members.get(0); + Assert.assertEquals(member.getUser().getId(), 4); + Assert.assertEquals(member.getProfile().getProfileId(), 4); + Assert.assertEquals(member.getRole(), Role.REGULAR); + Assert.assertEquals(member.getSpaceMemberships(), 1); + } + + @Test + public void getMemberByUserId() { + OrganizationMember member = getAPI().getMember(1, 2); + + Assert.assertEquals(member.getUser().getId(), 2); + Assert.assertEquals(member.getProfile().getProfileId(), 2); + Assert.assertEquals(member.getRole(), Role.REGULAR); + Assert.assertEquals(member.getSpaceMemberships(), 3); + } + + @Test + public void getMemberByMail() { + OrganizationMember member = getAPI().getMemberByMail(1, "haugstrup@hoisthq.com"); + + Assert.assertEquals(member.getUser().getId(), 2); + Assert.assertEquals(member.getProfile().getProfileId(), 2); + Assert.assertEquals(member.getRole(), Role.REGULAR); + Assert.assertEquals(member.getSpaceMemberships(), 3); + } + + @Test + public void getEndMemberInfo() { + EndMemberInfo endMemberInfo = getAPI().getEndMemberInfo(1, 2); + + Assert.assertEquals(endMemberInfo.getToRemove().size(), 3); + Assert.assertEquals(endMemberInfo.getToRemove().get(0).getSpace().getId(), 1); + Assert.assertEquals(endMemberInfo.getToRemove().get(0).getRole(), Role.REGULAR); + Assert.assertEquals(endMemberInfo.getToRemove().get(0).getGrants(), 0); + Assert.assertEquals(endMemberInfo.getToPromote().size(), 1); + Assert.assertEquals(endMemberInfo.getToDelete().size(), 0); + } + + @Test + public void endMember() { + getAPI().endMember(1, 4); + } +} diff --git a/src/test/java/com/podio/rating/RatingAPITest.java b/src/test/java/com/podio/rating/RatingAPITest.java index 1ade5e0..dd577dc 100644 --- a/src/test/java/com/podio/rating/RatingAPITest.java +++ b/src/test/java/com/podio/rating/RatingAPITest.java @@ -1,57 +1,57 @@ -package com.podio.rating; - -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class RatingAPITest { - - private RatingAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(RatingAPI.class); - } - - @Test - public void createRating() { - int ratingId = getAPI().createRating( - new Reference(ReferenceType.STATUS, 1), RatingType.LIKE, - RatingValue.LIKE); - - Assert.assertTrue(ratingId > 1); - } - - @Test - public void getAllRatings() { - RatingValuesMap ratings = getAPI().getAllRatings( - new Reference(ReferenceType.STATUS, 1)); - - Assert.assertEquals(ratings.get(RatingType.LIKE).getCounts(1) - .getTotal(), 1); - Assert.assertEquals(ratings.get(RatingType.LIKE).getCounts(1) - .getUsers().get(0).getUserId().intValue(), 4); - } - - @Test - public void getRatings() { - TypeRating ratings = getAPI().getRatings( - new Reference(ReferenceType.STATUS, 1), RatingType.LIKE); - - Assert.assertEquals(ratings.getCounts(1).getTotal(), 1); - } - - @Test - public void getRating() { - int value = getAPI().getRating(new Reference(ReferenceType.STATUS, 1), - RatingType.LIKE, 4); - - Assert.assertEquals(value, 1); - } - - @Test - public void deleteRating() { - getAPI().deleteRating(new Reference(ReferenceType.ITEM, 1), - RatingType.APPROVED); - } -} +package com.podio.rating; + +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class RatingAPITest { + + private RatingAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(RatingAPI.class); + } + + @Test + public void createRating() { + int ratingId = getAPI().createRating( + new Reference(ReferenceType.STATUS, 1), RatingType.LIKE, + RatingValue.LIKE); + + Assert.assertTrue(ratingId > 1); + } + + @Test + public void getAllRatings() { + RatingValuesMap ratings = getAPI().getAllRatings( + new Reference(ReferenceType.STATUS, 1)); + + Assert.assertEquals(ratings.get(RatingType.LIKE).getCounts(1) + .getTotal(), 1); + Assert.assertEquals(ratings.get(RatingType.LIKE).getCounts(1) + .getUsers().get(0).getUserId().intValue(), 4); + } + + @Test + public void getRatings() { + TypeRating ratings = getAPI().getRatings( + new Reference(ReferenceType.STATUS, 1), RatingType.LIKE); + + Assert.assertEquals(ratings.getCounts(1).getTotal(), 1); + } + + @Test + public void getRating() { + int value = getAPI().getRating(new Reference(ReferenceType.STATUS, 1), + RatingType.LIKE, 4); + + Assert.assertEquals(value, 1); + } + + @Test + public void deleteRating() { + getAPI().deleteRating(new Reference(ReferenceType.ITEM, 1), + RatingType.APPROVED); + } +} diff --git a/src/test/java/com/podio/space/SpaceAPITest.java b/src/test/java/com/podio/space/SpaceAPITest.java index 65986eb..c985dbb 100644 --- a/src/test/java/com/podio/space/SpaceAPITest.java +++ b/src/test/java/com/podio/space/SpaceAPITest.java @@ -1,125 +1,125 @@ -package com.podio.space; - -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIApplicationException; -import com.podio.APIFactoryProvider; -import com.podio.ResourceFactoryProvider; -import com.podio.common.Role; - -public class SpaceAPITest { - - private SpaceAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(SpaceAPI.class); - } - - private SpaceAPI getAPI(int userId) { - return new SpaceAPI(ResourceFactoryProvider.getUser(userId)); - } - - @Test - public void createSpace() { - SpaceCreateResponse response = getAPI().createSpace( - new SpaceCreate("New", true, true, 1)); - - Assert.assertTrue(response.getId() > 1); - Assert.assertEquals(response.getUrl(), "https://podio.com/hoist/new"); - } - - @Test - public void getSpace() { - Space space = getAPI().getSpace(1); - - Assert.assertEquals(space.getId(), 1); - Assert.assertEquals(space.getName(), "API"); - Assert.assertEquals(space.getUrl(), "https://podio.com/hoist/api"); - Assert.assertEquals(space.getCreatedOn(), new DateTime(2010, 8, 9, 14, - 49, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(space.getCreatedBy().getUserId().intValue(), 1); - Assert.assertEquals(space.getRole(), Role.ADMIN); - } - - @Test - public void updateSpace() { - getAPI().updateSpace(1, new SpaceUpdate("Our API", false, false)); - } - - @Test - public void getSpaceByURL() { - SpaceWithOrganization space = getAPI().getSpaceByURL( - "https://podio.com/hoist/api/"); - - Assert.assertEquals(space.getId(), 1); - Assert.assertEquals(space.getOrganization().getId(), 1); - } - - @Test - public void getSpaceMembership() { - SpaceMember member = getAPI().getSpaceMembership(1, 1); - - Assert.assertEquals(member.getEndedOn(), null); - Assert.assertEquals(member.getInvitedOn(), new DateTime(2010, 8, 9, 15, - 7, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(member.getStartedOn(), new DateTime(2010, 8, 9, 15, - 7, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(member.getUser().getUserId().intValue(), 1); - Assert.assertEquals(member.getRole(), Role.ADMIN); - } - - @Test - public void updateSpaceMembership() { - try { - getAPI().updateSpaceMembership(1, 1, Role.REGULAR); - Assert.fail(); - } catch (APIApplicationException e) { - // Expected - } - - } - - @Test - public void endSpaceMembership() { - getAPI().endSpaceMembership(1, 2); - } - - @Test - public void getActiveMembers() { - List members = getAPI().getActiveMembers(1); - - Assert.assertEquals(members.size(), 6); - Assert.assertEquals(members.get(0).getUser().getUserId().intValue(), 5); - Assert.assertEquals(members.get(1).getUser().getUserId().intValue(), 4); - Assert.assertEquals(members.get(2).getUser().getUserId().intValue(), 2); - Assert.assertEquals(members.get(3).getUser().getUserId().intValue(), 1); - Assert.assertEquals(members.get(3).getRole(), Role.ADMIN); - Assert.assertEquals(members.get(3).getInvitedOn(), new DateTime(2010, - 8, 9, 15, 7, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(members.get(3).getStartedOn(), new DateTime(2010, - 8, 9, 15, 7, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(members.get(3).getEndedOn(), null); - } - - @Test - public void getEndedMembers() { - List members = getAPI(2).getEndedMembers(3); - - Assert.assertEquals(members.size(), 3); - Assert.assertEquals(members.get(0).getUser().getUserId().intValue(), 4); - Assert.assertEquals(members.get(0).getEndedOn(), new DateTime(2010, 9, - 30, 12, 35, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(members.get(1).getUser().getUserId().intValue(), 1); - } - - @Test - public void getTopSpaces() { - List topSpaces = getAPI().getTopSpaces(null); - - Assert.assertEquals(topSpaces.size(), 6); - Assert.assertEquals(topSpaces.get(0).getId(), 1); - } -} +package com.podio.space; + +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIApplicationException; +import com.podio.APIFactoryProvider; +import com.podio.ResourceFactoryProvider; +import com.podio.common.Role; + +public class SpaceAPITest { + + private SpaceAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(SpaceAPI.class); + } + + private SpaceAPI getAPI(int userId) { + return new SpaceAPI(ResourceFactoryProvider.getUser(userId)); + } + + @Test + public void createSpace() { + SpaceCreateResponse response = getAPI().createSpace( + new SpaceCreate("New", true, true, 1)); + + Assert.assertTrue(response.getId() > 1); + Assert.assertEquals(response.getUrl(), "https://podio.com/hoist/new"); + } + + @Test + public void getSpace() { + Space space = getAPI().getSpace(1); + + Assert.assertEquals(space.getId(), 1); + Assert.assertEquals(space.getName(), "API"); + Assert.assertEquals(space.getUrl(), "https://podio.com/hoist/api"); + Assert.assertEquals(space.getCreatedOn(), new DateTime(2010, 8, 9, 14, + 49, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(space.getCreatedBy().getUserId().intValue(), 1); + Assert.assertEquals(space.getRole(), Role.ADMIN); + } + + @Test + public void updateSpace() { + getAPI().updateSpace(1, new SpaceUpdate("Our API", false, false)); + } + + @Test + public void getSpaceByURL() { + SpaceWithOrganization space = getAPI().getSpaceByURL( + "https://podio.com/hoist/api/"); + + Assert.assertEquals(space.getId(), 1); + Assert.assertEquals(space.getOrganization().getId(), 1); + } + + @Test + public void getSpaceMembership() { + SpaceMember member = getAPI().getSpaceMembership(1, 1); + + Assert.assertEquals(member.getEndedOn(), null); + Assert.assertEquals(member.getInvitedOn(), new DateTime(2010, 8, 9, 15, + 7, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(member.getStartedOn(), new DateTime(2010, 8, 9, 15, + 7, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(member.getUser().getUserId().intValue(), 1); + Assert.assertEquals(member.getRole(), Role.ADMIN); + } + + @Test + public void updateSpaceMembership() { + try { + getAPI().updateSpaceMembership(1, 1, Role.REGULAR); + Assert.fail(); + } catch (APIApplicationException e) { + // Expected + } + + } + + @Test + public void endSpaceMembership() { + getAPI().endSpaceMembership(1, 2); + } + + @Test + public void getActiveMembers() { + List members = getAPI().getActiveMembers(1); + + Assert.assertEquals(members.size(), 6); + Assert.assertEquals(members.get(0).getUser().getUserId().intValue(), 5); + Assert.assertEquals(members.get(1).getUser().getUserId().intValue(), 4); + Assert.assertEquals(members.get(2).getUser().getUserId().intValue(), 2); + Assert.assertEquals(members.get(3).getUser().getUserId().intValue(), 1); + Assert.assertEquals(members.get(3).getRole(), Role.ADMIN); + Assert.assertEquals(members.get(3).getInvitedOn(), new DateTime(2010, + 8, 9, 15, 7, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(members.get(3).getStartedOn(), new DateTime(2010, + 8, 9, 15, 7, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(members.get(3).getEndedOn(), null); + } + + @Test + public void getEndedMembers() { + List members = getAPI(2).getEndedMembers(3); + + Assert.assertEquals(members.size(), 3); + Assert.assertEquals(members.get(0).getUser().getUserId().intValue(), 4); + Assert.assertEquals(members.get(0).getEndedOn(), new DateTime(2010, 9, + 30, 12, 35, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(members.get(1).getUser().getUserId().intValue(), 1); + } + + @Test + public void getTopSpaces() { + List topSpaces = getAPI().getTopSpaces(null); + + Assert.assertEquals(topSpaces.size(), 6); + Assert.assertEquals(topSpaces.get(0).getId(), 1); + } +} diff --git a/src/test/java/com/podio/status/StatusAPITest.java b/src/test/java/com/podio/status/StatusAPITest.java index 73ed7ba..0c0d0e3 100644 --- a/src/test/java/com/podio/status/StatusAPITest.java +++ b/src/test/java/com/podio/status/StatusAPITest.java @@ -1,61 +1,61 @@ -package com.podio.status; - -import java.util.Collections; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.rating.RatingType; - -public class StatusAPITest { - - private StatusAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(StatusAPI.class); - } - - @Test - public void createStatus() { - int statusId = getAPI().createStatus( - 1, - new StatusCreate("Hello from Java", Collections - . emptyList(), Collections - . emptyList())); - - Assert.assertTrue(statusId > 1); - } - - @Test - public void deleteStatus() { - getAPI().deleteStatus(1); - } - - @Test - public void getStatus() { - StatusFull status = getAPI().getStatus(1); - - Assert.assertEquals(status.getStatusId(), 1); - Assert.assertEquals(status.getCreatedBy().getId(), 1); - Assert.assertEquals( - status.getValue(), - "This is going to be legen- wait for it -dary. @Andreas Haugstrup Now it's up to you to make it ha..."); - Assert.assertEquals(status.getCreatedOn(), new DateTime(2010, 8, 12, - 17, 9, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(status.getComments().size(), 2); - Assert.assertEquals( - status.getRatings().get(RatingType.LIKE).getCounts(1) - .getUsers().get(0).getUserId().intValue(), 4); - Assert.assertEquals(status.getFiles().size(), 4); - Assert.assertEquals(status.getFiles().get(0).getId(), 34); - Assert.assertEquals(status.isSubscribed(), true); - Assert.assertEquals(status.getUserRatings().size(), 0); - } - - @Test - public void updateStatus() { - getAPI().updateStatus(1, - new StatusUpdate("Test", Collections. emptyList())); - } -} +package com.podio.status; + +import java.util.Collections; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.rating.RatingType; + +public class StatusAPITest { + + private StatusAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(StatusAPI.class); + } + + @Test + public void createStatus() { + int statusId = getAPI().createStatus( + 1, + new StatusCreate("Hello from Java", Collections + . emptyList(), Collections + . emptyList())); + + Assert.assertTrue(statusId > 1); + } + + @Test + public void deleteStatus() { + getAPI().deleteStatus(1); + } + + @Test + public void getStatus() { + StatusFull status = getAPI().getStatus(1); + + Assert.assertEquals(status.getStatusId(), 1); + Assert.assertEquals(status.getCreatedBy().getId(), 1); + Assert.assertEquals( + status.getValue(), + "This is going to be legen- wait for it -dary. @Andreas Haugstrup Now it's up to you to make it ha..."); + Assert.assertEquals(status.getCreatedOn(), new DateTime(2010, 8, 12, + 17, 9, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(status.getComments().size(), 2); + Assert.assertEquals( + status.getRatings().get(RatingType.LIKE).getCounts(1) + .getUsers().get(0).getUserId().intValue(), 4); + Assert.assertEquals(status.getFiles().size(), 4); + Assert.assertEquals(status.getFiles().get(0).getId(), 34); + Assert.assertEquals(status.isSubscribed(), true); + Assert.assertEquals(status.getUserRatings().size(), 0); + } + + @Test + public void updateStatus() { + getAPI().updateStatus(1, + new StatusUpdate("Test", Collections. emptyList())); + } +} diff --git a/src/test/java/com/podio/stream/StreamAPITest.java b/src/test/java/com/podio/stream/StreamAPITest.java index 46314cd..3fdfad2 100644 --- a/src/test/java/com/podio/stream/StreamAPITest.java +++ b/src/test/java/com/podio/stream/StreamAPITest.java @@ -1,123 +1,123 @@ -package com.podio.stream; - -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; -import com.podio.common.Right; - -public class StreamAPITest { - - private StreamAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(StreamAPI.class); - } - - @Test - public void getStreamObject() { - StreamObject object = getAPI().getStreamObject( - new Reference(ReferenceType.ITEM, 1)); - - Assert.assertEquals(object.getType(), ReferenceType.ITEM); - Assert.assertEquals(object.getId(), 1); - Assert.assertEquals(object.getLink(), - "https://podio.com/hoist/api/apps/bugs/items/1"); - Assert.assertEquals(object.getComments().size(), 2); - Assert.assertEquals(object.getComments().get(0).getId(), 1); - Assert.assertEquals(object.getFiles().size(), 2); - Assert.assertEquals(object.getFiles().get(0).getId(), 1); - Assert.assertEquals(object.getFiles().get(1).getId(), 8); - Assert.assertEquals(object.getOrganization().getId(), 1); - Assert.assertEquals(object.getSpace().getId(), 1); - } - - @Test - public void getStreamObjectV2() { - StreamObjectV2 object = getAPI().getStreamObjectV2( - new Reference(ReferenceType.ITEM, 1)); - - Assert.assertEquals(object.getType(), ReferenceType.ITEM); - Assert.assertEquals(object.getId(), 1); - Assert.assertEquals(object.getCreatedBy().getId(), 1); - Assert.assertEquals(object.getCreatedOn(), new DateTime(2010, 8, 2, 16, - 0, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(object.getCreatedVia().getId(), 1); - Assert.assertEquals(object.getLastUpdateOn(), new DateTime(2014, 5, 27, - 10, 36, 5, 0, DateTimeZone.UTC)); - Assert.assertEquals(object.getTitle(), "no & yes"); - Assert.assertEquals(object.getRights().size(), 10); - Assert.assertTrue(object.getRights().contains(Right.ADD_FILE)); - Assert.assertTrue(object.isCommentsAllowed()); - Assert.assertEquals(object.getLink(), - "https://podio.com/hoist/api/apps/bugs/items/1"); - Assert.assertEquals(object.getComments().size(), 2); - Assert.assertEquals(object.getComments().get(0).getId(), 1); - Assert.assertEquals(object.getFiles().size(), 2); - Assert.assertEquals(object.getFiles().get(0).getId(), 1); - Assert.assertEquals(object.getFiles().get(1).getId(), 8); - Assert.assertEquals(object.getData().get("item_id"), 1); - Assert.assertEquals(object.getOrganization().getId(), 1); - Assert.assertEquals(object.getSpace().getId(), 1); - Assert.assertEquals(object.getApp().getId(), 1); - Assert.assertEquals(object.getActivities().size(), 9); - } - - @Test - public void getGlobalStream() { - List objects = getAPI().getGlobalStream(3, 2, null, - new DateTime(2011, 6, 30, 12, 0, 0, 0, DateTimeZone.UTC)); - - Assert.assertEquals(objects.size(), 3); - Assert.assertEquals(objects.get(2).getType(), ReferenceType.ITEM); - Assert.assertEquals(objects.get(2).getId(), 8); - } - - @Test - public void getOrganizationStream() { - List objects = getAPI().getOrganizationStream(1, 3, 2, - null, new DateTime(2011, 6, 30, 12, 0, 0, 0, DateTimeZone.UTC)); - - Assert.assertEquals(objects.size(), 3); - Assert.assertEquals(objects.get(2).getType(), ReferenceType.ITEM); - Assert.assertEquals(objects.get(2).getId(), 8); - } - - @Test - public void getOrganizationStreamV2() { - List objects = getAPI().getOrganizationStreamV2(1, 3, - 2, null, - new DateTime(2010, 10, 4, 12, 0, 0, 0, DateTimeZone.UTC)); - - Assert.assertEquals(objects.size(), 3); - } - - @Test - public void getSpaceStream() { - List objects = getAPI().getSpaceStream(1, 3, 2, null, - new DateTime(2011, 6, 30, 12, 0, 0, 0, DateTimeZone.UTC)); - - Assert.assertEquals(objects.size(), 3); - Assert.assertEquals(objects.get(0).getType(), ReferenceType.ITEM); - Assert.assertEquals(objects.get(0).getId(), 1); - } - - @Test - public void getSpaceStreamV2() { - List objects = getAPI().getSpaceStreamV2(1, 3, 2, null, - new DateTime(2010, 10, 4, 12, 0, 0, 0, DateTimeZone.UTC)); - - Assert.assertEquals(objects.size(), 3); - } - - @Test - public void getAppStreamV2() { - List objects = getAPI().getAppStream(1, 3, 2); - - Assert.assertEquals(objects.size(), 3); - } -} +package com.podio.stream; + +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; +import com.podio.common.Right; + +public class StreamAPITest { + + private StreamAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(StreamAPI.class); + } + + @Test + public void getStreamObject() { + StreamObject object = getAPI().getStreamObject( + new Reference(ReferenceType.ITEM, 1)); + + Assert.assertEquals(object.getType(), ReferenceType.ITEM); + Assert.assertEquals(object.getId(), 1); + Assert.assertEquals(object.getLink(), + "https://podio.com/hoist/api/apps/bugs/items/1"); + Assert.assertEquals(object.getComments().size(), 2); + Assert.assertEquals(object.getComments().get(0).getId(), 1); + Assert.assertEquals(object.getFiles().size(), 2); + Assert.assertEquals(object.getFiles().get(0).getId(), 1); + Assert.assertEquals(object.getFiles().get(1).getId(), 8); + Assert.assertEquals(object.getOrganization().getId(), 1); + Assert.assertEquals(object.getSpace().getId(), 1); + } + + @Test + public void getStreamObjectV2() { + StreamObjectV2 object = getAPI().getStreamObjectV2( + new Reference(ReferenceType.ITEM, 1)); + + Assert.assertEquals(object.getType(), ReferenceType.ITEM); + Assert.assertEquals(object.getId(), 1); + Assert.assertEquals(object.getCreatedBy().getId(), 1); + Assert.assertEquals(object.getCreatedOn(), new DateTime(2010, 8, 2, 16, + 0, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(object.getCreatedVia().getId(), 1); + Assert.assertEquals(object.getLastUpdateOn(), new DateTime(2014, 5, 27, + 10, 36, 5, 0, DateTimeZone.UTC)); + Assert.assertEquals(object.getTitle(), "no & yes"); + Assert.assertEquals(object.getRights().size(), 10); + Assert.assertTrue(object.getRights().contains(Right.ADD_FILE)); + Assert.assertTrue(object.isCommentsAllowed()); + Assert.assertEquals(object.getLink(), + "https://podio.com/hoist/api/apps/bugs/items/1"); + Assert.assertEquals(object.getComments().size(), 2); + Assert.assertEquals(object.getComments().get(0).getId(), 1); + Assert.assertEquals(object.getFiles().size(), 2); + Assert.assertEquals(object.getFiles().get(0).getId(), 1); + Assert.assertEquals(object.getFiles().get(1).getId(), 8); + Assert.assertEquals(object.getData().get("item_id"), 1); + Assert.assertEquals(object.getOrganization().getId(), 1); + Assert.assertEquals(object.getSpace().getId(), 1); + Assert.assertEquals(object.getApp().getId(), 1); + Assert.assertEquals(object.getActivities().size(), 9); + } + + @Test + public void getGlobalStream() { + List objects = getAPI().getGlobalStream(3, 2, null, + new DateTime(2011, 6, 30, 12, 0, 0, 0, DateTimeZone.UTC)); + + Assert.assertEquals(objects.size(), 3); + Assert.assertEquals(objects.get(2).getType(), ReferenceType.ITEM); + Assert.assertEquals(objects.get(2).getId(), 8); + } + + @Test + public void getOrganizationStream() { + List objects = getAPI().getOrganizationStream(1, 3, 2, + null, new DateTime(2011, 6, 30, 12, 0, 0, 0, DateTimeZone.UTC)); + + Assert.assertEquals(objects.size(), 3); + Assert.assertEquals(objects.get(2).getType(), ReferenceType.ITEM); + Assert.assertEquals(objects.get(2).getId(), 8); + } + + @Test + public void getOrganizationStreamV2() { + List objects = getAPI().getOrganizationStreamV2(1, 3, + 2, null, + new DateTime(2010, 10, 4, 12, 0, 0, 0, DateTimeZone.UTC)); + + Assert.assertEquals(objects.size(), 3); + } + + @Test + public void getSpaceStream() { + List objects = getAPI().getSpaceStream(1, 3, 2, null, + new DateTime(2011, 6, 30, 12, 0, 0, 0, DateTimeZone.UTC)); + + Assert.assertEquals(objects.size(), 3); + Assert.assertEquals(objects.get(0).getType(), ReferenceType.ITEM); + Assert.assertEquals(objects.get(0).getId(), 1); + } + + @Test + public void getSpaceStreamV2() { + List objects = getAPI().getSpaceStreamV2(1, 3, 2, null, + new DateTime(2010, 10, 4, 12, 0, 0, 0, DateTimeZone.UTC)); + + Assert.assertEquals(objects.size(), 3); + } + + @Test + public void getAppStreamV2() { + List objects = getAPI().getAppStream(1, 3, 2); + + Assert.assertEquals(objects.size(), 3); + } +} diff --git a/src/test/java/com/podio/subscription/SubscriptionAPITest.java b/src/test/java/com/podio/subscription/SubscriptionAPITest.java index a0e5113..6da247c 100644 --- a/src/test/java/com/podio/subscription/SubscriptionAPITest.java +++ b/src/test/java/com/podio/subscription/SubscriptionAPITest.java @@ -1,57 +1,57 @@ -package com.podio.subscription; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class SubscriptionAPITest { - - private SubscriptionAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(SubscriptionAPI.class); - } - - @Test - public void getSubscriptionById() { - Subscription subscription = getAPI().getSubscription(1); - - Assert.assertEquals(subscription.getStartedOn(), new DateTime(2010, 7, - 29, 16, 2, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(subscription.getNotifications(), 0); - Assert.assertEquals(subscription.getReference().getType(), - ReferenceType.APP); - Assert.assertEquals(subscription.getReference().getId(), 1); - } - - @Test - public void getSubscriptionByReference() { - Subscription subscription = getAPI().getSubscription( - new Reference(ReferenceType.APP, 1)); - - Assert.assertEquals(subscription.getStartedOn(), new DateTime(2010, 7, - 29, 16, 2, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(subscription.getNotifications(), 0); - Assert.assertEquals(subscription.getReference().getType(), - ReferenceType.APP); - Assert.assertEquals(subscription.getReference().getId(), 1); - } - - @Test - public void subscribe() { - getAPI().subscribe(new Reference(ReferenceType.APP, 2)); - } - - @Test - public void unsubscribeById() { - getAPI().unsubscribe(1); - } - - @Test - public void unsubscribeByReference() { - getAPI().unsubscribe(new Reference(ReferenceType.APP, 1)); - } -} +package com.podio.subscription; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class SubscriptionAPITest { + + private SubscriptionAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(SubscriptionAPI.class); + } + + @Test + public void getSubscriptionById() { + Subscription subscription = getAPI().getSubscription(1); + + Assert.assertEquals(subscription.getStartedOn(), new DateTime(2010, 7, + 29, 16, 2, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(subscription.getNotifications(), 0); + Assert.assertEquals(subscription.getReference().getType(), + ReferenceType.APP); + Assert.assertEquals(subscription.getReference().getId(), 1); + } + + @Test + public void getSubscriptionByReference() { + Subscription subscription = getAPI().getSubscription( + new Reference(ReferenceType.APP, 1)); + + Assert.assertEquals(subscription.getStartedOn(), new DateTime(2010, 7, + 29, 16, 2, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(subscription.getNotifications(), 0); + Assert.assertEquals(subscription.getReference().getType(), + ReferenceType.APP); + Assert.assertEquals(subscription.getReference().getId(), 1); + } + + @Test + public void subscribe() { + getAPI().subscribe(new Reference(ReferenceType.APP, 2)); + } + + @Test + public void unsubscribeById() { + getAPI().unsubscribe(1); + } + + @Test + public void unsubscribeByReference() { + getAPI().unsubscribe(new Reference(ReferenceType.APP, 1)); + } +} diff --git a/src/test/java/com/podio/tag/TagAPITest.java b/src/test/java/com/podio/tag/TagAPITest.java index 4833e39..1ec3fe1 100644 --- a/src/test/java/com/podio/tag/TagAPITest.java +++ b/src/test/java/com/podio/tag/TagAPITest.java @@ -1,86 +1,86 @@ -package com.podio.tag; - -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class TagAPITest { - - private TagAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(TagAPI.class); - } - - @Test - public void createTags() { - getAPI().createTags(new Reference(ReferenceType.ITEM, 1), "Tag1", - "Tag2"); - } - - @Test - public void updateTags() { - getAPI().updateTags(new Reference(ReferenceType.ITEM, 1), "Tag1", - "Tag2"); - } - - @Test - public void removeTag() { - getAPI().removeTag(new Reference(ReferenceType.ITEM, 1), "release"); - } - - @Test - public void getTagsOnApp() { - List tags = getAPI().getTagsOnApp(1); - - Assert.assertEquals(tags.size(), 3); - Assert.assertEquals(tags.get(0).getText(), "problems"); - Assert.assertEquals(tags.get(0).getCount(), 1); - } - - @Test - public void getTagsOnSpace() { - List tags = getAPI().getTagsOnSpace(1); - - Assert.assertEquals(tags.size(), 3); - Assert.assertEquals(tags.get(0).getText(), "problems"); - Assert.assertEquals(tags.get(0).getCount(), 1); - } - - @Test - public void getTagsOnAppWithText() { - List references = getAPI().getTagsOnAppWithText(1, - "problems"); - - Assert.assertEquals(references.size(), 1); - Assert.assertEquals(references.get(0).getType(), ReferenceType.ITEM); - Assert.assertEquals(references.get(0).getId(), 2); - Assert.assertEquals(references.get(0).getTitle(), - "no"); - Assert.assertEquals(references.get(0).getCreatedOn(), new DateTime( - 2010, 8, 5, 10, 12, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(references.get(0).getLink(), - "https://podio.com/hoist/api/apps/bugs/items/2"); - } - - @Test - public void getTagsOnSpaceWithText() { - List references = getAPI().getTagsOnSpaceWithText(1, - "release"); - - Assert.assertEquals(references.size(), 1); - TagReference reference = references.get(0); - Assert.assertEquals(reference.getType(), ReferenceType.ITEM); - Assert.assertEquals(reference.getId(), 1); - Assert.assertEquals(reference.getTitle(), "no & yes"); - Assert.assertEquals(reference.getCreatedOn(), new DateTime(2010, 8, 2, - 16, 0, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(reference.getLink(), - "https://podio.com/hoist/api/apps/bugs/items/1"); - } -} +package com.podio.tag; + +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class TagAPITest { + + private TagAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(TagAPI.class); + } + + @Test + public void createTags() { + getAPI().createTags(new Reference(ReferenceType.ITEM, 1), "Tag1", + "Tag2"); + } + + @Test + public void updateTags() { + getAPI().updateTags(new Reference(ReferenceType.ITEM, 1), "Tag1", + "Tag2"); + } + + @Test + public void removeTag() { + getAPI().removeTag(new Reference(ReferenceType.ITEM, 1), "release"); + } + + @Test + public void getTagsOnApp() { + List tags = getAPI().getTagsOnApp(1); + + Assert.assertEquals(tags.size(), 3); + Assert.assertEquals(tags.get(0).getText(), "problems"); + Assert.assertEquals(tags.get(0).getCount(), 1); + } + + @Test + public void getTagsOnSpace() { + List tags = getAPI().getTagsOnSpace(1); + + Assert.assertEquals(tags.size(), 3); + Assert.assertEquals(tags.get(0).getText(), "problems"); + Assert.assertEquals(tags.get(0).getCount(), 1); + } + + @Test + public void getTagsOnAppWithText() { + List references = getAPI().getTagsOnAppWithText(1, + "problems"); + + Assert.assertEquals(references.size(), 1); + Assert.assertEquals(references.get(0).getType(), ReferenceType.ITEM); + Assert.assertEquals(references.get(0).getId(), 2); + Assert.assertEquals(references.get(0).getTitle(), + "no"); + Assert.assertEquals(references.get(0).getCreatedOn(), new DateTime( + 2010, 8, 5, 10, 12, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(references.get(0).getLink(), + "https://podio.com/hoist/api/apps/bugs/items/2"); + } + + @Test + public void getTagsOnSpaceWithText() { + List references = getAPI().getTagsOnSpaceWithText(1, + "release"); + + Assert.assertEquals(references.size(), 1); + TagReference reference = references.get(0); + Assert.assertEquals(reference.getType(), ReferenceType.ITEM); + Assert.assertEquals(reference.getId(), 1); + Assert.assertEquals(reference.getTitle(), "no & yes"); + Assert.assertEquals(reference.getCreatedOn(), new DateTime(2010, 8, 2, + 16, 0, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(reference.getLink(), + "https://podio.com/hoist/api/apps/bugs/items/1"); + } +} diff --git a/src/test/java/com/podio/task/TaskAPITest.java b/src/test/java/com/podio/task/TaskAPITest.java index b6ba89a..c734f55 100644 --- a/src/test/java/com/podio/task/TaskAPITest.java +++ b/src/test/java/com/podio/task/TaskAPITest.java @@ -1,115 +1,115 @@ -package com.podio.task; - -import java.util.List; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.LocalDate; -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.common.Reference; -import com.podio.common.ReferenceType; - -public class TaskAPITest { - - private TaskAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(TaskAPI.class); - } - - @Test - public void getTask() { - Task task = getAPI().getTask(3); - - Assert.assertEquals(task.getId(), 3); - Assert.assertEquals(task.getStatus(), TaskStatus.ACTIVE); - Assert.assertEquals(task.getText(), "Document API"); - Assert.assertEquals(task.isPrivate(), true); - Assert.assertEquals(task.getDueDate(), new LocalDate(2010, 8, 20)); - Assert.assertEquals(task.getResponsible().getUserId().intValue(), 2); - Assert.assertEquals(task.getSpaceId(), null); - Assert.assertEquals(task.getLink(), "https://podio.com/tasks/3"); - Assert.assertEquals(task.getCreatedOn(), new DateTime(2010, 8, 20, 11, - 30, 0, 0, DateTimeZone.UTC)); - Assert.assertEquals(task.getCreatedBy().getId(), 1); - Assert.assertEquals(task.getReferenceType(), null); - Assert.assertEquals(task.getReferenceId(), null); - Assert.assertEquals(task.getReferenceTitle(), null); - Assert.assertEquals(task.getReferenceLink(), null); - } - - @Test - public void assignTask() { - getAPI().assignTask(1, 1); - } - - @Test - public void completeTask() { - getAPI().completeTask(1); - } - - @Test - public void incompleteTask() { - getAPI().incompleteTask(4); - } - - @Test - public void startTask() { - getAPI().completeTask(1); - } - - @Test - public void stopTask() { - getAPI().incompleteTask(4); - } - - @Test - public void createTask() { - int taskId = getAPI().createTask( - new TaskCreate("Test task", null, false, new LocalDate(2010, - 11, 10), 1), false); - - Assert.assertTrue(taskId > 0); - } - - @Test - public void createTaskWithReference() { - int taskId = getAPI().createTaskWithReference( - new TaskCreate("Test task", null, false, new LocalDate(2010, - 11, 10), 1), new Reference(ReferenceType.ITEM, 1), - false); - - Assert.assertTrue(taskId > 0); - } - - @Test - public void updateDueDate() { - getAPI().updateDueDate(1, new LocalDate(2010, 11, 9)); - } - - @Test - public void updatePrivate() { - getAPI().updatePrivate(2, true); - } - - @Test - public void updateText() { - getAPI().updateText(1, "Test text"); - } - - @Test - public void getTasksWithReference() { - List tasks = getAPI().getTasksWithReference( - new Reference(ReferenceType.ITEM, 1)); - Assert.assertEquals(tasks.size(), 1); - Assert.assertEquals(tasks.get(0).getId(), 4); - } - - @Test - public void getTasksWithReferenceEmpty() { - List tasks = getAPI().getTasksWithReference( - new Reference(ReferenceType.ITEM, 3)); - Assert.assertEquals(tasks.size(), 0); - } -} +package com.podio.task; + +import java.util.List; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.LocalDate; +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.common.Reference; +import com.podio.common.ReferenceType; + +public class TaskAPITest { + + private TaskAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(TaskAPI.class); + } + + @Test + public void getTask() { + Task task = getAPI().getTask(3); + + Assert.assertEquals(task.getId(), 3); + Assert.assertEquals(task.getStatus(), TaskStatus.ACTIVE); + Assert.assertEquals(task.getText(), "Document API"); + Assert.assertEquals(task.isPrivate(), true); + Assert.assertEquals(task.getDueDate(), new LocalDate(2010, 8, 20)); + Assert.assertEquals(task.getResponsible().getUserId().intValue(), 2); + Assert.assertEquals(task.getSpaceId(), null); + Assert.assertEquals(task.getLink(), "https://podio.com/tasks/3"); + Assert.assertEquals(task.getCreatedOn(), new DateTime(2010, 8, 20, 11, + 30, 0, 0, DateTimeZone.UTC)); + Assert.assertEquals(task.getCreatedBy().getId(), 1); + Assert.assertEquals(task.getReferenceType(), null); + Assert.assertEquals(task.getReferenceId(), null); + Assert.assertEquals(task.getReferenceTitle(), null); + Assert.assertEquals(task.getReferenceLink(), null); + } + + @Test + public void assignTask() { + getAPI().assignTask(1, 1); + } + + @Test + public void completeTask() { + getAPI().completeTask(1); + } + + @Test + public void incompleteTask() { + getAPI().incompleteTask(4); + } + + @Test + public void startTask() { + getAPI().completeTask(1); + } + + @Test + public void stopTask() { + getAPI().incompleteTask(4); + } + + @Test + public void createTask() { + int taskId = getAPI().createTask( + new TaskCreate("Test task", null, false, new LocalDate(2010, + 11, 10), 1), false); + + Assert.assertTrue(taskId > 0); + } + + @Test + public void createTaskWithReference() { + int taskId = getAPI().createTaskWithReference( + new TaskCreate("Test task", null, false, new LocalDate(2010, + 11, 10), 1), new Reference(ReferenceType.ITEM, 1), + false); + + Assert.assertTrue(taskId > 0); + } + + @Test + public void updateDueDate() { + getAPI().updateDueDate(1, new LocalDate(2010, 11, 9)); + } + + @Test + public void updatePrivate() { + getAPI().updatePrivate(2, true); + } + + @Test + public void updateText() { + getAPI().updateText(1, "Test text"); + } + + @Test + public void getTasksWithReference() { + List tasks = getAPI().getTasksWithReference( + new Reference(ReferenceType.ITEM, 1)); + Assert.assertEquals(tasks.size(), 1); + Assert.assertEquals(tasks.get(0).getId(), 4); + } + + @Test + public void getTasksWithReferenceEmpty() { + List tasks = getAPI().getTasksWithReference( + new Reference(ReferenceType.ITEM, 3)); + Assert.assertEquals(tasks.size(), 0); + } +} diff --git a/src/test/java/com/podio/user/UserAPITest.java b/src/test/java/com/podio/user/UserAPITest.java index c8ec4b5..97a55cc 100644 --- a/src/test/java/com/podio/user/UserAPITest.java +++ b/src/test/java/com/podio/user/UserAPITest.java @@ -1,123 +1,123 @@ -package com.podio.user; - -import java.util.List; -import java.util.Locale; -import java.util.TimeZone; - -import org.junit.Assert; -import org.junit.Test; - -import com.podio.APIFactoryProvider; -import com.podio.contact.Profile; -import com.podio.contact.ProfileField; -import com.podio.contact.ProfileFieldValues; -import com.podio.contact.ProfileUpdate; - -public class UserAPITest { - - private UserAPI getAPI() { - return APIFactoryProvider.getDefault().getAPI(UserAPI.class); - } - - @Test - public void getProfile() { - Profile profile = getAPI().getProfile(); - Assert.assertEquals(profile.getName(), "Christian Holm"); - } - - @Test - public void getProfileField() { - List name = getAPI().getProfileField(ProfileField.NAME); - Assert.assertEquals(name.get(0), "Christian Holm"); - } - - @Test - public void updateProfileA() { - ProfileUpdate update = new ProfileUpdate(); - update.setName("Christian L. Holm"); - - getAPI().updateProfile(update); - } - - @Test - public void updateProfileB() { - ProfileFieldValues fields = new ProfileFieldValues(); - fields.setValue(ProfileField.NAME, "Christian L. Holm"); - - getAPI().updateProfile(fields); - } - - @Test - public void updateProfileFieldSingle() { - getAPI().updateProfileField(ProfileField.NAME, "Christian L. Holm"); - } - - @Test - public void updateProfileFieldMulti() { - getAPI().updateProfileField(ProfileField.ADDRESS, "Borgergade 144", - "1300 Kbh K"); - } - - @Test - public void updateProfileFieldMultiSingle() { - getAPI().updateProfileField(ProfileField.ADDRESS, "Borgergade 144"); - } - - @Test - public void getUser() { - User user = getAPI().getUser(); - Assert.assertEquals(user.getId(), 1); - } - - @Test - public void getUpdateUser() { - getAPI().updateUser( - new UserUpdate(new Locale("da", "DK"), TimeZone - .getTimeZone("Europe/Copenhagen"))); - } - - @Test - public void getStatus() { - UserStatus status = getAPI().getStatus(); - - User user = status.getUser(); - Assert.assertEquals(user.getId(), 1); - Assert.assertEquals(user.getMail(), "dev@hoisthq.com"); - Assert.assertEquals(user.getStatus(), UserStatusType.ACTIVE); - Assert.assertEquals(user.getLocale().getLanguage(), "en_gb"); - Assert.assertEquals(user.getTimezone().getID(), "Europe/Copenhagen"); - - Profile profile = status.getProfile(); - Assert.assertEquals(profile.getUserId().intValue(), 1); - Assert.assertEquals(profile.getName(), "Christian Holm"); - Assert.assertEquals(profile.getImage().getThumbnailLink(), "https://d1izh0afz5ebv1.cloudfront.net/public/9"); - - Assert.assertEquals(status.getProperties().size(), 5); - Assert.assertEquals( - status.getProperties().get("global.video").get("value"), - Boolean.TRUE); - - Assert.assertEquals(status.getCalendarCode(), - "3OAnjyFACrJjTNe2JLnpn9ZqVe5dLWS59aSLzqtvlXZyXUenbRVqvQwtOMOYZk2T"); - - Assert.assertEquals(status.getInboxNew(), 59); - Assert.assertEquals(status.getMessageUnreadCount(), 5); - Assert.assertEquals(status.getMailbox(), "cholm.fdb27615"); - } - - @Test - public void getProperty() { - boolean value = getAPI().getProperty("global.video"); - Assert.assertEquals(value, true); - } - - @Test - public void setProperty() { - getAPI().setProperty("test.prop", true); - } - - @Test - public void deleteProperty() { - getAPI().deleteProperty("global.video"); - } -} +package com.podio.user; + +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +import org.junit.Assert; +import org.junit.Test; + +import com.podio.APIFactoryProvider; +import com.podio.contact.Profile; +import com.podio.contact.ProfileField; +import com.podio.contact.ProfileFieldValues; +import com.podio.contact.ProfileUpdate; + +public class UserAPITest { + + private UserAPI getAPI() { + return APIFactoryProvider.getDefault().getAPI(UserAPI.class); + } + + @Test + public void getProfile() { + Profile profile = getAPI().getProfile(); + Assert.assertEquals(profile.getName(), "Christian Holm"); + } + + @Test + public void getProfileField() { + List name = getAPI().getProfileField(ProfileField.NAME); + Assert.assertEquals(name.get(0), "Christian Holm"); + } + + @Test + public void updateProfileA() { + ProfileUpdate update = new ProfileUpdate(); + update.setName("Christian L. Holm"); + + getAPI().updateProfile(update); + } + + @Test + public void updateProfileB() { + ProfileFieldValues fields = new ProfileFieldValues(); + fields.setValue(ProfileField.NAME, "Christian L. Holm"); + + getAPI().updateProfile(fields); + } + + @Test + public void updateProfileFieldSingle() { + getAPI().updateProfileField(ProfileField.NAME, "Christian L. Holm"); + } + + @Test + public void updateProfileFieldMulti() { + getAPI().updateProfileField(ProfileField.ADDRESS, "Borgergade 144", + "1300 Kbh K"); + } + + @Test + public void updateProfileFieldMultiSingle() { + getAPI().updateProfileField(ProfileField.ADDRESS, "Borgergade 144"); + } + + @Test + public void getUser() { + User user = getAPI().getUser(); + Assert.assertEquals(user.getId(), 1); + } + + @Test + public void getUpdateUser() { + getAPI().updateUser( + new UserUpdate(new Locale("da", "DK"), TimeZone + .getTimeZone("Europe/Copenhagen"))); + } + + @Test + public void getStatus() { + UserStatus status = getAPI().getStatus(); + + User user = status.getUser(); + Assert.assertEquals(user.getId(), 1); + Assert.assertEquals(user.getMail(), "dev@hoisthq.com"); + Assert.assertEquals(user.getStatus(), UserStatusType.ACTIVE); + Assert.assertEquals(user.getLocale().getLanguage(), "en_gb"); + Assert.assertEquals(user.getTimezone().getID(), "Europe/Copenhagen"); + + Profile profile = status.getProfile(); + Assert.assertEquals(profile.getUserId().intValue(), 1); + Assert.assertEquals(profile.getName(), "Christian Holm"); + Assert.assertEquals(profile.getImage().getThumbnailLink(), "https://d1izh0afz5ebv1.cloudfront.net/public/9"); + + Assert.assertEquals(status.getProperties().size(), 5); + Assert.assertEquals( + status.getProperties().get("global.video").get("value"), + Boolean.TRUE); + + Assert.assertEquals(status.getCalendarCode(), + "3OAnjyFACrJjTNe2JLnpn9ZqVe5dLWS59aSLzqtvlXZyXUenbRVqvQwtOMOYZk2T"); + + Assert.assertEquals(status.getInboxNew(), 59); + Assert.assertEquals(status.getMessageUnreadCount(), 5); + Assert.assertEquals(status.getMailbox(), "cholm.fdb27615"); + } + + @Test + public void getProperty() { + boolean value = getAPI().getProperty("global.video"); + Assert.assertEquals(value, true); + } + + @Test + public void setProperty() { + getAPI().setProperty("test.prop", true); + } + + @Test + public void deleteProperty() { + getAPI().deleteProperty("global.video"); + } +}