From a9f6746b68bacea217ec92947d9dc5525a2d6a49 Mon Sep 17 00:00:00 2001 From: Caio Novaes Date: Fri, 24 Aug 2018 16:16:40 -0300 Subject: [PATCH 1/3] Implemented method that gets user related information --- README.md | 1 + .../java/org/zendesk/client/v2/Zendesk.java | 6 + .../client/v2/model/UserRelatedInfo.java | 110 ++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java diff --git a/README.md b/README.md index beb41e43..90e71dff 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Here is the status of the various API components: * [Views](http://developer.zendesk.com/documentation/rest_api/views.html) * [Users](http://developer.zendesk.com/documentation/rest_api/users.html) ✓ * [User Fields](https://developer.zendesk.com/rest_api/docs/core/user_fields.html) - Partial - List User Fields (`getUserField()`) +* [User Related Information](https://developer.zendesk.com/rest_api/docs/core/users#user-related-information) ✓ * [Requests](http://developer.zendesk.com/documentation/rest_api/requests.html) ✓ * [User Identities](http://developer.zendesk.com/documentation/rest_api/user_identities.html) ✓ * [Groups](http://developer.zendesk.com/documentation/rest_api/groups.html) ✓ diff --git a/src/main/java/org/zendesk/client/v2/Zendesk.java b/src/main/java/org/zendesk/client/v2/Zendesk.java index 3ad4f48d..dd909a82 100644 --- a/src/main/java/org/zendesk/client/v2/Zendesk.java +++ b/src/main/java/org/zendesk/client/v2/Zendesk.java @@ -51,6 +51,7 @@ import org.zendesk.client.v2.model.TwitterMonitor; import org.zendesk.client.v2.model.User; import org.zendesk.client.v2.model.UserField; +import org.zendesk.client.v2.model.UserRelatedInfo; import org.zendesk.client.v2.model.hc.Article; import org.zendesk.client.v2.model.hc.ArticleAttachments; import org.zendesk.client.v2.model.hc.Category; @@ -417,6 +418,11 @@ public Iterable getUserCCDTickets(long userId) { handleList(Ticket.class, "tickets")); } + public UserRelatedInfo getUserRelatedInfo(long userId) { + return complete(submit(req("GET", tmpl("/users/{userId}/related.json").set("userId", userId)), + handle(UserRelatedInfo.class, "user_related"))); + } + public Iterable getTicketMetrics() { return new PagedIterable<>(cnst("/ticket_metrics.json"), handleList(Metric.class, "ticket_metrics")); } diff --git a/src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java b/src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java new file mode 100644 index 00000000..af3aa2a4 --- /dev/null +++ b/src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java @@ -0,0 +1,110 @@ +package org.zendesk.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * @author caionovaes + * @since 08/24/2018 + */ +public class UserRelatedInfo implements Serializable { + + @JsonProperty(value = "assigned_tickets") + private Integer assignedTickets; + @JsonProperty(value = "requested_tickets") + private Integer requestedTickets; + private Integer topics; + @JsonProperty(value = "topic_comments") + private Integer topicComments; + private Integer votes; + private Integer subscriptions; + @JsonProperty(value = "entry_subscriptions") + private Integer entrySubscriptions; + @JsonProperty(value = "forum_subscriptions") + private Integer forumSubscriptions; + @JsonProperty(value = "organization_subscriptions") + private Integer organizationSubscriptions; + @JsonProperty(value = "ccd_tickets") + private Integer ccdTickets; + + public Integer getAssignedTickets() { + return assignedTickets; + } + + public void setAssignedTickets(Integer assignedTickets) { + this.assignedTickets = assignedTickets; + } + + public Integer getRequestedTickets() { + return requestedTickets; + } + + public void setRequestedTickets(Integer requestedTickets) { + this.requestedTickets = requestedTickets; + } + + public Integer getTopics() { + return topics; + } + + public void setTopics(Integer topics) { + this.topics = topics; + } + + public Integer getTopicComments() { + return topicComments; + } + + public void setTopicComments(Integer topicComments) { + this.topicComments = topicComments; + } + + public Integer getVotes() { + return votes; + } + + public void setVotes(Integer votes) { + this.votes = votes; + } + + public Integer getSubscriptions() { + return subscriptions; + } + + public void setSubscriptions(Integer subscriptions) { + this.subscriptions = subscriptions; + } + + public Integer getEntrySubscriptions() { + return entrySubscriptions; + } + + public void setEntrySubscriptions(Integer entrySubscriptions) { + this.entrySubscriptions = entrySubscriptions; + } + + public Integer getForumSubscriptions() { + return forumSubscriptions; + } + + public void setForumSubscriptions(Integer forumSubscriptions) { + this.forumSubscriptions = forumSubscriptions; + } + + public Integer getOrganizationSubscriptions() { + return organizationSubscriptions; + } + + public void setOrganizationSubscriptions(Integer organizationSubscriptions) { + this.organizationSubscriptions = organizationSubscriptions; + } + + public Integer getCcdTickets() { + return ccdTickets; + } + + public void setCcdTickets(Integer ccdTickets) { + this.ccdTickets = ccdTickets; + } +} From 5b6d4e8e92159da0f597d690af9881c37400faf3 Mon Sep 17 00:00:00 2001 From: Caio Novaes Date: Fri, 24 Aug 2018 16:27:43 -0300 Subject: [PATCH 2/3] Adding serialVersionUID and overriding toString to UserRelatedInfo --- .../client/v2/model/UserRelatedInfo.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java b/src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java index af3aa2a4..8fe304b6 100644 --- a/src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java +++ b/src/main/java/org/zendesk/client/v2/model/UserRelatedInfo.java @@ -10,6 +10,8 @@ */ public class UserRelatedInfo implements Serializable { + private static final long serialVersionUID = 1L; + @JsonProperty(value = "assigned_tickets") private Integer assignedTickets; @JsonProperty(value = "requested_tickets") @@ -107,4 +109,20 @@ public Integer getCcdTickets() { public void setCcdTickets(Integer ccdTickets) { this.ccdTickets = ccdTickets; } + + @Override + public String toString() { + return "UserRelatedInfo{" + + "assignedTickets=" + assignedTickets + + ", requestedTickets=" + requestedTickets + + ", topics=" + topics + + ", topicComments=" + topicComments + + ", votes=" + votes + + ", subscriptions=" + subscriptions + + ", entrySubscriptions=" + entrySubscriptions + + ", forumSubscriptions=" + forumSubscriptions + + ", organizationSubscriptions=" + organizationSubscriptions + + ", ccdTickets=" + ccdTickets + + '}'; + } } From e018c4ff16ffa542faea5218a30e2d200c8645dd Mon Sep 17 00:00:00 2001 From: Caio Novaes Date: Mon, 27 Aug 2018 10:43:29 -0300 Subject: [PATCH 3/3] Setting User Related Information as sub-item of Users on README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90e71dff..d791a5ed 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ Here is the status of the various API components: * [Ticket Forms](http://developer.zendesk.com/documentation/rest_api/ticket_forms.html) *getTicketForm() and getTicketForms()* * [Views](http://developer.zendesk.com/documentation/rest_api/views.html) * [Users](http://developer.zendesk.com/documentation/rest_api/users.html) ✓ + * [User Related Information](https://developer.zendesk.com/rest_api/docs/core/users#user-related-information) ✓ * [User Fields](https://developer.zendesk.com/rest_api/docs/core/user_fields.html) - Partial - List User Fields (`getUserField()`) -* [User Related Information](https://developer.zendesk.com/rest_api/docs/core/users#user-related-information) ✓ * [Requests](http://developer.zendesk.com/documentation/rest_api/requests.html) ✓ * [User Identities](http://developer.zendesk.com/documentation/rest_api/user_identities.html) ✓ * [Groups](http://developer.zendesk.com/documentation/rest_api/groups.html) ✓