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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,9 @@ userReply.setBody("Mighty fine shindig");
userReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments
System.out.println(MapperSupport.objectMapper().writeValueAsString(userReply));
Conversation.reply("66", userReply);

// mark conversation as read
Conversation.markAsRead("66");
```

### Webhooks
Expand Down
22 changes: 22 additions & 0 deletions intercom-java/src/main/java/io/intercom/api/Conversation.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class Conversation extends TypedData {

@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
private static class ConversationRead extends TypedData {

@JsonProperty("read")
private boolean read;

public ConversationRead() {
this.read = true;
}
}

private static final HashMap<String, String> SENTINEL = Maps.newHashMap();
private static final List<String> DISPLAY_AS_FORMATS = Lists.newArrayList("plaintext", "html");
static final String MESSAGE_TYPE_ASSIGNMENT = "assignment";
Expand Down Expand Up @@ -73,6 +85,16 @@ public static Conversation reply(String id, AdminReply reply) {
.post(Conversation.class, new AdminReply.AdminStringReply(reply));
}

public static Conversation markAsRead(String id) {
final URI uri = UriBuilder.newBuilder()
.path("conversations")
.path(id)
.build();

return new HttpClient(uri)
.put(Conversation.class, new ConversationRead());
}

public static UserMessage create(UserMessage message) {
return DataResource.create(message, "messages", UserMessage.class);
}
Expand Down