Skip to content

Commit aec966a

Browse files
author
Timothy Lim
committed
Add support for marking conversation as read
1 parent 0ec97e7 commit aec966a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ userReply.setBody("Mighty fine shindig");
572572
userReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments
573573
System.out.println(MapperSupport.objectMapper().writeValueAsString(userReply));
574574
Conversation.reply("66", userReply);
575+
576+
// mark conversation as read
577+
Conversation.markAsRead("66");
575578
```
576579

577580
### Webhooks

intercom-java/src/main/java/io/intercom/api/Conversation.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
56
import com.fasterxml.jackson.annotation.JsonProperty;
67
import com.google.common.base.Joiner;
78
import com.google.common.base.Optional;
@@ -17,6 +18,18 @@
1718
@JsonIgnoreProperties(ignoreUnknown = true)
1819
public class Conversation extends TypedData {
1920

21+
@SuppressWarnings("UnusedDeclaration")
22+
@JsonIgnoreProperties(ignoreUnknown = true)
23+
private static class ConversationRead extends TypedData {
24+
25+
@JsonProperty("read")
26+
private boolean read;
27+
28+
public ConversationRead() {
29+
this.read = true;
30+
}
31+
}
32+
2033
private static final HashMap<String, String> SENTINEL = Maps.newHashMap();
2134
private static final List<String> DISPLAY_AS_FORMATS = Lists.newArrayList("plaintext", "html");
2235
static final String MESSAGE_TYPE_ASSIGNMENT = "assignment";
@@ -71,6 +84,16 @@ public static Conversation reply(String id, AdminReply reply) {
7184
.post(Conversation.class, new AdminReply.AdminStringReply(reply));
7285
}
7386

87+
public static Conversation markAsRead(String id) {
88+
final URI uri = UriBuilder.newBuilder()
89+
.path("conversations")
90+
.path(id)
91+
.build();
92+
93+
return new HttpClient(uri)
94+
.put(Conversation.class, new ConversationRead());
95+
}
96+
7497
public static UserMessage create(UserMessage message) {
7598
return DataResource.create(message, "messages", UserMessage.class);
7699
}

0 commit comments

Comments
 (0)