Skip to content

Commit 12f251e

Browse files
authored
Merge pull request #68 from intercom/Ruairik/add_attachment_support
Add attachment support
2 parents 34ddfcc + 7c23516 commit 12f251e

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ ConversationCollection openForAdmin = Conversation.list(params);
447447
Admin admin = new Admin().setId("1");
448448
AdminReply adminReply = new AdminReply(admin);
449449
adminReply.setBody("These apples are healthsome");
450+
adminReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments
450451
Conversation.reply("66", adminReply);
451452

452453
// admin close
@@ -459,6 +460,7 @@ Conversation.reply("66", adminReply);
459460
User user1 = new User().setId("5310d8e8598c9a0b24000005");
460461
UserReply userReply = new UserReply(user1);
461462
userReply.setBody("Mighty fine shindig");
463+
userReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments
462464
System.out.println(MapperSupport.objectMapper().writeValueAsString(userReply));
463465
Conversation.reply("66", userReply);
464466
```

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public String getAdminID() {
4646
public String getAssigneeID() {
4747
return reply.getAssigneeID();
4848
}
49+
50+
@JsonProperty("attachment_urls")
51+
private String[] getAttachmentUrls() {
52+
return reply.getAttachmentUrls();
53+
}
4954
}
5055

5156
@JsonProperty("assignee_id")

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class Reply<T extends Replier> extends TypedData {
99

1010
@JsonProperty("body")
1111
private String body;
12+
13+
@JsonProperty("attachment_urls")
14+
private String[] attachmentUrls;
1215

1316
@JsonProperty("from")
1417
T from;
@@ -30,6 +33,15 @@ public Reply<T> setBody(String body) {
3033
return this;
3134
}
3235

36+
public String[] getAttachmentUrls() {
37+
return attachmentUrls;
38+
}
39+
40+
public Reply<T> setAttachmentUrls(String[] attachmentUrls) {
41+
this.attachmentUrls = attachmentUrls;
42+
return this;
43+
}
44+
3345
T getFrom() {
3446
return from;
3547
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public String getUserID() {
5151
public String getEmail() {
5252
return reply.getFrom().getEmail();
5353
}
54+
55+
@JsonProperty("attachment_urls")
56+
private String[] getAttachmentUrls() {
57+
return reply.getAttachmentUrls();
58+
}
5459
}
5560

5661
public UserReply(User user) {

intercom-java/src/test/java/io/intercom/api/ConversationTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ public void testAdminReply() {
5858
} catch (InvalidException e) {
5959
fail();
6060
}
61+
62+
adminReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"});
63+
try {
64+
Conversation.validateAdminReplyRequest(adminReply);
65+
} catch (InvalidException e) {
66+
fail();
67+
}
6168
}
6269

6370
@Test

0 commit comments

Comments
 (0)