Skip to content

Commit d9699f5

Browse files
thewheatchoran
authored andcommitted
Handle records with no avatars (#181)
1 parent 2751b32 commit d9699f5

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public URI getImageURL() {
3030
}
3131

3232
public Avatar setImageURL(String imageURL) {
33-
this.imageURL = URI.create(imageURL);
33+
if(imageURL != null) {
34+
this.imageURL = URI.create(imageURL);
35+
}
3436
return this;
3537
}
3638

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ public void TestSerdes() throws Exception {
246246
assertEquals(null, customAttribute);
247247
}
248248

249+
@Test
250+
public void TestSerdesNoAvatar() throws Exception {
251+
String json = load("user_no_avatar.json");
252+
final User user = mapper.readValue(json, User.class);
253+
assertEquals(null, user.getAvatar().getImageURL());
254+
}
255+
249256
@Test
250257
public void testBulkValidation() {
251258

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"type": "user",
3+
"id": "530370b477ad7120001d",
4+
"user_id": "25",
5+
"email": "[email protected]",
6+
"phone": "+1234567890",
7+
"name": "Hoban Washburne",
8+
"remote_created_at": 1392731331,
9+
"signed_up_at": 1392731331,
10+
"updated_at": 1392734388,
11+
"session_count": 0,
12+
"last_seen_ip": "1.2.3.4",
13+
"unsubscribed_from_emails": false,
14+
"last_request_at": 1397574667,
15+
"created_at": 1392734388,
16+
"user_agent_data": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9",
17+
"custom_attributes": {
18+
"truthy_typed": true,
19+
"floatly_typed": 155.5,
20+
"stringly_typed": "data",
21+
"dately_typed_at": 1397574667,
22+
"longly_typed": 221397574667,
23+
"intly_typed": 1,
24+
"nully_typed": null
25+
},
26+
"avatar": {
27+
"type": "avatar",
28+
"image_url": null
29+
},
30+
"location_data": {
31+
"type": "location_data",
32+
"city_name": "Dublin",
33+
"continent_code": "EU",
34+
"country_code": "IRL",
35+
"country_name": "Ireland",
36+
"latitude": 53.159233,
37+
"longitude": -6.723,
38+
"postal_code": null,
39+
"region_name": "Dublin",
40+
"timezone": "Europe/Dublin"
41+
},
42+
"social_profiles": {
43+
"type": "social_profile.list",
44+
"social_profiles": [
45+
{
46+
"name": "Twitter",
47+
"id": "1235d3213",
48+
"username": "th1sland",
49+
"url": "http://twitter.com/th1sland"
50+
}
51+
]
52+
},
53+
"companies": {
54+
"type": "company.list",
55+
"companies": [
56+
{
57+
"id": "530370b477ad7120001e"
58+
}
59+
]
60+
},
61+
"segments": {
62+
"type": "segment.list",
63+
"segments": [
64+
{
65+
"id": "5310d8e7598c9a0b24000002"
66+
}
67+
]
68+
},
69+
"tags": {
70+
"type": "tag.list",
71+
"tags": [
72+
{
73+
"id": "202"
74+
}
75+
]
76+
}
77+
}

0 commit comments

Comments
 (0)