Skip to content

Commit 5623f78

Browse files
alexshultsgmmartinic
authored andcommitted
Adding mapping for customer_first_reply (#263)
1 parent 60567ad commit 5623f78

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ private static boolean isAdminQuery(Map<String, String> params) {
214214

215215
@JsonProperty("conversation_message")
216216
private ConversationMessage conversationMessage;
217+
218+
@JsonProperty("customer_first_reply")
219+
private CustomerFirstReply customerFirstReply;
217220

218221
@JsonProperty("conversation_rating")
219222
private ConversationRating conversationRating;
@@ -293,6 +296,10 @@ public String getId() {
293296
public ConversationMessage getConversationMessage() {
294297
return conversationMessage;
295298
}
299+
300+
public CustomerFirstReply getCustomerFirstReply() {
301+
return customerFirstReply;
302+
}
296303

297304
public ConversationRating getConversationRating() {
298305
return conversationRating;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package io.intercom.api;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
@SuppressWarnings("UnusedDeclaration")
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
public class CustomerFirstReply extends TypedData {
9+
10+
@JsonProperty
11+
private String type;
12+
13+
@JsonProperty
14+
private String url;
15+
16+
@JsonProperty("created_at")
17+
private long createdAt;
18+
19+
public CustomerFirstReply() {
20+
}
21+
22+
public String getType() {
23+
return type;
24+
}
25+
26+
public void setType(String type) {
27+
this.type = type;
28+
}
29+
30+
public String getUrl() {
31+
return url;
32+
}
33+
34+
public void setUrl(String url) {
35+
this.url = url;
36+
}
37+
38+
public long getCreatedAt() {
39+
return createdAt;
40+
}
41+
42+
public void setCreatedAt(long createdAt) {
43+
this.createdAt = createdAt;
44+
}
45+
46+
@Override
47+
public int hashCode() {
48+
final int prime = 31;
49+
int result = 1;
50+
result = prime * result + (int) (createdAt ^ (createdAt >>> 32));
51+
result = prime * result + ((type == null) ? 0 : type.hashCode());
52+
result = prime * result + ((url == null) ? 0 : url.hashCode());
53+
return result;
54+
}
55+
56+
@Override
57+
public boolean equals(Object obj) {
58+
if (this == obj)
59+
return true;
60+
if (obj == null)
61+
return false;
62+
if (getClass() != obj.getClass())
63+
return false;
64+
CustomerFirstReply other = (CustomerFirstReply) obj;
65+
if (createdAt != other.createdAt)
66+
return false;
67+
if (type == null) {
68+
if (other.type != null)
69+
return false;
70+
} else if (!type.equals(other.type))
71+
return false;
72+
if (url == null) {
73+
if (other.url != null)
74+
return false;
75+
} else if (!url.equals(other.url))
76+
return false;
77+
return true;
78+
}
79+
80+
81+
@Override
82+
public String toString() {
83+
return "CustomerFirstReply{" + "type='" + type + '\'' + ", url='" + url + '\'' + ", created_at='" + createdAt + '\'' + "} " + super.toString();
84+
}
85+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,16 @@ private Map<String, String> buildRequestParameters(String html) {
271271
params2.put("display_as", html);
272272
return params2;
273273
}
274+
275+
@Test
276+
public void testGetConversationCustomerFirstReply() throws IOException {
277+
PowerMockito.mockStatic(Conversation.class);
278+
279+
String json = load("conversation.json");
280+
final Conversation conversation = objectMapper.readValue(json, Conversation.class);
281+
assertNotNull(conversation.getCustomerFirstReply());
282+
assertEquals(1468236397, conversation.getCustomerFirstReply().getCreatedAt());
283+
assertEquals("conversation", conversation.getCustomerFirstReply().getType());
284+
assertEquals("https://someurl", conversation.getCustomerFirstReply().getUrl());
285+
}
274286
}

intercom-java/src/test/resources/conversation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
"type": "admin",
4242
"id": "358111"
4343
},
44+
"customer_first_reply": {
45+
"created_at": 1468236397,
46+
"type": "conversation",
47+
"url": "https://someurl"
48+
},
4449
"conversation_parts": {
4550
"type": "conversation_part.list",
4651
"conversation_parts": [

0 commit comments

Comments
 (0)