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
63 changes: 63 additions & 0 deletions intercom-java/src/main/java/io/intercom/api/Company.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public static Company update(Company company) throws InvalidException, Authoriza
entity.setSessionCount(company.getSessionCount());
entity.setMonthlySpend(company.getMonthlySpend());
entity.setRemoteCreatedAt(company.getRemoteCreatedAt());
entity.setIndustry(company.getIndustry());
entity.setSize(company.getSize());
entity.setWebsite(company.getWebsite());
if(company.getCustomAttributes() != null) {
entity.getCustomAttributes().putAll(company.getCustomAttributes());
}
Expand Down Expand Up @@ -177,6 +180,9 @@ public String toString() {
@JsonProperty("remote_created_at")
private long remoteCreatedAt;

@JsonProperty("last_request_at")
private long lastRequestAt;

@JsonProperty("created_at")
private long createdAt;

Expand All @@ -189,6 +195,15 @@ public String toString() {
@JsonProperty("user_count")
private Integer userCount;

@JsonProperty("size")
private int size;

@JsonProperty("website")
private String website;

@JsonProperty("industry")
private String industry;

@JsonIgnoreProperties(ignoreUnknown = false)
@JsonProperty("custom_attributes")
private Map<String, CustomAttribute> customAttributes = Maps.newHashMap();
Expand Down Expand Up @@ -232,6 +247,33 @@ public Company setName(String name) {
return this;
}

public int getSize() {
return size;
}

public Company setSize(int size) {
this.size = size;
return this;
}

public String getWebsite() {
return website;
}

public Company setWebsite(String website) {
this.website = website;
return this;
}

public String getIndustry() {
return industry;
}

public Company setIndustry(String industry) {
this.industry = industry;
return this;
}

public long getCreatedAt() {
return createdAt;
}
Expand Down Expand Up @@ -262,6 +304,15 @@ public Company setRemoteCreatedAt(long remoteCreatedAt) {
return this;
}

public long getLastRequestAt() {
return lastRequestAt;
}

public Company setLastRequestAt(long lastRequestAt) {
this.lastRequestAt = lastRequestAt;
return this;
}

public Map<String, CustomAttribute> getCustomAttributes() {
return customAttributes;
}
Expand Down Expand Up @@ -322,6 +373,7 @@ public boolean equals(Object o) {
if (remoteCreatedAt != company.remoteCreatedAt) return false;
if (sessionCount != company.sessionCount) return false;
if (updatedAt != company.updatedAt) return false;
if (lastRequestAt != company.lastRequestAt) return false;
if (companyID != null ? !companyID.equals(company.companyID) : company.companyID != null) return false;
if (customAttributes != null ? !customAttributes.equals(company.customAttributes) : company.customAttributes != null)
return false;
Expand All @@ -336,6 +388,9 @@ public boolean equals(Object o) {
if (untag != null ? !untag.equals(company.untag) : company.untag != null) return false;
//noinspection RedundantIfStatement
if (userCount != null ? !userCount.equals(company.userCount) : company.userCount != null) return false;
if (size != company.size) return false;
if (website != null ? !website.equals(company.website) : company.website != null) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite complicated to read, you want to make sure that the current website and company website aren't equal, right? Is there any way you could export the equals checks to a separate method that returns the boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I can see that it is essentially checking for the possibly inequality between the 2 objects. I was following the standard format that exists for string checking and it is utilised in several places. Could definitely use a refactor though 👍

Do you see any issues with if (!Objects.equals(website, company.website)) return false; https://docs.oracle.com/javase/7/docs/api/java/util/Objects.html#equals(java.lang.Object,%20java.lang.Object)

I can try implement that as it seems built but seems to require Java 1.7

Copy link
Contributor

Choose a reason for hiding this comment

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

That's definitely a lot easier to read. What version of Java is this on? Why isn't it up higher?

That would definitely be nice, but I can understand that you're following the format. As well though, maintainability and readability are definitely important 😄

This definitely isn't a breaking change though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't think we have specified a version of Java we support but created this issue #214 to track the possibility of simplifying this

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry Tim, I missed this. I think you're definitely right we need to look into simplifying it.

if (industry != null ? !industry.equals(company.industry) : company.industry != null) return false;

return true;
}
Expand All @@ -351,12 +406,16 @@ public int hashCode() {
result = 31 * result + (int) (remoteCreatedAt ^ (remoteCreatedAt >>> 32));
result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32));
result = 31 * result + (plan != null ? plan.hashCode() : 0);
result = 31 * result + (userCount != null ? userCount.hashCode() : 0);
result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0);
result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0);
result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0);
result = 31 * result + (untag != null ? untag.hashCode() : 0);
result = 31 * result + size;
result = 31 * result + (website != null ? website.hashCode() : 0);
result = 31 * result + (industry != null ? industry.hashCode() : 0);
return result;
}

Expand All @@ -370,11 +429,15 @@ public String toString() {
", monthlySpend=" + monthlySpend +
", remoteCreatedAt=" + remoteCreatedAt +
", createdAt=" + createdAt +
", lastRequestAt=" + lastRequestAt +
", updatedAt=" + updatedAt +
", plan=" + plan +
", customAttributes=" + customAttributes +
", segmentCollection=" + segmentCollection +
", tagCollection=" + tagCollection +
", size=" + size +
", website='" + website + '\'' +
", industry='" + industry + '\'' +
"} " + super.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ private static CompanyWithStringPlan prepareUpdatableCompany(Company company) {
updatableCompany.setSessionCount(company.getSessionCount());
updatableCompany.setMonthlySpend(company.getMonthlySpend());
updatableCompany.setRemoteCreatedAt(company.getRemoteCreatedAt());
updatableCompany.setIndustry(company.getIndustry());
updatableCompany.setSize(company.getSize());
updatableCompany.setWebsite(company.getWebsite());
if (company.getCustomAttributes() != null) {
updatableCompany.getCustomAttributes().putAll(company.getCustomAttributes());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ class CompanyWithStringPlan extends TypedData {
@JsonProperty("plan")
private String plan;

@JsonProperty("size")
private int size;

@JsonProperty("website")
private String website;

@JsonProperty("industry")
private String industry;

@JsonIgnoreProperties(ignoreUnknown = false)
@JsonProperty("custom_attributes")
private Map<String, CustomAttribute> customAttributes = Maps.newHashMap();
Expand Down Expand Up @@ -96,6 +105,30 @@ public void setRemoteCreatedAt(long remoteCreatedAt) {
this.remoteCreatedAt = remoteCreatedAt;
}

public int getSize() {
return size;
}

public void setSize(int size) {
this.size = size;
}

public String getWebsite() {
return website;
}

public void setWebsite(String website) {
this.website = website;
}

public String getIndustry() {
return industry;
}

public void setIndustry(String industry) {
this.industry = industry;
}

public String getPlan() {
return plan;
}
Expand Down