Skip to content

Commit e76c356

Browse files
author
Timothy Lim
committed
Add support for new company attributes + add tests
1 parent 2751b32 commit e76c356

File tree

6 files changed

+400
-5
lines changed

6 files changed

+400
-5
lines changed

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

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static Company update(Company company) throws InvalidException, Authoriza
4040
entity.setSessionCount(company.getSessionCount());
4141
entity.setMonthlySpend(company.getMonthlySpend());
4242
entity.setRemoteCreatedAt(company.getRemoteCreatedAt());
43+
entity.setIndustry(company.getIndustry());
44+
entity.setSize(company.getSize());
45+
entity.setWebsite(company.getWebsite());
4346
if(company.getCustomAttributes() != null) {
4447
entity.getCustomAttributes().putAll(company.getCustomAttributes());
4548
}
@@ -181,6 +184,9 @@ public String toString() {
181184
@JsonProperty("remote_created_at")
182185
private long remoteCreatedAt;
183186

187+
@JsonProperty("last_request_at")
188+
private long lastRequestAt;
189+
184190
@JsonProperty("created_at")
185191
private long createdAt;
186192

@@ -193,6 +199,15 @@ public String toString() {
193199
@JsonProperty("user_count")
194200
private Integer userCount;
195201

202+
@JsonProperty("size")
203+
private int size;
204+
205+
@JsonProperty("website")
206+
private String website;
207+
208+
@JsonProperty("industry")
209+
private String industry;
210+
196211
@JsonIgnoreProperties(ignoreUnknown = false)
197212
@JsonProperty("custom_attributes")
198213
private Map<String, CustomAttribute> customAttributes = Maps.newHashMap();
@@ -236,6 +251,33 @@ public Company setName(String name) {
236251
return this;
237252
}
238253

254+
public int getSize() {
255+
return size;
256+
}
257+
258+
public Company setSize(int size) {
259+
this.size = size;
260+
return this;
261+
}
262+
263+
public String getWebsite() {
264+
return website;
265+
}
266+
267+
public Company setWebsite(String website) {
268+
this.website = website;
269+
return this;
270+
}
271+
272+
public String getIndustry() {
273+
return industry;
274+
}
275+
276+
public Company setIndustry(String industry) {
277+
this.industry = industry;
278+
return this;
279+
}
280+
239281
public long getCreatedAt() {
240282
return createdAt;
241283
}
@@ -258,15 +300,14 @@ public int getSessionCount() {
258300
}
259301

260302
/**
261-
* Deprecated. The Intercom API does not support changing the
262-
* session value for a company. Calling this method has no
263-
* effect.
303+
* Note. The Intercom API does not support changing the
304+
* session value for a company. Method needed for testing
264305
*
265-
* @param sessionCount this value is ignored
306+
* @param sessionCount
266307
* @return the company object
267308
*/
268-
@Deprecated
269309
public Company setSessionCount(int sessionCount) {
310+
this.sessionCount = sessionCount;
270311
return this;
271312
}
272313

@@ -279,6 +320,15 @@ public Company setRemoteCreatedAt(long remoteCreatedAt) {
279320
return this;
280321
}
281322

323+
public long getLastRequestAt() {
324+
return lastRequestAt;
325+
}
326+
327+
public Company setLastRequestAt(long lastRequestAt) {
328+
this.lastRequestAt = lastRequestAt;
329+
return this;
330+
}
331+
282332
public Map<String, CustomAttribute> getCustomAttributes() {
283333
return customAttributes;
284334
}
@@ -339,6 +389,7 @@ public boolean equals(Object o) {
339389
if (remoteCreatedAt != company.remoteCreatedAt) return false;
340390
if (sessionCount != company.sessionCount) return false;
341391
if (updatedAt != company.updatedAt) return false;
392+
if (lastRequestAt != company.lastRequestAt) return false;
342393
if (companyID != null ? !companyID.equals(company.companyID) : company.companyID != null) return false;
343394
if (customAttributes != null ? !customAttributes.equals(company.customAttributes) : company.customAttributes != null)
344395
return false;
@@ -353,6 +404,9 @@ public boolean equals(Object o) {
353404
if (untag != null ? !untag.equals(company.untag) : company.untag != null) return false;
354405
//noinspection RedundantIfStatement
355406
if (userCount != null ? !userCount.equals(company.userCount) : company.userCount != null) return false;
407+
if (size != company.size) return false;
408+
if (website != null ? !website.equals(company.website) : company.website != null) return false;
409+
if (industry != null ? !industry.equals(company.industry) : company.industry != null) return false;
356410

357411
return true;
358412
}
@@ -368,12 +422,16 @@ public int hashCode() {
368422
result = 31 * result + (int) (remoteCreatedAt ^ (remoteCreatedAt >>> 32));
369423
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
370424
result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
425+
result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32));
371426
result = 31 * result + (plan != null ? plan.hashCode() : 0);
372427
result = 31 * result + (userCount != null ? userCount.hashCode() : 0);
373428
result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0);
374429
result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0);
375430
result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0);
376431
result = 31 * result + (untag != null ? untag.hashCode() : 0);
432+
result = 31 * result + size;
433+
result = 31 * result + (website != null ? website.hashCode() : 0);
434+
result = 31 * result + (industry != null ? industry.hashCode() : 0);
377435
return result;
378436
}
379437

@@ -387,11 +445,15 @@ public String toString() {
387445
", monthlySpend=" + monthlySpend +
388446
", remoteCreatedAt=" + remoteCreatedAt +
389447
", createdAt=" + createdAt +
448+
", lastRequestAt=" + lastRequestAt +
390449
", updatedAt=" + updatedAt +
391450
", plan=" + plan +
392451
", customAttributes=" + customAttributes +
393452
", segmentCollection=" + segmentCollection +
394453
", tagCollection=" + tagCollection +
454+
", size=" + size +
455+
", website='" + website + '\'' +
456+
", industry='" + industry + '\'' +
395457
"} " + super.toString();
396458
}
397459

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ private static CompanyWithStringPlan prepareUpdatableCompany(Company company) {
5656
updatableCompany.setSessionCount(company.getSessionCount());
5757
updatableCompany.setMonthlySpend(company.getMonthlySpend());
5858
updatableCompany.setRemoteCreatedAt(company.getRemoteCreatedAt());
59+
updatableCompany.setIndustry(company.getIndustry());
60+
updatableCompany.setSize(company.getSize());
61+
updatableCompany.setWebsite(company.getWebsite());
5962
if (company.getCustomAttributes() != null) {
6063
updatableCompany.getCustomAttributes().putAll(company.getCustomAttributes());
6164
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ class CompanyWithStringPlan extends TypedData {
3333
@JsonProperty("plan")
3434
private String plan;
3535

36+
@JsonProperty("size")
37+
private int size;
38+
39+
@JsonProperty("website")
40+
private String website;
41+
42+
@JsonProperty("industry")
43+
private String industry;
44+
3645
@JsonIgnoreProperties(ignoreUnknown = false)
3746
@JsonProperty("custom_attributes")
3847
private Map<String, CustomAttribute> customAttributes = Maps.newHashMap();
@@ -96,6 +105,30 @@ public void setRemoteCreatedAt(long remoteCreatedAt) {
96105
this.remoteCreatedAt = remoteCreatedAt;
97106
}
98107

108+
public int getSize() {
109+
return size;
110+
}
111+
112+
public void setSize(int size) {
113+
this.size = size;
114+
}
115+
116+
public String getWebsite() {
117+
return website;
118+
}
119+
120+
public void setWebsite(String website) {
121+
this.website = website;
122+
}
123+
124+
public String getIndustry() {
125+
return industry;
126+
}
127+
128+
public void setIndustry(String industry) {
129+
this.industry = industry;
130+
}
131+
99132
public String getPlan() {
100133
return plan;
101134
}

0 commit comments

Comments
 (0)