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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,18 @@ AdminReply adminReply = new AdminReply(admin);
adminReply.setMessageType("close");
Conversation.reply("66", adminReply);

// admin snooze
Admin admin = new Admin().setId("1");
AdminReply adminReply = new AdminReply(admin);
adminReply.setSnoozedUntil(1549092382);
Conversation.reply("66", adminReply);

// admin open / unsnooze
Admin admin = new Admin().setId("1");
AdminReply adminReply = new AdminReply(admin);
adminReply.setMessageType("open");
Conversation.reply("66", adminReply);

// user reply
User user1 = new User().setId("5310d8e8598c9a0b24000005");
UserReply userReply = new UserReply(user1);
Expand Down
18 changes: 18 additions & 0 deletions intercom-java/src/main/java/io/intercom/api/AdminReply.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public String getMessageType() {
return reply.getMessageType();
}

@JsonProperty("snoozed_until")
public long getSnoozedUntil() {
return reply.getSnoozedUntil();
}

@JsonProperty("body")
public String getBody() {
return reply.getBody();
Expand All @@ -56,6 +61,9 @@ private String[] getAttachmentUrls() {
@JsonProperty("assignee_id")
private String assigneeID;

@JsonProperty("snoozed_until")
private long snoozedUntil;

public AdminReply(Admin admin) {
this.from = admin;
}
Expand All @@ -74,6 +82,16 @@ public Reply<Admin> setAssigneeID(String assigneeID) {
return this;
}

public long getSnoozedUntil() {
return snoozedUntil;
}

public Reply<Admin> setSnoozedUntil(long snoozedUntil) {
this.snoozedUntil = snoozedUntil;
this.setMessageType(Conversation.MESSAGE_TYPE_SNOOZED);
return this;
}

@Override
public String toString() {
return "AdminReply{} " + super.toString();
Expand Down
24 changes: 23 additions & 1 deletion intercom-java/src/main/java/io/intercom/api/Conversation.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ public class Conversation extends TypedData {
static final String MESSAGE_TYPE_NOTE = "note";
static final String MESSAGE_TYPE_CLOSE = "close";
static final String MESSAGE_TYPE_OPEN = "open";
static final String MESSAGE_TYPE_SNOOZED = "snoozed";
static final List<String> MESSAGE_TYPES = Lists.newArrayList(
MESSAGE_TYPE_ASSIGNMENT,
MESSAGE_TYPE_COMMENT,
MESSAGE_TYPE_NOTE,
MESSAGE_TYPE_CLOSE,
MESSAGE_TYPE_OPEN
MESSAGE_TYPE_OPEN,
MESSAGE_TYPE_SNOOZED
);

public static Conversation find(String id) throws InvalidException, AuthorizationException {
Expand Down Expand Up @@ -196,6 +198,9 @@ private static boolean isAdminQuery(Map<String, String> params) {
@JsonProperty("waiting_since")
private long waitingSince;

@JsonProperty("snoozed_until")
private long snoozedUntil;

@JsonProperty("conversation_parts")
private ConversationPartCollection conversationPartCollection;

Expand All @@ -208,6 +213,9 @@ private static boolean isAdminQuery(Map<String, String> params) {
@JsonProperty("read")
private boolean read;

@JsonProperty("state")
private String state;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's that property used for in the context of snoozing? There's no setter, is that expected?

Copy link
Contributor

@mmartinic mmartinic Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This maps to conversation state (open, closed, snoozed). We also have open )
which is boolean but that no longer fits with snoozed state.

https://developers.intercom.com/intercom-api-reference/reference#conversation-model

Copy link

@apassant apassant Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense 👍 LGTM then


@JsonProperty("links")
private Map<String, URI> links;

Expand Down Expand Up @@ -271,6 +279,10 @@ public long getWaitingSince() {
return waitingSince;
}

public long getSnoozedUntil() {
return snoozedUntil;
}

public ConversationPartCollection getConversationPartCollection() {
if (conversationPartCollection == null) {
conversationPartCollection = find(this.getId()).getConversationPartCollection();
Expand All @@ -295,6 +307,10 @@ public boolean getRead() {
return read;
}

public String getState() {
return state;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -307,6 +323,7 @@ public boolean equals(Object o) {
if (read != that.read) return false;
if (updatedAt != that.updatedAt) return false;
if (waitingSince != that.waitingSince) return false;
if (snoozedUntil != that.snoozedUntil) return false;
if (assignee != null ? !assignee.equals(that.assignee) : that.assignee != null) return false;
if (conversationMessage != null ? !conversationMessage.equals(that.conversationMessage) : that.conversationMessage != null)
return false;
Expand All @@ -316,6 +333,7 @@ public boolean equals(Object o) {
return false;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (links != null ? !links.equals(that.links) : that.links != null) return false;
if (!state.equals(that.state)) return false;
if (!type.equals(that.type)) return false;
//noinspection RedundantIfStatement
if (user != null ? !user.equals(that.user) : that.user != null) return false;
Expand All @@ -327,12 +345,14 @@ public boolean equals(Object o) {
public int hashCode() {
int result = type.hashCode();
result = 31 * result + (id != null ? id.hashCode() : 0);
result = 31 * result + (state != null ? state.hashCode() : 0);
result = 31 * result + (conversationMessage != null ? conversationMessage.hashCode() : 0);
result = 31 * result + (user != null ? user.hashCode() : 0);
result = 31 * result + (assignee != null ? assignee.hashCode() : 0);
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
result = 31 * result + (int) (waitingSince ^ (waitingSince >>> 32));
result = 31 * result + (int) (snoozedUntil ^ (snoozedUntil >>> 32));
result = 31 * result + (conversationPartCollection != null ? conversationPartCollection.hashCode() : 0);
result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0);
result = 31 * result + (open ? 1 : 0);
Expand All @@ -352,9 +372,11 @@ public String toString() {
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
", waitingSince=" + waitingSince +
", snoozedUntil=" + snoozedUntil +
", conversationPartCollection=" + conversationPartCollection +
", tagCollection=" + tagCollection +
", open=" + open +
", state=" + state +
", read=" + read +
", links=" + links +
"} " + super.toString();
Expand Down