Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/org/zendesk/client/v2/model/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class Comment implements Serializable {
private List<Attachment> attachments;
private Date createdAt;
private Boolean publicComment;
private CommentType type;


public Comment() {
}
Expand Down Expand Up @@ -104,6 +106,15 @@ public void setPublic(Boolean isPublic) {
this.publicComment = isPublic;
}

@JsonProperty("type")
public CommentType getType() {
return type;
}

public void setType(CommentType type) {
this.type = type;
}

@Override
public String toString() {
return "Comment{" + "id=" + id +
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/zendesk/client/v2/model/CommentType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.zendesk.client.v2.model;

/**
* https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/
*/
public enum CommentType {

COMMENT("Comment"),
VOICE_COMMENT("VoiceComment");

private final String name;

CommentType(String name) {
this.name = name;
}

@Override
public String toString() {
return name;
}
}
13 changes: 11 additions & 2 deletions src/test/java/org/zendesk/client/v2/RealSmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.zendesk.client.v2.model.Brand;
import org.zendesk.client.v2.model.Collaborator;
import org.zendesk.client.v2.model.Comment;
import org.zendesk.client.v2.model.CommentType;
import org.zendesk.client.v2.model.ComplianceDeletionStatus;
import org.zendesk.client.v2.model.DeletedTicket;
import org.zendesk.client.v2.model.Field;
Expand Down Expand Up @@ -1646,14 +1647,18 @@ public void getTicketCommentsShouldBeAscending() throws Exception {
Ticket ticket = null;
try {
ticket = instance.createTicket(t);
instance.createComment(ticket.getId(), new Comment(TICKET_COMMENT2));
final Comment comment = new Comment(TICKET_COMMENT2);
comment.setType(CommentType.COMMENT);
instance.createComment(ticket.getId(), comment);
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId());
List<Comment> comments = new ArrayList<>();
ticketCommentsIt.forEach(comments::add);

assertThat(comments.size(), is(2));
assertThat(comments.get(0).getBody(), containsString(TICKET_COMMENT1));
assertThat(comments.get(0).getType(), is(CommentType.COMMENT));
assertThat(comments.get(1).getBody(), containsString(TICKET_COMMENT2));
assertThat(comments.get(1).getType(), is(CommentType.COMMENT));
} finally {
if (ticket != null) {
instance.deleteTicket(ticket.getId());
Expand All @@ -1669,14 +1674,18 @@ public void getTicketCommentsDescending() throws Exception {
Ticket ticket = null;
try {
ticket = instance.createTicket(t);
instance.createComment(ticket.getId(), new Comment(TICKET_COMMENT2));
final Comment comment = new Comment(TICKET_COMMENT2);
comment.setType(CommentType.COMMENT);
instance.createComment(ticket.getId(), comment);
Iterable<Comment> ticketCommentsIt = instance.getTicketComments(ticket.getId(), SortOrder.DESCENDING);
List<Comment> comments = new ArrayList<>();
ticketCommentsIt.forEach(comments::add);

assertThat(comments.size(), is(2));
assertThat(comments.get(0).getBody(), containsString(TICKET_COMMENT2));
assertThat(comments.get(0).getType(), is(CommentType.COMMENT));
assertThat(comments.get(1).getBody(), containsString(TICKET_COMMENT1));
assertThat(comments.get(1).getType(), is(CommentType.COMMENT));
} finally {
if (ticket != null) {
instance.deleteTicket(ticket.getId());
Expand Down