├── .gitignore ├── .settings ├── org.maven.ide.eclipse.prefs └── org.eclipse.jdt.core.prefs ├── src ├── main │ └── java │ │ └── com │ │ └── podio │ │ └── integration │ │ └── zendesk │ │ ├── search │ │ ├── SearchResult.java │ │ └── SearchAPI.java │ │ ├── serialize │ │ ├── DateTimeDeserializer.java │ │ ├── DateTimeSerializer.java │ │ ├── TagListDeserializer.java │ │ └── DateTimeUtil.java │ │ ├── user │ │ ├── UserAPI.java │ │ ├── UserRole.java │ │ └── User.java │ │ ├── ticket │ │ ├── TicketAPI.java │ │ ├── TicketType.java │ │ ├── TicketStatus.java │ │ ├── TicketVia.java │ │ ├── TicketPriority.java │ │ ├── TicketFieldEntry.java │ │ ├── TicketComment.java │ │ └── Ticket.java │ │ ├── CustomJacksonJsonProvider.java │ │ ├── group │ │ └── Group.java │ │ ├── attachment │ │ └── Attachment.java │ │ └── APIFactory.java └── test │ └── java │ └── com │ └── podio │ └── zendesk │ ├── search │ └── SearchAPITest.java │ ├── user │ └── UserAPITest.java │ └── ticket │ └── TicketAPITest.java ├── .project ├── .classpath └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /config.properties 2 | /target 3 | -------------------------------------------------------------------------------- /.settings/org.maven.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | #Wed Nov 24 20:56:38 CET 2010 2 | activeProfiles= 3 | eclipse.preferences.version=1 4 | fullBuildGoals=process-test-resources 5 | resolveWorkspaceProjects=true 6 | resourceFilterGoals=process-resources resources\:testResources 7 | skipCompilerPlugin=true 8 | version=1 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Wed Nov 24 20:56:38 CET 2010 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 | org.eclipse.jdt.core.compiler.compliance=1.5 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.source=1.5 7 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/search/SearchResult.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.search; 2 | 3 | import java.util.List; 4 | 5 | import com.podio.integration.zendesk.ticket.Ticket; 6 | 7 | public class SearchResult { 8 | 9 | private int count; 10 | 11 | private List tickets; 12 | 13 | public int getCount() { 14 | return count; 15 | } 16 | 17 | public void setCount(int count) { 18 | this.count = count; 19 | } 20 | 21 | public void setTickets(List tickets) { 22 | this.tickets = tickets; 23 | } 24 | 25 | public List getTickets() { 26 | return tickets; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | zendesk 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.maven.ide.eclipse.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.maven.ide.eclipse.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/serialize/DateTimeDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.serialize; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonParser; 6 | import org.codehaus.jackson.JsonProcessingException; 7 | import org.codehaus.jackson.map.DeserializationContext; 8 | import org.codehaus.jackson.map.JsonDeserializer; 9 | import org.joda.time.DateTime; 10 | 11 | public class DateTimeDeserializer extends JsonDeserializer { 12 | 13 | @Override 14 | public DateTime deserialize(JsonParser jp, DeserializationContext ctxt) 15 | throws IOException, JsonProcessingException { 16 | return DateTimeUtil.parseDateTime(jp.getText()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/serialize/DateTimeSerializer.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.serialize; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonGenerator; 6 | import org.codehaus.jackson.JsonProcessingException; 7 | import org.codehaus.jackson.map.JsonSerializer; 8 | import org.codehaus.jackson.map.SerializerProvider; 9 | import org.joda.time.DateTime; 10 | 11 | public class DateTimeSerializer extends JsonSerializer { 12 | 13 | @Override 14 | public void serialize(DateTime value, JsonGenerator jgen, 15 | SerializerProvider provider) throws IOException, 16 | JsonProcessingException { 17 | jgen.writeString(DateTimeUtil.formatDateTime(value)); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/serialize/TagListDeserializer.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.serialize; 2 | 3 | import java.io.IOException; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | import org.codehaus.jackson.JsonParser; 8 | import org.codehaus.jackson.JsonProcessingException; 9 | import org.codehaus.jackson.map.DeserializationContext; 10 | import org.codehaus.jackson.map.JsonDeserializer; 11 | 12 | public class TagListDeserializer extends JsonDeserializer> { 13 | 14 | @Override 15 | public List deserialize(JsonParser jp, DeserializationContext ctxt) 16 | throws IOException, JsonProcessingException { 17 | return Arrays.asList(jp.getText().split(" ")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/user/UserAPI.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.user; 2 | 3 | import javax.ws.rs.core.MediaType; 4 | 5 | import com.sun.jersey.api.client.WebResource; 6 | 7 | public class UserAPI { 8 | 9 | // 2010/11/24 21:42:50 +0100 10 | 11 | private final WebResource rootResource; 12 | 13 | public UserAPI(WebResource rootResource) { 14 | super(); 15 | this.rootResource = rootResource; 16 | } 17 | 18 | public User getCurrentUser() { 19 | return rootResource.path("/users/current.json") 20 | .accept(MediaType.APPLICATION_JSON_TYPE).get(User.class); 21 | } 22 | 23 | public User getUser(int id) { 24 | return rootResource.path("/users/" + id + ".json") 25 | .accept(MediaType.APPLICATION_JSON_TYPE).get(User.class); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/serialize/DateTimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.serialize; 2 | 3 | import org.joda.time.DateTime; 4 | import org.joda.time.DateTimeZone; 5 | import org.joda.time.format.DateTimeFormat; 6 | import org.joda.time.format.DateTimeFormatter; 7 | 8 | public final class DateTimeUtil { 9 | 10 | private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormat 11 | .forPattern("yyyy/MM/dd HH:mm:ss Z"); 12 | 13 | private DateTimeUtil() { 14 | } 15 | 16 | public static DateTime parseDateTime(String text) { 17 | return DATE_TIME_FORMAT.parseDateTime(text) 18 | .toDateTime(DateTimeZone.UTC); 19 | } 20 | 21 | public static String formatDateTime(DateTime dateTime) { 22 | return DATE_TIME_FORMAT.print(dateTime); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/podio/zendesk/search/SearchAPITest.java: -------------------------------------------------------------------------------- 1 | package com.podio.zendesk.search; 2 | 3 | import java.io.IOException; 4 | import java.util.Collections; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | import com.podio.integration.zendesk.APIFactory; 10 | import com.podio.integration.zendesk.search.SearchAPI; 11 | import com.podio.integration.zendesk.search.SearchResult; 12 | 13 | public class SearchAPITest { 14 | 15 | private static SearchAPI getAPI() throws IOException { 16 | return APIFactory.getFromConfig().getSearchAPI(); 17 | } 18 | 19 | @Test 20 | public void search() throws IOException { 21 | SearchResult result = getAPI().search( 22 | Collections.singletonMap("query", "status:sovled")); 23 | Assert.assertTrue(result.getCount() > 1); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/search/SearchAPI.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.search; 2 | 3 | import java.util.Map; 4 | 5 | import javax.ws.rs.core.MediaType; 6 | 7 | import com.sun.jersey.api.client.WebResource; 8 | 9 | public class SearchAPI { 10 | 11 | private final WebResource rootResource; 12 | 13 | public SearchAPI(WebResource rootResource) { 14 | super(); 15 | this.rootResource = rootResource; 16 | } 17 | 18 | public SearchResult search(Map parameters) { 19 | WebResource resource = rootResource.path("/rules/search.json"); 20 | 21 | for (Map.Entry entry : parameters.entrySet()) { 22 | resource = resource.queryParam(entry.getKey(), entry.getValue()); 23 | } 24 | 25 | return resource.accept(MediaType.APPLICATION_JSON_TYPE).get( 26 | SearchResult.class); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/TicketAPI.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import java.util.List; 4 | 5 | import javax.ws.rs.core.MediaType; 6 | 7 | import com.sun.jersey.api.client.GenericType; 8 | import com.sun.jersey.api.client.WebResource; 9 | 10 | public class TicketAPI { 11 | 12 | // 2010/11/24 21:42:50 +0100 13 | 14 | private final WebResource rootResource; 15 | 16 | public TicketAPI(WebResource rootResource) { 17 | super(); 18 | this.rootResource = rootResource; 19 | } 20 | 21 | public Ticket getTicket(int id) { 22 | return rootResource.path("/tickets/" + id + ".json") 23 | .accept(MediaType.APPLICATION_JSON_TYPE).get(Ticket.class); 24 | } 25 | 26 | public List getTickets(int viewId, Integer page) { 27 | WebResource resource = rootResource.path("/rules/" + viewId + ".json"); 28 | if (page != null) { 29 | resource = resource.queryParam("page", page.toString()); 30 | } 31 | 32 | return resource.accept(MediaType.APPLICATION_JSON_TYPE).get( 33 | new GenericType>() { 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/CustomJacksonJsonProvider.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk; 2 | 3 | import javax.ws.rs.Consumes; 4 | import javax.ws.rs.core.MediaType; 5 | 6 | import org.codehaus.jackson.jaxrs.JacksonJsonProvider; 7 | import org.codehaus.jackson.map.ObjectMapper; 8 | 9 | @Consumes({ MediaType.APPLICATION_JSON, "text/json", "text/javascript", 10 | "application/x-javascript", "text/plain" }) 11 | public class CustomJacksonJsonProvider extends JacksonJsonProvider { 12 | 13 | public CustomJacksonJsonProvider(ObjectMapper mapper) { 14 | super(mapper); 15 | } 16 | 17 | @Override 18 | protected boolean isJsonType(MediaType mediaType) { 19 | if (super.isJsonType(mediaType)) { 20 | return true; 21 | } 22 | 23 | return mediaType != null 24 | && (mediaType.getType().equalsIgnoreCase("text") && mediaType 25 | .getSubtype().equals("javascript")) 26 | || (mediaType.getType().equalsIgnoreCase("application") && mediaType 27 | .getSubtype().equals("x-javascript")) 28 | || (mediaType.getType().equalsIgnoreCase("text") && mediaType 29 | .getSubtype().equals("plain")); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/user/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.user; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonParser; 6 | import org.codehaus.jackson.JsonProcessingException; 7 | import org.codehaus.jackson.annotate.JsonValue; 8 | import org.codehaus.jackson.map.DeserializationContext; 9 | import org.codehaus.jackson.map.JsonDeserializer; 10 | 11 | public enum UserRole { 12 | 13 | END_USER(0), 14 | ADMINISTRATOR(2), 15 | AGENT(4); 16 | 17 | private final int id; 18 | 19 | private UserRole(int id) { 20 | this.id = id; 21 | } 22 | 23 | @JsonValue 24 | public int getId() { 25 | return id; 26 | } 27 | 28 | public static UserRole getById(int id) { 29 | for (UserRole role : values()) { 30 | if (role.getId() == id) { 31 | return role; 32 | } 33 | } 34 | 35 | return null; 36 | } 37 | 38 | public static class Deserializer extends JsonDeserializer { 39 | 40 | @Override 41 | public UserRole deserialize(JsonParser jp, DeserializationContext ctxt) 42 | throws IOException, JsonProcessingException { 43 | return getById(jp.getIntValue()); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/TicketType.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonParser; 6 | import org.codehaus.jackson.JsonProcessingException; 7 | import org.codehaus.jackson.annotate.JsonValue; 8 | import org.codehaus.jackson.map.DeserializationContext; 9 | import org.codehaus.jackson.map.JsonDeserializer; 10 | 11 | public enum TicketType { 12 | 13 | NONE(0), 14 | QUESTION(1), 15 | INCIDENT(2), 16 | PROBLEM(3), 17 | TASK(4); 18 | 19 | private final int id; 20 | 21 | private TicketType(int id) { 22 | this.id = id; 23 | } 24 | 25 | @JsonValue 26 | public int getId() { 27 | return id; 28 | } 29 | 30 | public static TicketType getById(int id) { 31 | for (TicketType status : values()) { 32 | if (status.getId() == id) { 33 | return status; 34 | } 35 | } 36 | 37 | return null; 38 | } 39 | 40 | public static class Deserializer extends JsonDeserializer { 41 | 42 | @Override 43 | public TicketType deserialize(JsonParser jp, DeserializationContext ctxt) 44 | throws IOException, JsonProcessingException { 45 | return getById(jp.getIntValue()); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/TicketStatus.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonParser; 6 | import org.codehaus.jackson.JsonProcessingException; 7 | import org.codehaus.jackson.annotate.JsonValue; 8 | import org.codehaus.jackson.map.DeserializationContext; 9 | import org.codehaus.jackson.map.JsonDeserializer; 10 | 11 | public enum TicketStatus { 12 | 13 | NEW(0), 14 | OPEN(1), 15 | PENDING(2), 16 | SOLVED(3), 17 | CLOSED(4); 18 | 19 | private final int id; 20 | 21 | private TicketStatus(int id) { 22 | this.id = id; 23 | } 24 | 25 | @JsonValue 26 | public int getId() { 27 | return id; 28 | } 29 | 30 | public static TicketStatus getById(int id) { 31 | for (TicketStatus status : values()) { 32 | if (status.getId() == id) { 33 | return status; 34 | } 35 | } 36 | 37 | return null; 38 | } 39 | 40 | public static class Deserializer extends JsonDeserializer { 41 | 42 | @Override 43 | public TicketStatus deserialize(JsonParser jp, 44 | DeserializationContext ctxt) throws IOException, 45 | JsonProcessingException { 46 | return getById(jp.getIntValue()); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/group/Group.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.group; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | import org.joda.time.DateTime; 5 | 6 | public class Group { 7 | 8 | private int id; 9 | 10 | private String name; 11 | 12 | private DateTime createdAt; 13 | 14 | private DateTime updatedAt; 15 | 16 | private boolean active; 17 | 18 | public int getId() { 19 | return id; 20 | } 21 | 22 | public void setId(int id) { 23 | this.id = id; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | public DateTime getCreatedAt() { 35 | return createdAt; 36 | } 37 | 38 | @JsonProperty("created_at") 39 | public void setCreatedAt(DateTime createdAt) { 40 | this.createdAt = createdAt; 41 | } 42 | 43 | public DateTime getUpdatedAt() { 44 | return updatedAt; 45 | } 46 | 47 | @JsonProperty("updated_at") 48 | public void setUpdatedAt(DateTime updatedAt) { 49 | this.updatedAt = updatedAt; 50 | } 51 | 52 | public boolean isActive() { 53 | return active; 54 | } 55 | 56 | @JsonProperty("is_active") 57 | public void setActive(boolean active) { 58 | this.active = active; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/TicketVia.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonParser; 6 | import org.codehaus.jackson.JsonProcessingException; 7 | import org.codehaus.jackson.annotate.JsonValue; 8 | import org.codehaus.jackson.map.DeserializationContext; 9 | import org.codehaus.jackson.map.JsonDeserializer; 10 | 11 | public enum TicketVia { 12 | 13 | WEB_FORM(0), 14 | MAIL(4), 15 | WEB_SERVICE(5), 16 | GET_SATISFACTION(16), 17 | DROPBOX(17), 18 | RECOVERED(21), 19 | FORUM(24); 20 | 21 | private final int id; 22 | 23 | private TicketVia(int id) { 24 | this.id = id; 25 | } 26 | 27 | @JsonValue 28 | public int getId() { 29 | return id; 30 | } 31 | 32 | public static TicketVia getById(int id) { 33 | for (TicketVia viaType : values()) { 34 | if (viaType.getId() == id) { 35 | return viaType; 36 | } 37 | } 38 | 39 | return null; 40 | } 41 | 42 | public static class Deserializer extends JsonDeserializer { 43 | 44 | @Override 45 | public TicketVia deserialize(JsonParser jp, 46 | DeserializationContext ctxt) throws IOException, 47 | JsonProcessingException { 48 | return getById(jp.getIntValue()); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/TicketPriority.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import java.io.IOException; 4 | 5 | import org.codehaus.jackson.JsonParser; 6 | import org.codehaus.jackson.JsonProcessingException; 7 | import org.codehaus.jackson.annotate.JsonCreator; 8 | import org.codehaus.jackson.annotate.JsonValue; 9 | import org.codehaus.jackson.map.DeserializationContext; 10 | import org.codehaus.jackson.map.JsonDeserializer; 11 | 12 | public enum TicketPriority { 13 | 14 | NONE(0), 15 | LOW(1), 16 | NORMAL(2), 17 | HIGH(3), 18 | URGENT(4); 19 | 20 | private final int id; 21 | 22 | private TicketPriority(int id) { 23 | this.id = id; 24 | } 25 | 26 | @JsonValue 27 | public int getId() { 28 | return id; 29 | } 30 | 31 | @JsonCreator 32 | public static TicketPriority getById(int id) { 33 | for (TicketPriority priority : values()) { 34 | if (priority.getId() == id) { 35 | return priority; 36 | } 37 | } 38 | 39 | return null; 40 | } 41 | 42 | public static class Deserializer extends JsonDeserializer { 43 | 44 | @Override 45 | public TicketPriority deserialize(JsonParser jp, 46 | DeserializationContext ctxt) throws IOException, 47 | JsonProcessingException { 48 | return getById(jp.getIntValue()); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/TicketFieldEntry.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import org.codehaus.jackson.annotate.JsonProperty; 4 | import org.joda.time.DateTime; 5 | 6 | public class TicketFieldEntry { 7 | 8 | private int fieldId; 9 | 10 | private DateTime createdAt; 11 | 12 | private DateTime updatedAt; 13 | 14 | private int ticketId; 15 | 16 | private String value; 17 | 18 | public int getFieldId() { 19 | return fieldId; 20 | } 21 | 22 | @JsonProperty("ticket_field_id") 23 | public void setFieldId(int fieldId) { 24 | this.fieldId = fieldId; 25 | } 26 | 27 | public DateTime getCreatedAt() { 28 | return createdAt; 29 | } 30 | 31 | @JsonProperty("created_at") 32 | public void setCreatedAt(DateTime createdAt) { 33 | this.createdAt = createdAt; 34 | } 35 | 36 | public DateTime getUpdatedAt() { 37 | return updatedAt; 38 | } 39 | 40 | @JsonProperty("updated_at") 41 | public void setUpdatedAt(DateTime updatedAt) { 42 | this.updatedAt = updatedAt; 43 | } 44 | 45 | public int getTicketId() { 46 | return ticketId; 47 | } 48 | 49 | @JsonProperty("ticket_id") 50 | public void setTicketId(int ticketId) { 51 | this.ticketId = ticketId; 52 | } 53 | 54 | public String getValue() { 55 | return value; 56 | } 57 | 58 | public void setValue(String value) { 59 | this.value = value; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/TicketComment.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import java.util.List; 4 | 5 | import org.codehaus.jackson.annotate.JsonProperty; 6 | import org.codehaus.jackson.map.annotate.JsonDeserialize; 7 | import org.joda.time.DateTime; 8 | 9 | import com.podio.integration.zendesk.attachment.Attachment; 10 | 11 | public class TicketComment { 12 | 13 | private int authorId; 14 | 15 | private String value; 16 | 17 | private TicketVia via; 18 | 19 | private boolean isPublic; 20 | 21 | private DateTime createdAt; 22 | 23 | private List attachments; 24 | 25 | public int getAuthorId() { 26 | return authorId; 27 | } 28 | 29 | @JsonProperty("author_id") 30 | public void setAuthorId(int authorId) { 31 | this.authorId = authorId; 32 | } 33 | 34 | public DateTime getCreatedAt() { 35 | return createdAt; 36 | } 37 | 38 | @JsonProperty("created_at") 39 | public void setCreatedAt(DateTime createdAt) { 40 | this.createdAt = createdAt; 41 | } 42 | 43 | public boolean isPublic() { 44 | return isPublic; 45 | } 46 | 47 | @JsonProperty("is_public") 48 | public void setPublic(boolean isPublic) { 49 | this.isPublic = isPublic; 50 | } 51 | 52 | public String getValue() { 53 | return value; 54 | } 55 | 56 | public void setValue(String value) { 57 | this.value = value; 58 | } 59 | 60 | public TicketVia getVia() { 61 | return via; 62 | } 63 | 64 | @JsonProperty("via_id") 65 | @JsonDeserialize(using = TicketVia.Deserializer.class) 66 | public void setVia(TicketVia via) { 67 | this.via = via; 68 | } 69 | 70 | public List getAttachments() { 71 | return attachments; 72 | } 73 | 74 | public void setAttachments(List attachments) { 75 | this.attachments = attachments; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/attachment/Attachment.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.attachment; 2 | 3 | import java.net.URL; 4 | 5 | import org.codehaus.jackson.annotate.JsonProperty; 6 | import org.joda.time.DateTime; 7 | 8 | public class Attachment { 9 | 10 | private int id; 11 | 12 | private int size; 13 | 14 | private String contentType; 15 | 16 | private String filename; 17 | 18 | private URL url; 19 | 20 | private String token; 21 | 22 | private boolean isPublic; 23 | 24 | private DateTime createdAt; 25 | 26 | public int getId() { 27 | return id; 28 | } 29 | 30 | public void setId(int id) { 31 | this.id = id; 32 | } 33 | 34 | public int getSize() { 35 | return size; 36 | } 37 | 38 | public void setSize(int size) { 39 | this.size = size; 40 | } 41 | 42 | public String getContentType() { 43 | return contentType; 44 | } 45 | 46 | @JsonProperty("content_type") 47 | public void setContentType(String contentType) { 48 | this.contentType = contentType; 49 | } 50 | 51 | public String getFilename() { 52 | return filename; 53 | } 54 | 55 | public void setFilename(String filename) { 56 | this.filename = filename; 57 | } 58 | 59 | public URL getUrl() { 60 | return url; 61 | } 62 | 63 | public void setUrl(URL url) { 64 | this.url = url; 65 | } 66 | 67 | public String getToken() { 68 | return token; 69 | } 70 | 71 | public void setToken(String token) { 72 | this.token = token; 73 | } 74 | 75 | public boolean isPublic() { 76 | return isPublic; 77 | } 78 | 79 | @JsonProperty("is_public") 80 | public void setPublic(boolean isPublic) { 81 | this.isPublic = isPublic; 82 | } 83 | 84 | public DateTime getCreatedAt() { 85 | return createdAt; 86 | } 87 | 88 | @JsonProperty("created_at") 89 | public void setCreatedAt(DateTime createdAt) { 90 | this.createdAt = createdAt; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/test/java/com/podio/zendesk/user/UserAPITest.java: -------------------------------------------------------------------------------- 1 | package com.podio.zendesk.user; 2 | 3 | import java.io.IOException; 4 | 5 | import org.joda.time.DateTime; 6 | import org.joda.time.DateTimeZone; 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | 10 | import com.podio.integration.zendesk.APIFactory; 11 | import com.podio.integration.zendesk.user.User; 12 | import com.podio.integration.zendesk.user.UserAPI; 13 | import com.podio.integration.zendesk.user.UserRole; 14 | 15 | public class UserAPITest { 16 | 17 | private static UserAPI getAPI() throws IOException { 18 | return APIFactory.getFromConfig().getUserAPI(); 19 | } 20 | 21 | @Test 22 | public void getCurrentUser() throws IOException { 23 | User user = getAPI().getCurrentUser(); 24 | 25 | Assert.assertEquals(user.getId(), 16080839); 26 | } 27 | 28 | @Test 29 | public void getUser() throws IOException { 30 | User user = getAPI().getUser(16080839); 31 | 32 | Assert.assertEquals(user.getGroups().size(), 2); 33 | Assert.assertEquals(user.getGroups().get(1).getName(), "Support"); 34 | Assert.assertEquals(user.getGroups().get(1).getCreatedAt(), null); 35 | Assert.assertEquals(user.getGroups().get(1).getId(), 1807); 36 | Assert.assertEquals(user.getGroups().get(1).getUpdatedAt(), null); 37 | 38 | Assert.assertEquals(user.getDetails(), ""); 39 | Assert.assertEquals(user.getEmail(), "holm@hoisthq.com"); 40 | Assert.assertEquals(user.getExternalId(), null); 41 | Assert.assertEquals(user.getName(), "Christian Holm"); 42 | Assert.assertEquals(user.getNotes(), ""); 43 | Assert.assertEquals(user.getOpenIdURL(), null); 44 | Assert.assertEquals(user.getPhone(), ""); 45 | Assert.assertEquals(user.getCreatedAt(), new DateTime(2010, 8, 26, 9, 46 | 50, 12, 0, DateTimeZone.UTC)); 47 | Assert.assertEquals(user.getId(), 16080839); 48 | Assert.assertNotNull(user.getLastLogin()); 49 | Assert.assertEquals(user.getLocaleId(), null); 50 | Assert.assertEquals(user.getOrganizationId(), null); 51 | Assert.assertEquals( 52 | user.getPhotoURL().toString(), 53 | "https://hoist.zendesk.com/system/photos/0015/9483/picture-5343-1275426057_thumb.jpg"); 54 | Assert.assertEquals(user.getRestrictionId().intValue(), 0); 55 | Assert.assertEquals(user.getRole(), UserRole.ADMINISTRATOR); 56 | Assert.assertEquals(user.getTimeZone(), "Copenhagen"); 57 | Assert.assertEquals(user.isVerified(), true); 58 | Assert.assertEquals(user.isActive(), true); 59 | Assert.assertNotNull(user.getUpdatedAt()); 60 | } 61 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.podio.integration 5 | zendesk 6 | 0.5.0-SNAPSHOT 7 | ZenDesk API 8 | 9 | 10 | 11 | 12 | maven-compiler-plugin 13 | 2.3.2 14 | 15 | 1.6 16 | 1.6 17 | 18 | 19 | 20 | 21 | 22 | 23 | maven2-repository.dev.java.net 24 | Java.net Repository for Maven 25 | http://download.java.net/maven/2/ 26 | default 27 | 28 | 29 | 30 | 31 | nexus 32 | Podio Nexus 33 | http://localhost:9191/nexus/content/repositories/releases/ 34 | 35 | 36 | 37 | 38 | UTF-8 39 | 40 | 41 | 42 | 43 | junit 44 | junit 45 | 4.8.2 46 | compile 47 | 48 | 49 | com.sun.jersey 50 | jersey-client 51 | 1.4 52 | compile 53 | 54 | 55 | com.sun.jersey.contribs 56 | jersey-multipart 57 | 1.4 58 | compile 59 | 60 | 61 | com.sun.jersey 62 | jersey-json 63 | 1.4 64 | compile 65 | 66 | 67 | org.eclipse.jetty 68 | jetty-client 69 | 8.0.0.M1 70 | jar 71 | compile 72 | 73 | 74 | org.codehaus.jackson 75 | jackson-jaxrs 76 | 1.6.1 77 | jar 78 | compile 79 | 80 | 81 | org.codehaus.jackson 82 | jackson-core-asl 83 | 1.6.1 84 | jar 85 | compile 86 | 87 | 88 | org.codehaus.jackson 89 | jackson-mapper-asl 90 | 1.6.1 91 | jar 92 | compile 93 | 94 | 95 | org.codehaus.jackson 96 | jackson-xc 97 | 1.6.1 98 | jar 99 | compile 100 | 101 | 102 | joda-time 103 | joda-time 104 | 1.6.2 105 | jar 106 | compile 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/APIFactory.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | import java.net.URI; 6 | import java.net.URISyntaxException; 7 | import java.util.Properties; 8 | 9 | import org.codehaus.jackson.jaxrs.JacksonJsonProvider; 10 | import org.codehaus.jackson.map.DeserializationConfig; 11 | import org.codehaus.jackson.map.ObjectMapper; 12 | import org.codehaus.jackson.map.SerializationConfig; 13 | import org.codehaus.jackson.map.deser.CustomDeserializerFactory; 14 | import org.codehaus.jackson.map.deser.StdDeserializerProvider; 15 | import org.codehaus.jackson.map.ser.CustomSerializerFactory; 16 | import org.joda.time.DateTime; 17 | 18 | import com.podio.integration.zendesk.search.SearchAPI; 19 | import com.podio.integration.zendesk.serialize.DateTimeDeserializer; 20 | import com.podio.integration.zendesk.serialize.DateTimeSerializer; 21 | import com.podio.integration.zendesk.ticket.TicketAPI; 22 | import com.podio.integration.zendesk.user.UserAPI; 23 | import com.sun.jersey.api.client.Client; 24 | import com.sun.jersey.api.client.WebResource; 25 | import com.sun.jersey.api.client.config.ClientConfig; 26 | import com.sun.jersey.api.client.config.DefaultClientConfig; 27 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; 28 | 29 | public class APIFactory { 30 | 31 | private final WebResource rootResource; 32 | 33 | public APIFactory(String domain, boolean ssl, String username, 34 | String password) { 35 | ClientConfig config = new DefaultClientConfig(); 36 | config.getSingletons().add(getJsonProvider()); 37 | Client client = Client.create(config); 38 | 39 | this.rootResource = client.resource(getURI(domain, ssl)); 40 | this.rootResource 41 | .addFilter(new HTTPBasicAuthFilter(username, password)); 42 | } 43 | 44 | private URI getURI(String domain, boolean ssl) { 45 | try { 46 | return new URI(ssl ? "https" : "http", null, domain 47 | + ".zendesk.com", ssl ? 443 : 80, null, null, null); 48 | } catch (URISyntaxException e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | 53 | private JacksonJsonProvider getJsonProvider() { 54 | ObjectMapper mapper = new ObjectMapper(); 55 | mapper.configure( 56 | DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); 57 | mapper.configure( 58 | DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, true); 59 | mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); 60 | 61 | CustomSerializerFactory serializerFactory = new CustomSerializerFactory(); 62 | serializerFactory.addSpecificMapping(DateTime.class, 63 | new DateTimeSerializer()); 64 | mapper.setSerializerFactory(serializerFactory); 65 | 66 | CustomDeserializerFactory deserializerFactory = new CustomDeserializerFactory(); 67 | deserializerFactory.addSpecificMapping(DateTime.class, 68 | new DateTimeDeserializer()); 69 | mapper.setDeserializerProvider(new StdDeserializerProvider( 70 | deserializerFactory)); 71 | 72 | return new CustomJacksonJsonProvider(mapper); 73 | } 74 | 75 | public TicketAPI getTicketAPI() { 76 | return new TicketAPI(rootResource); 77 | } 78 | 79 | public SearchAPI getSearchAPI() { 80 | return new SearchAPI(rootResource); 81 | } 82 | 83 | public UserAPI getUserAPI() { 84 | return new UserAPI(rootResource); 85 | } 86 | 87 | public static APIFactory getFromConfig() throws IOException { 88 | Properties properties = new Properties(); 89 | properties.load(new FileInputStream("config.properties")); 90 | 91 | return new APIFactory(properties.getProperty("domain"), 92 | Boolean.parseBoolean(properties.getProperty("ssl")), 93 | properties.getProperty("username"), 94 | properties.getProperty("password")); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/test/java/com/podio/zendesk/ticket/TicketAPITest.java: -------------------------------------------------------------------------------- 1 | package com.podio.zendesk.ticket; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | import org.joda.time.DateTime; 7 | import org.joda.time.DateTimeZone; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | 11 | import com.podio.integration.zendesk.APIFactory; 12 | import com.podio.integration.zendesk.ticket.Ticket; 13 | import com.podio.integration.zendesk.ticket.TicketAPI; 14 | import com.podio.integration.zendesk.ticket.TicketPriority; 15 | import com.podio.integration.zendesk.ticket.TicketStatus; 16 | import com.podio.integration.zendesk.ticket.TicketType; 17 | import com.podio.integration.zendesk.ticket.TicketVia; 18 | 19 | public class TicketAPITest { 20 | 21 | private static TicketAPI getAPI() throws IOException { 22 | return APIFactory.getFromConfig().getTicketAPI(); 23 | } 24 | 25 | @Test 26 | public void getTicket() throws IOException { 27 | Ticket ticket = getAPI().getTicket(933); 28 | 29 | System.out.println(ticket.getAssignedAt().getZone()); 30 | Assert.assertEquals(ticket.getAssignedAt(), new DateTime(2010, 11, 24, 31 | 20, 42, 51, 0, DateTimeZone.UTC)); 32 | Assert.assertEquals(ticket.getAssigneeId().intValue(), 16080839); 33 | Assert.assertEquals(ticket.getCreatedAt(), new DateTime(2010, 11, 24, 34 | 20, 1, 34, 0, DateTimeZone.UTC)); 35 | Assert.assertEquals(ticket.getSubject(), ""); 36 | Assert.assertTrue(ticket.getDescription().contains("Popup:")); 37 | Assert.assertEquals(ticket.getExternalId(), null); 38 | Assert.assertEquals(ticket.getGroupId(), 1807); 39 | Assert.assertEquals(ticket.getId(), 933); 40 | Assert.assertEquals(ticket.getLinkings().size(), 0); 41 | Assert.assertEquals(ticket.getPriority(), TicketPriority.NONE); 42 | Assert.assertEquals(ticket.getSubmitterId(), 21480147); 43 | Assert.assertEquals(ticket.getStatus(), TicketStatus.CLOSED); 44 | Assert.assertEquals(ticket.getStatusUpdatedAt(), new DateTime(2010, 12, 45 | 1, 12, 0, 28, 0, DateTimeZone.UTC)); 46 | Assert.assertEquals(ticket.getRequesterId(), 21480147); 47 | Assert.assertEquals(ticket.getType(), TicketType.INCIDENT); 48 | Assert.assertEquals(ticket.getUpdatedAt(), new DateTime(2010, 12, 1, 49 | 12, 0, 29, 0, DateTimeZone.UTC)); 50 | Assert.assertEquals(ticket.getVia(), TicketVia.DROPBOX); 51 | Assert.assertEquals(ticket.getCurrentTags().size(), 2); 52 | Assert.assertEquals(ticket.getCurrentTags().get(0), "betafeedback"); 53 | Assert.assertEquals(ticket.getCurrentTags().get(1), "question"); 54 | Assert.assertEquals(ticket.getScore(), 0); 55 | Assert.assertEquals(ticket.getComments().size(), 4); 56 | Assert.assertTrue(ticket.getComments().get(0).getValue() 57 | .contains("Popup:")); 58 | Assert.assertEquals( 59 | ticket.getComments().get(0).getAttachments().size(), 0); 60 | Assert.assertEquals(ticket.getComments().get(0).getAuthorId(), 21480147); 61 | Assert.assertEquals(ticket.getComments().get(0).getCreatedAt(), 62 | new DateTime(2010, 11, 24, 20, 01, 34, 0, DateTimeZone.UTC)); 63 | Assert.assertEquals(ticket.getComments().get(0).getVia(), 64 | TicketVia.DROPBOX); 65 | Assert.assertEquals( 66 | ticket.getComments().get(1).getAttachments().size(), 1); 67 | Assert.assertEquals(ticket.getComments().get(1).getAttachments().get(0) 68 | .getContentType(), "image/png"); 69 | Assert.assertEquals(ticket.getComments().get(1).getAttachments().get(0) 70 | .getFilename(), "image001.png"); 71 | Assert.assertEquals(ticket.getComments().get(1).getAttachments().get(0) 72 | .getToken(), "yxzdd3cdcehv6zs"); 73 | Assert.assertEquals(ticket.getComments().get(1).getAttachments().get(0) 74 | .getCreatedAt(), new DateTime(2010, 11, 24, 20, 14, 30, 0, 75 | DateTimeZone.UTC)); 76 | Assert.assertEquals(ticket.getComments().get(1).getAttachments().get(0) 77 | .getId(), 12628519); 78 | Assert.assertEquals(ticket.getComments().get(1).getAttachments().get(0) 79 | .getSize(), 36057); 80 | Assert.assertEquals( 81 | ticket.getComments().get(1).getAttachments().get(0).getUrl() 82 | .toString(), 83 | "https://hoist.zendesk.com/attachments/token/yxzdd3cdcehv6zs/?name=image001.png"); 84 | Assert.assertEquals(ticket.getEntries().size(), 1); 85 | Assert.assertEquals(ticket.getEntries().get(0).getFieldId(), 87154); 86 | Assert.assertEquals(ticket.getEntries().get(0).getValue(), "question"); 87 | } 88 | 89 | @Test 90 | public void getTickets() throws IOException { 91 | List tickets = getAPI().getTickets(47845, 1); 92 | 93 | Assert.assertEquals(tickets.size(), 30); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/user/User.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.user; 2 | 3 | import java.net.URL; 4 | import java.util.List; 5 | 6 | import org.codehaus.jackson.annotate.JsonProperty; 7 | import org.codehaus.jackson.map.annotate.JsonDeserialize; 8 | import org.joda.time.DateTime; 9 | 10 | import com.podio.integration.zendesk.group.Group; 11 | 12 | public class User { 13 | 14 | private int id; 15 | 16 | private String name; 17 | 18 | private String email; 19 | 20 | private Integer localeId; 21 | 22 | private String openIdURL; 23 | 24 | private String timeZone; 25 | 26 | private UserRole role; 27 | 28 | private URL photoURL; 29 | 30 | private Integer organizationId; 31 | 32 | private boolean uses12HourClock; 33 | 34 | private boolean active; 35 | 36 | private boolean verified; 37 | 38 | private String phone; 39 | 40 | private Integer restrictionId; 41 | 42 | private String externalId; 43 | 44 | private String notes; 45 | 46 | private String details; 47 | 48 | private DateTime createdAt; 49 | 50 | private DateTime updatedAt; 51 | 52 | private DateTime lastLogin; 53 | 54 | private List groups; 55 | 56 | public int getId() { 57 | return id; 58 | } 59 | 60 | public void setId(int id) { 61 | this.id = id; 62 | } 63 | 64 | public String getName() { 65 | return name; 66 | } 67 | 68 | public void setName(String name) { 69 | this.name = name; 70 | } 71 | 72 | public String getEmail() { 73 | return email; 74 | } 75 | 76 | public void setEmail(String email) { 77 | this.email = email; 78 | } 79 | 80 | public Integer getLocaleId() { 81 | return localeId; 82 | } 83 | 84 | @JsonProperty("locale_id") 85 | public void setLocaleId(Integer localeId) { 86 | this.localeId = localeId; 87 | } 88 | 89 | public String getOpenIdURL() { 90 | return openIdURL; 91 | } 92 | 93 | @JsonProperty("openid_url") 94 | public void setOpenIdURL(String openIdURL) { 95 | this.openIdURL = openIdURL; 96 | } 97 | 98 | public String getTimeZone() { 99 | return timeZone; 100 | } 101 | 102 | @JsonProperty("time_zone") 103 | public void setTimeZone(String timeZone) { 104 | this.timeZone = timeZone; 105 | } 106 | 107 | public UserRole getRole() { 108 | return role; 109 | } 110 | 111 | @JsonProperty("roles") 112 | @JsonDeserialize(using = UserRole.Deserializer.class) 113 | public void setRole(UserRole role) { 114 | this.role = role; 115 | } 116 | 117 | public URL getPhotoURL() { 118 | return photoURL; 119 | } 120 | 121 | @JsonProperty("photo_url") 122 | public void setPhotoURL(URL photoURL) { 123 | this.photoURL = photoURL; 124 | } 125 | 126 | public Integer getOrganizationId() { 127 | return organizationId; 128 | } 129 | 130 | @JsonProperty("organization_id") 131 | public void setOrganizationId(Integer organizationId) { 132 | this.organizationId = organizationId; 133 | } 134 | 135 | public boolean isUses12HourClock() { 136 | return uses12HourClock; 137 | } 138 | 139 | @JsonProperty("uses_12_hour_clock") 140 | public void setUses12HourClock(boolean uses12HourClock) { 141 | this.uses12HourClock = uses12HourClock; 142 | } 143 | 144 | public boolean isActive() { 145 | return active; 146 | } 147 | 148 | @JsonProperty("is_active") 149 | public void setActive(boolean active) { 150 | this.active = active; 151 | } 152 | 153 | public boolean isVerified() { 154 | return verified; 155 | } 156 | 157 | @JsonProperty("is_verified") 158 | public void setVerified(boolean verified) { 159 | this.verified = verified; 160 | } 161 | 162 | public String getPhone() { 163 | return phone; 164 | } 165 | 166 | public void setPhone(String phone) { 167 | this.phone = phone; 168 | } 169 | 170 | public Integer getRestrictionId() { 171 | return restrictionId; 172 | } 173 | 174 | @JsonProperty("restriction_id") 175 | public void setRestrictionId(Integer restrictionId) { 176 | this.restrictionId = restrictionId; 177 | } 178 | 179 | public String getExternalId() { 180 | return externalId; 181 | } 182 | 183 | @JsonProperty("external_id") 184 | public void setExternalId(String externalId) { 185 | this.externalId = externalId; 186 | } 187 | 188 | public String getNotes() { 189 | return notes; 190 | } 191 | 192 | public void setNotes(String notes) { 193 | this.notes = notes; 194 | } 195 | 196 | public String getDetails() { 197 | return details; 198 | } 199 | 200 | public void setDetails(String details) { 201 | this.details = details; 202 | } 203 | 204 | public DateTime getCreatedAt() { 205 | return createdAt; 206 | } 207 | 208 | @JsonProperty("created_at") 209 | public void setCreatedAt(DateTime createdAt) { 210 | this.createdAt = createdAt; 211 | } 212 | 213 | public DateTime getUpdatedAt() { 214 | return updatedAt; 215 | } 216 | 217 | @JsonProperty("updated_at") 218 | public void setUpdatedAt(DateTime updatedAt) { 219 | this.updatedAt = updatedAt; 220 | } 221 | 222 | public DateTime getLastLogin() { 223 | return lastLogin; 224 | } 225 | 226 | @JsonProperty("last_login") 227 | public void setLastLogin(DateTime lastLogin) { 228 | this.lastLogin = lastLogin; 229 | } 230 | 231 | public List getGroups() { 232 | return groups; 233 | } 234 | 235 | public void setGroups(List groups) { 236 | this.groups = groups; 237 | } 238 | } 239 | -------------------------------------------------------------------------------- /src/main/java/com/podio/integration/zendesk/ticket/Ticket.java: -------------------------------------------------------------------------------- 1 | package com.podio.integration.zendesk.ticket; 2 | 3 | import java.util.List; 4 | 5 | import org.codehaus.jackson.annotate.JsonProperty; 6 | import org.codehaus.jackson.map.annotate.JsonDeserialize; 7 | import org.joda.time.DateTime; 8 | 9 | import com.podio.integration.zendesk.serialize.TagListDeserializer; 10 | 11 | public class Ticket { 12 | 13 | /** 14 | * "original_recipient_address":null, "channel":null, "recipient":null, 15 | * "latest_recipients":null, "current_collaborators":null, 16 | */ 17 | 18 | private DateTime initiallyAssignedAt; 19 | 20 | private DateTime assignedAt; 21 | 22 | private Integer assigneeId; 23 | 24 | private Integer entryId; 25 | 26 | private DateTime createdAt; 27 | 28 | private String subject; 29 | 30 | private String description; 31 | 32 | private String externalId; 33 | 34 | private int groupId; 35 | 36 | private Integer organizationId; 37 | 38 | private int id; 39 | 40 | private List linkings; 41 | 42 | private TicketPriority priority; 43 | 44 | private int submitterId; 45 | 46 | private TicketStatus status; 47 | 48 | private DateTime statusUpdatedAt; 49 | 50 | private int requesterId; 51 | 52 | private TicketType type; 53 | 54 | private DateTime updatedAt; 55 | 56 | private TicketVia updatedViaType; 57 | 58 | private TicketVia via; 59 | 60 | private DateTime dueDate; 61 | 62 | private Integer resolutionTime; 63 | 64 | private DateTime solvedAt; 65 | 66 | private List currentTags; 67 | 68 | private int score; 69 | 70 | private int baseScore; 71 | 72 | private Integer problemId; 73 | 74 | private List comments; 75 | 76 | private List entries; 77 | 78 | public DateTime getInitiallyAssignedAt() { 79 | return initiallyAssignedAt; 80 | } 81 | 82 | @JsonProperty("initially_assigned_at") 83 | public void setInitiallyAssignedAt(DateTime initiallyAssignedAt) { 84 | this.initiallyAssignedAt = initiallyAssignedAt; 85 | } 86 | 87 | public Integer getEntryId() { 88 | return entryId; 89 | } 90 | 91 | @JsonProperty("entry_id") 92 | public void setEntryId(Integer entryId) { 93 | this.entryId = entryId; 94 | } 95 | 96 | public Integer getOrganizationId() { 97 | return organizationId; 98 | } 99 | 100 | @JsonProperty("organization_id") 101 | public void setOrganizationId(Integer organizationId) { 102 | this.organizationId = organizationId; 103 | } 104 | 105 | public TicketVia getUpdatedViaType() { 106 | return updatedViaType; 107 | } 108 | 109 | @JsonProperty("updated_by_type_id") 110 | public void setUpdatedViaType(TicketVia updatedViaType) { 111 | this.updatedViaType = updatedViaType; 112 | } 113 | 114 | public DateTime getDueDate() { 115 | return dueDate; 116 | } 117 | 118 | @JsonProperty("due_date") 119 | public void setDueDate(DateTime dueDate) { 120 | this.dueDate = dueDate; 121 | } 122 | 123 | public Integer getResolutionTime() { 124 | return resolutionTime; 125 | } 126 | 127 | @JsonProperty("resolution_time") 128 | public void setResolutionTime(Integer resolutionTime) { 129 | this.resolutionTime = resolutionTime; 130 | } 131 | 132 | public DateTime getSolvedAt() { 133 | return solvedAt; 134 | } 135 | 136 | @JsonProperty("solved_at") 137 | public void setSolvedAt(DateTime solvedAt) { 138 | this.solvedAt = solvedAt; 139 | } 140 | 141 | public Integer getProblemId() { 142 | return problemId; 143 | } 144 | 145 | @JsonProperty("problem_id") 146 | public void setProblemId(Integer problemId) { 147 | this.problemId = problemId; 148 | } 149 | 150 | public DateTime getAssignedAt() { 151 | return assignedAt; 152 | } 153 | 154 | @JsonProperty("assigned_at") 155 | public void setAssignedAt(DateTime assignedAt) { 156 | this.assignedAt = assignedAt; 157 | } 158 | 159 | public Integer getAssigneeId() { 160 | return assigneeId; 161 | } 162 | 163 | @JsonProperty("assignee_id") 164 | public void setAssigneeId(Integer assigneeId) { 165 | this.assigneeId = assigneeId; 166 | } 167 | 168 | public DateTime getCreatedAt() { 169 | return createdAt; 170 | } 171 | 172 | @JsonProperty("created_at") 173 | public void setCreatedAt(DateTime createdAt) { 174 | this.createdAt = createdAt; 175 | } 176 | 177 | public String getSubject() { 178 | return subject; 179 | } 180 | 181 | public void setSubject(String subject) { 182 | this.subject = subject; 183 | } 184 | 185 | public String getDescription() { 186 | return description; 187 | } 188 | 189 | public void setDescription(String description) { 190 | this.description = description; 191 | } 192 | 193 | public String getExternalId() { 194 | return externalId; 195 | } 196 | 197 | @JsonProperty("external_id") 198 | public void setExternalId(String externalId) { 199 | this.externalId = externalId; 200 | } 201 | 202 | public int getGroupId() { 203 | return groupId; 204 | } 205 | 206 | @JsonProperty("group_id") 207 | public void setGroupId(int groupId) { 208 | this.groupId = groupId; 209 | } 210 | 211 | public int getId() { 212 | return id; 213 | } 214 | 215 | @JsonProperty("nice_id") 216 | public void setId(int id) { 217 | this.id = id; 218 | } 219 | 220 | public List getLinkings() { 221 | return linkings; 222 | } 223 | 224 | @JsonProperty("linkings") 225 | public void setLinkings(List linkings) { 226 | this.linkings = linkings; 227 | } 228 | 229 | public TicketPriority getPriority() { 230 | return priority; 231 | } 232 | 233 | @JsonProperty("priority_id") 234 | @JsonDeserialize(using = TicketPriority.Deserializer.class) 235 | public void setPriority(TicketPriority priority) { 236 | this.priority = priority; 237 | } 238 | 239 | public int getSubmitterId() { 240 | return submitterId; 241 | } 242 | 243 | @JsonProperty("submitter_id") 244 | public void setSubmitterId(int submitterId) { 245 | this.submitterId = submitterId; 246 | } 247 | 248 | public TicketStatus getStatus() { 249 | return status; 250 | } 251 | 252 | @JsonProperty("status_id") 253 | public void setStatus(TicketStatus status) { 254 | this.status = status; 255 | } 256 | 257 | public DateTime getStatusUpdatedAt() { 258 | return statusUpdatedAt; 259 | } 260 | 261 | @JsonProperty("status_updated_at") 262 | public void setStatusUpdatedAt(DateTime statusUpdatedAt) { 263 | this.statusUpdatedAt = statusUpdatedAt; 264 | } 265 | 266 | public int getRequesterId() { 267 | return requesterId; 268 | } 269 | 270 | @JsonProperty("requester_id") 271 | public void setRequesterId(int requesterId) { 272 | this.requesterId = requesterId; 273 | } 274 | 275 | public TicketType getType() { 276 | return type; 277 | } 278 | 279 | @JsonProperty("ticket_type_id") 280 | @JsonDeserialize(using = TicketType.Deserializer.class) 281 | public void setType(TicketType type) { 282 | this.type = type; 283 | } 284 | 285 | public DateTime getUpdatedAt() { 286 | return updatedAt; 287 | } 288 | 289 | @JsonProperty("updated_at") 290 | public void setUpdatedAt(DateTime updatedAt) { 291 | this.updatedAt = updatedAt; 292 | } 293 | 294 | public TicketVia getVia() { 295 | return via; 296 | } 297 | 298 | @JsonProperty("via_id") 299 | @JsonDeserialize(using = TicketVia.Deserializer.class) 300 | public void setVia(TicketVia via) { 301 | this.via = via; 302 | } 303 | 304 | public List getCurrentTags() { 305 | return currentTags; 306 | } 307 | 308 | @JsonProperty("current_tags") 309 | @JsonDeserialize(using = TagListDeserializer.class) 310 | public void setCurrentTags(List currentTags) { 311 | this.currentTags = currentTags; 312 | } 313 | 314 | public int getScore() { 315 | return score; 316 | } 317 | 318 | public void setScore(int score) { 319 | this.score = score; 320 | } 321 | 322 | public int getBaseScore() { 323 | return baseScore; 324 | } 325 | 326 | @JsonProperty("base_score") 327 | public void setBaseScore(int baseScore) { 328 | this.baseScore = baseScore; 329 | } 330 | 331 | public List getComments() { 332 | return comments; 333 | } 334 | 335 | public void setComments(List comments) { 336 | this.comments = comments; 337 | } 338 | 339 | public List getEntries() { 340 | return entries; 341 | } 342 | 343 | @JsonProperty("ticket_field_entries") 344 | public void setEntries(List entries) { 345 | this.entries = entries; 346 | } 347 | } 348 | --------------------------------------------------------------------------------