Skip to content

Commit ae0d968

Browse files
authored
Merge pull request #415 from besbes/feature/add-comment-type
Add type attribute to Comment model
2 parents d80090b + 7b190bb commit ae0d968

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/main/java/org/zendesk/client/v2/model/Comment.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class Comment implements Serializable {
2323
private List<Attachment> attachments;
2424
private Date createdAt;
2525
private Boolean publicComment;
26+
private CommentType type;
27+
2628

2729
public Comment() {
2830
}
@@ -104,6 +106,15 @@ public void setPublic(Boolean isPublic) {
104106
this.publicComment = isPublic;
105107
}
106108

109+
@JsonProperty("type")
110+
public CommentType getType() {
111+
return type;
112+
}
113+
114+
public void setType(CommentType type) {
115+
this.type = type;
116+
}
117+
107118
@Override
108119
public String toString() {
109120
return "Comment{" + "id=" + id +
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.zendesk.client.v2.model;
2+
3+
/**
4+
* https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/
5+
*/
6+
public enum CommentType {
7+
8+
COMMENT("Comment"),
9+
VOICE_COMMENT("VoiceComment");
10+
11+
private final String name;
12+
13+
CommentType(String name) {
14+
this.name = name;
15+
}
16+
17+
@Override
18+
public String toString() {
19+
return name;
20+
}
21+
}

src/test/java/org/zendesk/client/v2/RealSmokeTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.zendesk.client.v2.model.Brand;
1818
import org.zendesk.client.v2.model.Collaborator;
1919
import org.zendesk.client.v2.model.Comment;
20+
import org.zendesk.client.v2.model.CommentType;
2021
import org.zendesk.client.v2.model.ComplianceDeletionStatus;
2122
import org.zendesk.client.v2.model.DeletedTicket;
2223
import org.zendesk.client.v2.model.Field;
@@ -1646,14 +1647,18 @@ public void getTicketCommentsShouldBeAscending() throws Exception {
16461647
Ticket ticket = null;
16471648
try {
16481649
ticket = instance.createTicket(t);
1649-
instance.createComment(ticket.getId(), new Comment(TICKET_COMMENT2));
1650+
final Comment comment = new Comment(TICKET_COMMENT2);
1651+
comment.setType(CommentType.COMMENT);
1652+
instance.createComment(ticket.getId(), comment);
16501653
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId());
16511654
List<Comment> comments = new ArrayList<>();
16521655
ticketCommentsIt.forEach(comments::add);
16531656

16541657
assertThat(comments.size(), is(2));
16551658
assertThat(comments.get(0).getBody(), containsString(TICKET_COMMENT1));
1659+
assertThat(comments.get(0).getType(), is(CommentType.COMMENT));
16561660
assertThat(comments.get(1).getBody(), containsString(TICKET_COMMENT2));
1661+
assertThat(comments.get(1).getType(), is(CommentType.COMMENT));
16571662
} finally {
16581663
if (ticket != null) {
16591664
instance.deleteTicket(ticket.getId());
@@ -1669,14 +1674,18 @@ public void getTicketCommentsDescending() throws Exception {
16691674
Ticket ticket = null;
16701675
try {
16711676
ticket = instance.createTicket(t);
1672-
instance.createComment(ticket.getId(), new Comment(TICKET_COMMENT2));
1677+
final Comment comment = new Comment(TICKET_COMMENT2);
1678+
comment.setType(CommentType.COMMENT);
1679+
instance.createComment(ticket.getId(), comment);
16731680
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId(), SortOrder.DESCENDING);
16741681
List<Comment> comments = new ArrayList<>();
16751682
ticketCommentsIt.forEach(comments::add);
16761683

16771684
assertThat(comments.size(), is(2));
16781685
assertThat(comments.get(0).getBody(), containsString(TICKET_COMMENT2));
1686+
assertThat(comments.get(0).getType(), is(CommentType.COMMENT));
16791687
assertThat(comments.get(1).getBody(), containsString(TICKET_COMMENT1));
1688+
assertThat(comments.get(1).getType(), is(CommentType.COMMENT));
16801689
} finally {
16811690
if (ticket != null) {
16821691
instance.deleteTicket(ticket.getId());

0 commit comments

Comments
 (0)