Skip to content

Commit 7085e8f

Browse files
thewheatchoran
authored andcommitted
Add support for marking conversation as read (#234)
1 parent 948c077 commit 7085e8f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,9 @@ userReply.setBody("Mighty fine shindig");
584584
userReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments
585585
System.out.println(MapperSupport.objectMapper().writeValueAsString(userReply));
586586
Conversation.reply("66", userReply);
587+
588+
// mark conversation as read
589+
Conversation.markAsRead("66");
587590
```
588591

589592
### Webhooks

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
@JsonIgnoreProperties(ignoreUnknown = true)
1818
public class Conversation extends TypedData {
1919

20+
@SuppressWarnings("UnusedDeclaration")
21+
@JsonIgnoreProperties(ignoreUnknown = true)
22+
private static class ConversationRead extends TypedData {
23+
24+
@JsonProperty("read")
25+
private boolean read;
26+
27+
public ConversationRead() {
28+
this.read = true;
29+
}
30+
}
31+
2032
private static final HashMap<String, String> SENTINEL = Maps.newHashMap();
2133
private static final List<String> DISPLAY_AS_FORMATS = Lists.newArrayList("plaintext", "html");
2234
static final String MESSAGE_TYPE_ASSIGNMENT = "assignment";
@@ -73,6 +85,16 @@ public static Conversation reply(String id, AdminReply reply) {
7385
.post(Conversation.class, new AdminReply.AdminStringReply(reply));
7486
}
7587

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

0 commit comments

Comments
 (0)