diff --git a/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java index 289e047..39c37ff 100644 --- a/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java @@ -17,10 +17,10 @@ import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest; import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest; import com.intercom.api.resources.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse; import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; -import com.intercom.api.types.CompanyList; import com.intercom.api.types.DeletedCompanyObject; import java.util.concurrent.CompletableFuture; @@ -49,7 +49,7 @@ public AsyncRawCompaniesClient withRawResponse() { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompletableFuture retrieve() { + public CompletableFuture retrieve() { return this.rawClient.retrieve().thenApply(response -> response.body()); } @@ -61,7 +61,7 @@ public CompletableFuture retrieve() { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompletableFuture retrieve(RetrieveCompanyRequest request) { + public CompletableFuture retrieve(RetrieveCompanyRequest request) { return this.rawClient.retrieve(request).thenApply(response -> response.body()); } @@ -73,7 +73,8 @@ public CompletableFuture retrieve(RetrieveCompanyRequest request) { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompletableFuture retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) { + public CompletableFuture retrieve( + RetrieveCompanyRequest request, RequestOptions requestOptions) { return this.rawClient.retrieve(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java index fea4f30..eb44232 100644 --- a/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java @@ -27,6 +27,7 @@ import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest; import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest; import com.intercom.api.resources.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse; import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; @@ -65,7 +66,7 @@ public AsyncRawCompaniesClient(ClientOptions clientOptions) { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompletableFuture> retrieve() { + public CompletableFuture> retrieve() { return retrieve(RetrieveCompanyRequest.builder().build()); } @@ -77,7 +78,7 @@ public CompletableFuture> retrieve() { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompletableFuture> retrieve(RetrieveCompanyRequest request) { + public CompletableFuture> retrieve(RetrieveCompanyRequest request) { return retrieve(request, null); } @@ -89,7 +90,7 @@ public CompletableFuture> retrieve(RetrieveCom *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompletableFuture> retrieve( + public CompletableFuture> retrieve( RetrieveCompanyRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -129,14 +130,15 @@ public CompletableFuture> retrieve( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CompaniesRetrieveResponse.class), response)); return; } diff --git a/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java index 1268935..c3eef41 100644 --- a/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java @@ -17,10 +17,10 @@ import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest; import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest; import com.intercom.api.resources.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse; import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; -import com.intercom.api.types.CompanyList; import com.intercom.api.types.DeletedCompanyObject; public class CompaniesClient { @@ -48,7 +48,7 @@ public RawCompaniesClient withRawResponse() { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompanyList retrieve() { + public CompaniesRetrieveResponse retrieve() { return this.rawClient.retrieve().body(); } @@ -60,7 +60,7 @@ public CompanyList retrieve() { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompanyList retrieve(RetrieveCompanyRequest request) { + public CompaniesRetrieveResponse retrieve(RetrieveCompanyRequest request) { return this.rawClient.retrieve(request).body(); } @@ -72,7 +72,7 @@ public CompanyList retrieve(RetrieveCompanyRequest request) { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public CompanyList retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) { + public CompaniesRetrieveResponse retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) { return this.rawClient.retrieve(request, requestOptions).body(); } diff --git a/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java index 3b48b7b..e156a5c 100644 --- a/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java @@ -27,6 +27,7 @@ import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest; import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest; import com.intercom.api.resources.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse; import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; @@ -60,7 +61,7 @@ public RawCompaniesClient(ClientOptions clientOptions) { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public IntercomHttpResponse retrieve() { + public IntercomHttpResponse retrieve() { return retrieve(RetrieveCompanyRequest.builder().build()); } @@ -72,7 +73,7 @@ public IntercomHttpResponse retrieve() { *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public IntercomHttpResponse retrieve(RetrieveCompanyRequest request) { + public IntercomHttpResponse retrieve(RetrieveCompanyRequest request) { return retrieve(request, null); } @@ -84,7 +85,8 @@ public IntercomHttpResponse retrieve(RetrieveCompanyRequest request *

https://api.intercom.io/companies?tag_id={tag_id}

*

https://api.intercom.io/companies?segment_id={segment_id}

*/ - public IntercomHttpResponse retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse retrieve( + RetrieveCompanyRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies"); @@ -127,7 +129,8 @@ public IntercomHttpResponse retrieve(RetrieveCompanyRequest request ResponseBody responseBody = response.body(); if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompaniesRetrieveResponse.class), + response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { diff --git a/src/main/java/com/intercom/api/resources/companies/types/CompaniesRetrieveResponse.java b/src/main/java/com/intercom/api/resources/companies/types/CompaniesRetrieveResponse.java new file mode 100644 index 0000000..80242a3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/companies/types/CompaniesRetrieveResponse.java @@ -0,0 +1,204 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.companies.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import com.intercom.api.types.CompanyList; +import java.util.Objects; +import java.util.Optional; + +public final class CompaniesRetrieveResponse { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private CompaniesRetrieveResponse(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static CompaniesRetrieveResponse company(Company value) { + return new CompaniesRetrieveResponse(new CompanyValue(value)); + } + + public static CompaniesRetrieveResponse list(CompanyList value) { + return new CompaniesRetrieveResponse(new ListValue(value)); + } + + public boolean isCompany() { + return value instanceof CompanyValue; + } + + public boolean isList() { + return value instanceof ListValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getCompany() { + if (isCompany()) { + return Optional.of(((CompanyValue) value).value); + } + return Optional.empty(); + } + + public Optional getList() { + if (isList()) { + return Optional.of(((ListValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitCompany(Company company); + + T visitList(CompanyList list); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({@JsonSubTypes.Type(CompanyValue.class), @JsonSubTypes.Type(ListValue.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("company") + @JsonIgnoreProperties("type") + private static final class CompanyValue implements Value { + @JsonUnwrapped + private Company value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private CompanyValue() {} + + private CompanyValue(Company value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitCompany(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CompanyValue && equalTo((CompanyValue) other); + } + + private boolean equalTo(CompanyValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "CompaniesRetrieveResponse{" + "value: " + value + "}"; + } + } + + @JsonTypeName("list") + @JsonIgnoreProperties("type") + private static final class ListValue implements Value { + @JsonUnwrapped + private CompanyList value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private ListValue() {} + + private ListValue(CompanyList value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitList(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListValue && equalTo((ListValue) other); + } + + private boolean equalTo(ListValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "CompaniesRetrieveResponse{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "CompaniesRetrieveResponse{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/types/Company.java b/src/main/java/com/intercom/api/resources/companies/types/Company.java index 9fc0bde..99e4810 100644 --- a/src/main/java/com/intercom/api/resources/companies/types/Company.java +++ b/src/main/java/com/intercom/api/resources/companies/types/Company.java @@ -23,8 +23,6 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Company.Builder.class) public final class Company { - private final Optional type; - private final String id; private final String name; @@ -64,7 +62,6 @@ public final class Company { private final Map additionalProperties; private Company( - Optional type, String id, String name, String appId, @@ -84,7 +81,6 @@ private Company( Optional tags, Optional segments, Map additionalProperties) { - this.type = type; this.id = id; this.name = name; this.appId = appId; @@ -106,14 +102,6 @@ private Company( this.additionalProperties = additionalProperties; } - /** - * @return Value is company - */ - @JsonProperty("type") - public Optional getType() { - return type; - } - /** * @return The Intercom defined id representing the company. */ @@ -267,8 +255,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(Company other) { - return type.equals(other.type) - && id.equals(other.id) + return id.equals(other.id) && name.equals(other.name) && appId.equals(other.appId) && plan.equals(other.plan) @@ -291,7 +278,6 @@ private boolean equalTo(Company other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.type, this.id, this.name, this.appId, @@ -382,10 +368,6 @@ public interface UserCountStage { public interface _FinalStage { Company build(); - _FinalStage type(Optional type); - - _FinalStage type(String type); - _FinalStage plan(Optional plan); _FinalStage plan(Plan plan); @@ -456,8 +438,6 @@ public static final class Builder private Optional plan = Optional.empty(); - private Optional type = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -465,7 +445,6 @@ private Builder() {} @java.lang.Override public Builder from(Company other) { - type(other.getType()); id(other.getId()); name(other.getName()); appId(other.getAppId()); @@ -705,27 +684,9 @@ public _FinalStage plan(Optional plan) { return this; } - /** - *

Value is company

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage type(String type) { - this.type = Optional.ofNullable(type); - return this; - } - - @java.lang.Override - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public _FinalStage type(Optional type) { - this.type = type; - return this; - } - @java.lang.Override public Company build() { return new Company( - type, id, name, appId, diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java index 1f83e6b..2b578ad 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ConvertConversationToTicketRequest.java @@ -9,18 +9,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.intercom.api.core.ObjectMappers; -import java.io.IOException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -33,14 +25,14 @@ public final class ConvertConversationToTicketRequest { private final String ticketTypeId; - private final Optional> attributes; + private final Optional> attributes; private final Map additionalProperties; private ConvertConversationToTicketRequest( String conversationId, String ticketTypeId, - Optional> attributes, + Optional> attributes, Map additionalProperties) { this.conversationId = conversationId; this.ticketTypeId = ticketTypeId; @@ -65,7 +57,7 @@ public String getTicketTypeId() { } @JsonProperty("attributes") - public Optional> getAttributes() { + public Optional> getAttributes() { return attributes; } @@ -114,9 +106,9 @@ public interface TicketTypeIdStage { public interface _FinalStage { ConvertConversationToTicketRequest build(); - _FinalStage attributes(Optional> attributes); + _FinalStage attributes(Optional> attributes); - _FinalStage attributes(Map attributes); + _FinalStage attributes(Map attributes); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -125,7 +117,7 @@ public static final class Builder implements ConversationIdStage, TicketTypeIdSt private String ticketTypeId; - private Optional> attributes = Optional.empty(); + private Optional> attributes = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -163,14 +155,14 @@ public _FinalStage ticketTypeId(@NotNull String ticketTypeId) { } @java.lang.Override - public _FinalStage attributes(Map attributes) { + public _FinalStage attributes(Map attributes) { this.attributes = Optional.ofNullable(attributes); return this; } @java.lang.Override @JsonSetter(value = "attributes", nulls = Nulls.SKIP) - public _FinalStage attributes(Optional> attributes) { + public _FinalStage attributes(Optional> attributes) { this.attributes = attributes; return this; } @@ -181,106 +173,4 @@ public ConvertConversationToTicketRequest build() { conversationId, ticketTypeId, attributes, additionalProperties); } } - - @JsonDeserialize(using = AttributesValue.Deserializer.class) - public static final class AttributesValue { - private final Object value; - - private final int type; - - private AttributesValue(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Optional) this.value); - } else if (this.type == 1) { - return visitor.visit((double) this.value); - } else if (this.type == 2) { - return visitor.visit((boolean) this.value); - } else if (this.type == 3) { - return visitor.visit((List) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AttributesValue && equalTo((AttributesValue) other); - } - - private boolean equalTo(AttributesValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AttributesValue of(Optional value) { - return new AttributesValue(value, 0); - } - - public static AttributesValue of(double value) { - return new AttributesValue(value, 1); - } - - public static AttributesValue of(boolean value) { - return new AttributesValue(value, 2); - } - - public static AttributesValue of(List value) { - return new AttributesValue(value, 3); - } - - public interface Visitor { - T visit(Optional value); - - T visit(double value); - - T visit(boolean value); - - T visit(List value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AttributesValue.class); - } - - @java.lang.Override - public AttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - if (value instanceof Double) { - return of((Double) value); - } - if (value instanceof Boolean) { - return of((Boolean) value); - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } - } } diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java index 1ff1dd1..d1a5971 100644 --- a/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java @@ -13,7 +13,6 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; @@ -38,7 +37,7 @@ public final class CreateTicketRequest { private final Optional createdAt; - private final Optional> ticketAttributes; + private final Optional> ticketAttributes; private final Map additionalProperties; @@ -47,7 +46,7 @@ private CreateTicketRequest( List contacts, Optional companyId, Optional createdAt, - Optional> ticketAttributes, + Optional> ticketAttributes, Map additionalProperties) { this.ticketTypeId = ticketTypeId; this.contacts = contacts; @@ -90,7 +89,7 @@ public Optional getCreatedAt() { } @JsonProperty("ticket_attributes") - public Optional> getTicketAttributes() { + public Optional> getTicketAttributes() { return ticketAttributes; } @@ -150,16 +149,16 @@ public interface _FinalStage { _FinalStage createdAt(Integer createdAt); - _FinalStage ticketAttributes(Optional> ticketAttributes); + _FinalStage ticketAttributes(Optional> ticketAttributes); - _FinalStage ticketAttributes(Map ticketAttributes); + _FinalStage ticketAttributes(Map ticketAttributes); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements TicketTypeIdStage, _FinalStage { private String ticketTypeId; - private Optional> ticketAttributes = Optional.empty(); + private Optional> ticketAttributes = Optional.empty(); private Optional createdAt = Optional.empty(); @@ -194,14 +193,14 @@ public _FinalStage ticketTypeId(@NotNull String ticketTypeId) { } @java.lang.Override - public _FinalStage ticketAttributes(Map ticketAttributes) { + public _FinalStage ticketAttributes(Map ticketAttributes) { this.ticketAttributes = Optional.ofNullable(ticketAttributes); return this; } @java.lang.Override @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) - public _FinalStage ticketAttributes(Optional> ticketAttributes) { + public _FinalStage ticketAttributes(Optional> ticketAttributes) { this.ticketAttributes = ticketAttributes; return this; } @@ -275,108 +274,6 @@ public CreateTicketRequest build() { } } - @JsonDeserialize(using = TicketAttributesValue.Deserializer.class) - public static final class TicketAttributesValue { - private final Object value; - - private final int type; - - private TicketAttributesValue(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Optional) this.value); - } else if (this.type == 1) { - return visitor.visit((double) this.value); - } else if (this.type == 2) { - return visitor.visit((boolean) this.value); - } else if (this.type == 3) { - return visitor.visit((List) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TicketAttributesValue && equalTo((TicketAttributesValue) other); - } - - private boolean equalTo(TicketAttributesValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TicketAttributesValue of(Optional value) { - return new TicketAttributesValue(value, 0); - } - - public static TicketAttributesValue of(double value) { - return new TicketAttributesValue(value, 1); - } - - public static TicketAttributesValue of(boolean value) { - return new TicketAttributesValue(value, 2); - } - - public static TicketAttributesValue of(List value) { - return new TicketAttributesValue(value, 3); - } - - public interface Visitor { - T visit(Optional value); - - T visit(double value); - - T visit(boolean value); - - T visit(List value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TicketAttributesValue.class); - } - - @java.lang.Override - public TicketAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - if (value instanceof Double) { - return of((Double) value); - } - if (value instanceof Boolean) { - return of((Boolean) value); - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } - } - @JsonDeserialize(using = ContactsItem.Deserializer.class) public static final class ContactsItem { private final Object value; diff --git a/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java b/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java index 123a13a..308a85b 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java @@ -11,20 +11,12 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.intercom.api.core.ObjectMappers; -import com.intercom.api.types.FileAttribute; import com.intercom.api.types.LinkedObjectList; import com.intercom.api.types.TicketParts; -import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -39,7 +31,7 @@ public final class Ticket { private final Category category; - private final Map ticketAttributes; + private final Map ticketAttributes; private final TicketState ticketState; @@ -75,7 +67,7 @@ private Ticket( String id, String ticketId, Category category, - Map ticketAttributes, + Map ticketAttributes, TicketState ticketState, TicketType ticketType, TicketContacts contacts, @@ -145,7 +137,7 @@ public Category getCategory() { } @JsonProperty("ticket_attributes") - public Map getTicketAttributes() { + public Map getTicketAttributes() { return ticketAttributes; } @@ -342,11 +334,11 @@ public interface ContactsStage { public interface _FinalStage { Ticket build(); - _FinalStage ticketAttributes(Map ticketAttributes); + _FinalStage ticketAttributes(Map ticketAttributes); - _FinalStage putAllTicketAttributes(Map ticketAttributes); + _FinalStage putAllTicketAttributes(Map ticketAttributes); - _FinalStage ticketAttributes(String key, TicketAttributesValue value); + _FinalStage ticketAttributes(String key, Object value); _FinalStage adminAssigneeId(Optional adminAssigneeId); @@ -436,7 +428,7 @@ public static final class Builder private Optional adminAssigneeId = Optional.empty(); - private Map ticketAttributes = new LinkedHashMap<>(); + private Map ticketAttributes = new LinkedHashMap<>(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -704,20 +696,20 @@ public _FinalStage adminAssigneeId(Optional adminAssigneeId) { } @java.lang.Override - public _FinalStage ticketAttributes(String key, TicketAttributesValue value) { + public _FinalStage ticketAttributes(String key, Object value) { this.ticketAttributes.put(key, value); return this; } @java.lang.Override - public _FinalStage putAllTicketAttributes(Map ticketAttributes) { + public _FinalStage putAllTicketAttributes(Map ticketAttributes) { this.ticketAttributes.putAll(ticketAttributes); return this; } @java.lang.Override @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) - public _FinalStage ticketAttributes(Map ticketAttributes) { + public _FinalStage ticketAttributes(Map ticketAttributes) { this.ticketAttributes.clear(); this.ticketAttributes.putAll(ticketAttributes); return this; @@ -789,118 +781,4 @@ public String toString() { return this.value; } } - - @JsonDeserialize(using = TicketAttributesValue.Deserializer.class) - public static final class TicketAttributesValue { - private final Object value; - - private final int type; - - private TicketAttributesValue(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Optional) this.value); - } else if (this.type == 1) { - return visitor.visit((double) this.value); - } else if (this.type == 2) { - return visitor.visit((boolean) this.value); - } else if (this.type == 3) { - return visitor.visit((List) this.value); - } else if (this.type == 4) { - return visitor.visit((FileAttribute) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TicketAttributesValue && equalTo((TicketAttributesValue) other); - } - - private boolean equalTo(TicketAttributesValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TicketAttributesValue of(Optional value) { - return new TicketAttributesValue(value, 0); - } - - public static TicketAttributesValue of(double value) { - return new TicketAttributesValue(value, 1); - } - - public static TicketAttributesValue of(boolean value) { - return new TicketAttributesValue(value, 2); - } - - public static TicketAttributesValue of(List value) { - return new TicketAttributesValue(value, 3); - } - - public static TicketAttributesValue of(FileAttribute value) { - return new TicketAttributesValue(value, 4); - } - - public interface Visitor { - T visit(Optional value); - - T visit(double value); - - T visit(boolean value); - - T visit(List value); - - T visit(FileAttribute value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TicketAttributesValue.class); - } - - @java.lang.Override - public TicketAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - if (value instanceof Double) { - return of((Double) value); - } - if (value instanceof Boolean) { - return of((Boolean) value); - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FileAttribute.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } - } } diff --git a/src/main/java/com/intercom/api/types/CompanyList.java b/src/main/java/com/intercom/api/types/CompanyList.java index edf34d6..cab58b4 100644 --- a/src/main/java/com/intercom/api/types/CompanyList.java +++ b/src/main/java/com/intercom/api/types/CompanyList.java @@ -39,14 +39,6 @@ private CompanyList( this.additionalProperties = additionalProperties; } - /** - * @return The type of object - list. - */ - @JsonProperty("type") - public String getType() { - return "list"; - } - @JsonProperty("pages") public Optional getPages() { return pages;