Skip to content

Add support for replying to last conversation #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,23 @@ 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);

// reply to last users' conversation as an admin
ReplyToLastReply replyToLastReplay = new ReplyToLastReply();
replyToLastReplay.setIntercomUserID("5310d8e8598c9a0b24000005");
replyToLastReplay.setAdminId("1");
replyToLastReplay.setBody("These apples are healthsome");
replyToLastReplay.setMessageType("comment");
replyToLastReplay.setType("admin");
Conversation.replyToLastConversation(replyToLastReplay);

// reply to last users' conversation as a user
ReplyToLastReply replyToLastReplay = new ReplyToLastReply();
replyToLastReplay.setIntercomUserID("5310d8e8598c9a0b24000005");
replyToLastReplay.setBody("Mighty fine shindig");
replyToLastReplay.setMessageType("comment");
replyToLastReplay.setType("user");
Conversation.replyToLastConversation(replyToLastReplay);
```

### Webhooks
Expand Down
10 changes: 10 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 @@ -71,6 +71,16 @@ public static Conversation reply(String id, AdminReply reply) {
.post(Conversation.class, new AdminReply.AdminStringReply(reply));
}

public static Conversation replyToLastConversation(ReplyToLastReply reply) {
final URI uri = UriBuilder.newBuilder()
.path("conversations")
.path("last")
.path("reply")
.build();
return new HttpClient(uri)
.post(Conversation.class, reply);
}

public static UserMessage create(UserMessage message) {
return DataResource.create(message, "messages", UserMessage.class);
}
Expand Down
120 changes: 120 additions & 0 deletions intercom-java/src/main/java/io/intercom/api/ReplyToLastReply.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package io.intercom.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ReplyToLastReply {

@JsonProperty("message_type")
private String messageType;

@JsonProperty("body")
private String body;

@JsonProperty("attachment_urls")
private String[] attachmentUrls;

@JsonProperty("type")
private String type;

@JsonProperty("admin_id")
private String adminId;

@JsonProperty("intercom_user_id")
public String intercomUserId;

@JsonProperty("user_id")
public String userId;

@JsonProperty("email")
public String email;


public String getMessageType() {
return this.messageType;
}
public ReplyToLastReply setMessageType(String messageType) {
this.messageType = messageType;
return this;
}

public String getBody() {
return this.body ;
}
public ReplyToLastReply setBody(String body) {
this.body = body;
return this;
}

public String getType() {
return this.type;
}

public ReplyToLastReply setType(String type) {
this.type = type;
return this;
}

public String getAdminId() {
return this.adminId;
}

public ReplyToLastReply setAdminId(String adminId) {
this.adminId = adminId;
return this;
}

public String getIntercomUserID(){
return this.intercomUserId;
}

public ReplyToLastReply setIntercomUserID(String intercomUserId){
this.intercomUserId = intercomUserId;
return this;
}

public String getUserID() {
return this.userId;
}

public ReplyToLastReply setUserID(String userId) {
this.userId = userId;
return this;
}
public String getEmail(){
return this.email;
}

public ReplyToLastReply setEmail(String email){
this.email = email;
return this;
}

public String[] getAttachmentUrls() {
return this.attachmentUrls;
}

public ReplyToLastReply setAttachmentUrls(String[] attachmentUrls) {
this.attachmentUrls = attachmentUrls;
return this;
}

@Override
public String toString() {
return "ReplyToLast{ " +
" messageType='" + messageType + '\'' +
", body='" + body + '\'' +
", attachmentUrls='" + (attachmentUrls == null ? attachmentUrls : attachmentUrls.toString()) + '\'' +
", type='" + type + '\'' +
", adminId='" + adminId + '\'' +
", intercomUserId='" + intercomUserId + '\'' +
", userId='" + userId + '\'' +
", email='" + email + '\'' +
"} " + super.toString();

}
}