Skip to content

Commit fe3accf

Browse files
authored
Merge pull request #170 from intercom/MM/json_ignore
add ignoreUnknown to all models
2 parents d1a8796 + be47d48 commit fe3accf

File tree

7 files changed

+131
-15
lines changed

7 files changed

+131
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ out/*
66
*.ipr
77
*.iws
88
build
9+
out
910
*/build/*
1011
*/build/**/*.jar
1112
*.war

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.util.Map;
1111

1212
@SuppressWarnings("UnusedDeclaration")
13-
@JsonIgnoreProperties({"intercom"})
13+
@JsonIgnoreProperties(value = {"intercom"}, ignoreUnknown = true)
1414
public class Notification extends TypedData {
1515

1616
public static Notification readJSON(String json) throws InvalidException {
@@ -200,18 +200,18 @@ public boolean equals(Object o) {
200200
@Override
201201
public String toString() {
202202
return "Notification{" +
203-
"type='" + type + '\'' +
204-
", id='" + id + '\'' +
205-
", topic='" + topic + '\'' +
206-
", appID='" + appID + '\'' +
207-
", data=" + data +
208-
", deliveryStatus='" + deliveryStatus + '\'' +
209-
", deliveryAttempts=" + deliveryAttempts +
210-
", deliveredAt=" + deliveredAt +
211-
", firstSentAt=" + firstSentAt +
212-
", createdAt=" + createdAt +
213-
", links=" + links +
214-
", self=" + self +
215-
"} " + super.toString();
203+
"type='" + type + '\'' +
204+
", id='" + id + '\'' +
205+
", topic='" + topic + '\'' +
206+
", appID='" + appID + '\'' +
207+
", data=" + data +
208+
", deliveryStatus='" + deliveryStatus + '\'' +
209+
", deliveryAttempts=" + deliveryAttempts +
210+
", deliveredAt=" + deliveredAt +
211+
", firstSentAt=" + firstSentAt +
212+
", createdAt=" + createdAt +
213+
", links=" + links +
214+
", self=" + self +
215+
"} " + super.toString();
216216
}
217217
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.intercom.api;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
34
import com.fasterxml.jackson.annotation.JsonProperty;
45

6+
@JsonIgnoreProperties(ignoreUnknown = true)
57
class Reply<T extends Replier> extends TypedData {
68

79
@JsonProperty("message_type")

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.intercom.api;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
34
import com.fasterxml.jackson.annotation.JsonInclude;
45
import com.fasterxml.jackson.annotation.JsonProperty;
56
import com.google.common.collect.Lists;
67

78
import java.util.List;
89

10+
@JsonIgnoreProperties(ignoreUnknown = true)
911
@JsonInclude(JsonInclude.Include.NON_EMPTY)
1012
public abstract class ScrollableTypedDataCollection<T extends TypedData> extends TypedData {
1113

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import java.util.Map;
1414

1515
@SuppressWarnings("UnusedDeclaration")
16-
@JsonIgnoreProperties({"page"})
16+
@JsonIgnoreProperties(value={"page"}, ignoreUnknown = true)
1717
@JsonInclude(JsonInclude.Include.NON_EMPTY)
1818
public abstract class TypedDataCollection<T extends TypedData> extends TypedData {
1919

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.intercom.api;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import org.junit.BeforeClass;
5+
import org.junit.Test;
6+
7+
import java.util.Map;
8+
9+
import static io.intercom.api.TestSupport.load;
10+
import static org.junit.Assert.assertEquals;
11+
12+
public class NotificationTest {
13+
private static ObjectMapper mapper;
14+
15+
@BeforeClass
16+
public static void beforeClass() {
17+
mapper = TestSupport.objectMapper();
18+
}
19+
20+
@Test
21+
public void testPayload() throws Exception {
22+
String json = load("notification.json");
23+
final Notification notification = mapper.readValue(json, Notification.class);
24+
25+
assertEquals("notif_d9697680-d363-11e7-9ccb-d3a7f70c358c", notification.getId());
26+
assertEquals(1511781145L, notification.getCreatedAt());
27+
assertEquals("a86dr8yl", notification.getAppID());
28+
assertEquals("pending", notification.getDeliveryStatus());
29+
assertEquals("user.created", notification.getTopic());
30+
assertEquals(1, notification.getDeliveryAttempts());
31+
assertEquals(1511781146L, notification.getFirstSentAt());
32+
33+
final NotificationData notificationData = notification.getData();
34+
final Map notificationDataItem = notificationData.getItem();
35+
assertEquals("user", notificationDataItem.get("type"));
36+
assertEquals("5a1bf31767893985752b4041", notificationDataItem.get("id"));
37+
assertEquals("test1234", notificationDataItem.get("user_id"));
38+
}
39+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"type" : "notification_event",
3+
"app_id" : "a86dr8yl",
4+
"data" : {
5+
"type" : "notification_event_data",
6+
"item" : {
7+
"type" : "user",
8+
"id" : "5a1bf31767893985752b4041",
9+
"user_id" : "test1234",
10+
"anonymous" : false,
11+
"email" : "[email protected]",
12+
"phone" : "1234567890",
13+
"name" : "name1",
14+
"pseudonym" : null,
15+
"avatar" : {
16+
"type" : "avatar",
17+
"image_url" : "http://example.org/128Wash.jpg"
18+
},
19+
"app_id" : "a86dr8yl",
20+
"companies" : {
21+
"type" : "company.list",
22+
"companies" : [ ]
23+
},
24+
"location_data": {
25+
"type": "location_data",
26+
"city_name": "Dublin",
27+
"continent_code": "EU",
28+
"country_code": "IRL",
29+
"country_name": "Ireland",
30+
"latitude": 53.159233,
31+
"longitude": -6.723,
32+
"postal_code": null,
33+
"region_name": "Dublin",
34+
"timezone": "Europe/Dublin"
35+
},
36+
"last_request_at" : "2017-10-17T12:38:46.000Z",
37+
"last_seen_ip" : "1.2.3.4",
38+
"created_at" : "2017-11-27T11:12:24.000Z",
39+
"remote_created_at" : "2017-10-17T12:38:47.000Z",
40+
"signed_up_at" : "2017-10-17T12:38:47.000Z",
41+
"updated_at" : "2017-11-27T11:12:24.713Z",
42+
"session_count" : 0,
43+
"social_profiles" : {
44+
"type" : "social_profile.list",
45+
"social_profiles" : [ ]
46+
},
47+
"unsubscribed_from_emails" : false,
48+
"marked_email_as_spam" : false,
49+
"has_hard_bounced" : false,
50+
"user_agent_data" : "abc",
51+
"tags" : {
52+
"type" : "tag.list",
53+
"tags" : [ ]
54+
},
55+
"segments" : {
56+
"type" : "segment.list",
57+
"segments" : [ ]
58+
},
59+
"custom_attributes" : { }
60+
}
61+
},
62+
"links" : { },
63+
"id" : "notif_d9697680-d363-11e7-9ccb-d3a7f70c358c",
64+
"topic" : "user.created",
65+
"delivery_status" : "pending",
66+
"delivery_attempts" : 1,
67+
"delivered_at" : 0,
68+
"first_sent_at" : 1511781146,
69+
"created_at" : 1511781145,
70+
"self" : null,
71+
"test_unknown_property" : "1234"
72+
}

0 commit comments

Comments
 (0)