diff --git a/README.md b/README.md index 1c3ce8f..f50483c 100644 --- a/README.md +++ b/README.md @@ -99,27 +99,24 @@ Intercom client = Intercom ### Retries The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long -as the request is deemed retriable and the number of retry attempts has not grown larger than the configured +as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2). -A request is deemed retriable when any of the following HTTP status codes is returned: +A request is deemed retryable when any of the following HTTP status codes is returned: - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout) - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) -Use the `maxRetries` request option to configure this behavior. +Use the `maxRetries` client option to configure this behavior. ```java -import com.intercom.api.core.RequestOptions; +import com.intercom.api.Intercom; -client.articles().create( - ..., - RequestOptions - .builder() - .maxRetries(1) - .build() -); +Intercom client = Intercom + .builder() + .maxRetries(1) + .build(); ``` ### Timeouts diff --git a/build.gradle b/build.gradle index 58ca531..c4409ab 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ java { group = 'io.intercom' -version = '3.0.0-alpha7' +version = '3.0.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -77,7 +77,7 @@ publishing { maven(MavenPublication) { groupId = 'io.intercom' artifactId = 'intercom-java' - version = '3.0.0-alpha7' + version = '3.0.0' from components.java pom { name = 'intercom' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 9bbc975..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37f853b..002b867 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index faf9300..23d15a9 100755 --- a/gradlew +++ b/gradlew @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9b42019..5eed7ee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/com/intercom/api/AsyncIntercom.java b/src/main/java/com/intercom/api/AsyncIntercom.java index db64e39..7973c6a 100644 --- a/src/main/java/com/intercom/api/AsyncIntercom.java +++ b/src/main/java/com/intercom/api/AsyncIntercom.java @@ -10,7 +10,6 @@ import com.intercom.api.resources.companies.AsyncCompaniesClient; import com.intercom.api.resources.contacts.AsyncContactsClient; import com.intercom.api.resources.conversations.AsyncConversationsClient; -import com.intercom.api.resources.customchannelevents.AsyncCustomChannelEventsClient; import com.intercom.api.resources.dataattributes.AsyncDataAttributesClient; import com.intercom.api.resources.dataexport.AsyncDataExportClient; import com.intercom.api.resources.events.AsyncEventsClient; @@ -25,6 +24,7 @@ import com.intercom.api.resources.teams.AsyncTeamsClient; import com.intercom.api.resources.tickets.AsyncTicketsClient; import com.intercom.api.resources.tickettypes.AsyncTicketTypesClient; +import com.intercom.api.resources.unstable.AsyncUnstableClient; import com.intercom.api.resources.visitors.AsyncVisitorsClient; import java.util.function.Supplier; @@ -69,10 +69,10 @@ public class AsyncIntercom { protected final Supplier visitorsClient; - protected final Supplier customChannelEventsClient; - protected final Supplier newsClient; + protected final Supplier unstableClient; + public AsyncIntercom(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.adminsClient = Suppliers.memoize(() -> new AsyncAdminsClient(clientOptions)); @@ -94,8 +94,8 @@ public AsyncIntercom(ClientOptions clientOptions) { this.ticketTypesClient = Suppliers.memoize(() -> new AsyncTicketTypesClient(clientOptions)); this.ticketsClient = Suppliers.memoize(() -> new AsyncTicketsClient(clientOptions)); this.visitorsClient = Suppliers.memoize(() -> new AsyncVisitorsClient(clientOptions)); - this.customChannelEventsClient = Suppliers.memoize(() -> new AsyncCustomChannelEventsClient(clientOptions)); this.newsClient = Suppliers.memoize(() -> new AsyncNewsClient(clientOptions)); + this.unstableClient = Suppliers.memoize(() -> new AsyncUnstableClient(clientOptions)); } public AsyncAdminsClient admins() { @@ -174,14 +174,14 @@ public AsyncVisitorsClient visitors() { return this.visitorsClient.get(); } - public AsyncCustomChannelEventsClient customChannelEvents() { - return this.customChannelEventsClient.get(); - } - public AsyncNewsClient news() { return this.newsClient.get(); } + public AsyncUnstableClient unstable() { + return this.unstableClient.get(); + } + public static AsyncIntercomBuilder builder() { return new AsyncIntercomBuilder(); } diff --git a/src/main/java/com/intercom/api/Intercom.java b/src/main/java/com/intercom/api/Intercom.java index 0584e00..4d9bfec 100644 --- a/src/main/java/com/intercom/api/Intercom.java +++ b/src/main/java/com/intercom/api/Intercom.java @@ -10,7 +10,6 @@ import com.intercom.api.resources.companies.CompaniesClient; import com.intercom.api.resources.contacts.ContactsClient; import com.intercom.api.resources.conversations.ConversationsClient; -import com.intercom.api.resources.customchannelevents.CustomChannelEventsClient; import com.intercom.api.resources.dataattributes.DataAttributesClient; import com.intercom.api.resources.dataexport.DataExportClient; import com.intercom.api.resources.events.EventsClient; @@ -25,6 +24,7 @@ import com.intercom.api.resources.teams.TeamsClient; import com.intercom.api.resources.tickets.TicketsClient; import com.intercom.api.resources.tickettypes.TicketTypesClient; +import com.intercom.api.resources.unstable.UnstableClient; import com.intercom.api.resources.visitors.VisitorsClient; import java.util.function.Supplier; @@ -69,10 +69,10 @@ public class Intercom { protected final Supplier visitorsClient; - protected final Supplier customChannelEventsClient; - protected final Supplier newsClient; + protected final Supplier unstableClient; + public Intercom(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.adminsClient = Suppliers.memoize(() -> new AdminsClient(clientOptions)); @@ -94,8 +94,8 @@ public Intercom(ClientOptions clientOptions) { this.ticketTypesClient = Suppliers.memoize(() -> new TicketTypesClient(clientOptions)); this.ticketsClient = Suppliers.memoize(() -> new TicketsClient(clientOptions)); this.visitorsClient = Suppliers.memoize(() -> new VisitorsClient(clientOptions)); - this.customChannelEventsClient = Suppliers.memoize(() -> new CustomChannelEventsClient(clientOptions)); this.newsClient = Suppliers.memoize(() -> new NewsClient(clientOptions)); + this.unstableClient = Suppliers.memoize(() -> new UnstableClient(clientOptions)); } public AdminsClient admins() { @@ -174,14 +174,14 @@ public VisitorsClient visitors() { return this.visitorsClient.get(); } - public CustomChannelEventsClient customChannelEvents() { - return this.customChannelEventsClient.get(); - } - public NewsClient news() { return this.newsClient.get(); } + public UnstableClient unstable() { + return this.unstableClient.get(); + } + public static IntercomBuilder builder() { return new IntercomBuilder(); } diff --git a/src/main/java/com/intercom/api/core/ClientOptions.java b/src/main/java/com/intercom/api/core/ClientOptions.java index 1610d35..4c66e52 100644 --- a/src/main/java/com/intercom/api/core/ClientOptions.java +++ b/src/main/java/com/intercom/api/core/ClientOptions.java @@ -41,10 +41,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "io.intercom:intercom-java/3.0.0-alpha7"); + put("User-Agent", "io.intercom:intercom-java/3.0.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.intercom.fern:api-sdk"); - put("X-Fern-SDK-Version", "3.0.0-alpha7"); + put("X-Fern-SDK-Version", "3.0.0"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java b/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java index d3ec9b9..bd7c8f1 100644 --- a/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java +++ b/src/main/java/com/intercom/api/resources/admins/requests/ConfigureAwayAdminRequest.java @@ -94,16 +94,25 @@ public static AdminIdStage builder() { } public interface AdminIdStage { + /** + * The unique identifier of a given admin + */ AwayModeEnabledStage adminId(@NotNull String adminId); Builder from(ConfigureAwayAdminRequest other); } public interface AwayModeEnabledStage { + /** + * Set to "true" to change the status of the admin to away. + */ AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled); } public interface AwayModeReassignStage { + /** + * Set to "true" to assign any new conversation replies to your default inbox. + */ _FinalStage awayModeReassign(boolean awayModeReassign); } @@ -134,7 +143,7 @@ public Builder from(ConfigureAwayAdminRequest other) { } /** - *

The unique identifier of a given admin

+ * The unique identifier of a given admin

The unique identifier of a given admin

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -145,7 +154,7 @@ public AwayModeEnabledStage adminId(@NotNull String adminId) { } /** - *

Set to "true" to change the status of the admin to away.

+ * Set to "true" to change the status of the admin to away.

Set to "true" to change the status of the admin to away.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -156,7 +165,7 @@ public AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled) { } /** - *

Set to "true" to assign any new conversation replies to your default inbox.

+ * Set to "true" to assign any new conversation replies to your default inbox.

Set to "true" to assign any new conversation replies to your default inbox.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java b/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java index 3b169f7..c843ffb 100644 --- a/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java +++ b/src/main/java/com/intercom/api/resources/admins/requests/FindAdminRequest.java @@ -66,6 +66,9 @@ public static AdminIdStage builder() { } public interface AdminIdStage { + /** + * The unique identifier of a given admin + */ _FinalStage adminId(@NotNull String adminId); Builder from(FindAdminRequest other); @@ -91,7 +94,7 @@ public Builder from(FindAdminRequest other) { } /** - *

The unique identifier of a given admin

+ * The unique identifier of a given admin

The unique identifier of a given admin

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java b/src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java index f2362c9..5d882ad 100644 --- a/src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java +++ b/src/main/java/com/intercom/api/resources/admins/requests/ListAllActivityLogsRequest.java @@ -80,6 +80,9 @@ public static CreatedAtAfterStage builder() { } public interface CreatedAtAfterStage { + /** + * The start date that you request data for. It must be formatted as a UNIX timestamp. + */ _FinalStage createdAtAfter(@NotNull String createdAtAfter); Builder from(ListAllActivityLogsRequest other); @@ -88,6 +91,9 @@ public interface CreatedAtAfterStage { public interface _FinalStage { ListAllActivityLogsRequest build(); + /** + *

The end date that you request data for. It must be formatted as a UNIX timestamp.

+ */ _FinalStage createdAtBefore(Optional createdAtBefore); _FinalStage createdAtBefore(String createdAtBefore); @@ -112,7 +118,7 @@ public Builder from(ListAllActivityLogsRequest other) { } /** - *

The start date that you request data for. It must be formatted as a UNIX timestamp.

+ * The start date that you request data for. It must be formatted as a UNIX timestamp.

The start date that you request data for. It must be formatted as a UNIX timestamp.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -132,6 +138,9 @@ public _FinalStage createdAtBefore(String createdAtBefore) { return this; } + /** + *

The end date that you request data for. It must be formatted as a UNIX timestamp.

+ */ @java.lang.Override @JsonSetter(value = "created_at_before", nulls = Nulls.SKIP) public _FinalStage createdAtBefore(Optional createdAtBefore) { diff --git a/src/main/java/com/intercom/api/resources/admins/types/Admin.java b/src/main/java/com/intercom/api/resources/admins/types/Admin.java index 556bcae..74e3849 100644 --- a/src/main/java/com/intercom/api/resources/admins/types/Admin.java +++ b/src/main/java/com/intercom/api/resources/admins/types/Admin.java @@ -211,48 +211,78 @@ public static IdStage builder() { } public interface IdStage { + /** + * The id representing the admin. + */ NameStage id(@NotNull String id); Builder from(Admin other); } public interface NameStage { + /** + * The name of the admin. + */ EmailStage name(@NotNull String name); } public interface EmailStage { + /** + * The email of the admin. + */ JobTitleStage email(@NotNull String email); } public interface JobTitleStage { + /** + * The job title of the admin. + */ AwayModeEnabledStage jobTitle(@NotNull String jobTitle); } public interface AwayModeEnabledStage { + /** + * Identifies if this admin is currently set in away mode. + */ AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled); } public interface AwayModeReassignStage { + /** + * Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. + */ HasInboxSeatStage awayModeReassign(boolean awayModeReassign); } public interface HasInboxSeatStage { + /** + * Identifies if this admin has a paid inbox seat to restrict/allow features that require them. + */ _FinalStage hasInboxSeat(boolean hasInboxSeat); } public interface _FinalStage { Admin build(); + /** + *

String representing the object's type. Always has the value admin.

+ */ _FinalStage type(Optional type); _FinalStage type(String type); + /** + *

This object represents the avatar associated with the admin.

+ */ _FinalStage teamIds(List teamIds); _FinalStage addTeamIds(Integer teamIds); _FinalStage addAllTeamIds(List teamIds); + /** + *

The avatar object associated with the admin

+ */ _FinalStage avatar(Optional avatar); _FinalStage avatar(Avatar avatar); @@ -316,7 +346,7 @@ public Builder from(Admin other) { } /** - *

The id representing the admin.

+ * The id representing the admin.

The id representing the admin.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -327,7 +357,7 @@ public NameStage id(@NotNull String id) { } /** - *

The name of the admin.

+ * The name of the admin.

The name of the admin.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -338,7 +368,7 @@ public EmailStage name(@NotNull String name) { } /** - *

The email of the admin.

+ * The email of the admin.

The email of the admin.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -349,7 +379,7 @@ public JobTitleStage email(@NotNull String email) { } /** - *

The job title of the admin.

+ * The job title of the admin.

The job title of the admin.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -360,7 +390,7 @@ public AwayModeEnabledStage jobTitle(@NotNull String jobTitle) { } /** - *

Identifies if this admin is currently set in away mode.

+ * Identifies if this admin is currently set in away mode.

Identifies if this admin is currently set in away mode.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -371,7 +401,7 @@ public AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled) { } /** - *

Identifies if this admin is set to automatically reassign new conversations to the apps default inbox.

+ * Identifies if this admin is set to automatically reassign new conversations to the apps default inbox.

Identifies if this admin is set to automatically reassign new conversations to the apps default inbox.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -382,7 +412,7 @@ public HasInboxSeatStage awayModeReassign(boolean awayModeReassign) { } /** - *

Identifies if this admin has a paid inbox seat to restrict/allow features that require them.

+ * Identifies if this admin has a paid inbox seat to restrict/allow features that require them.

Identifies if this admin has a paid inbox seat to restrict/allow features that require them.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -415,6 +445,9 @@ public _FinalStage avatar(Avatar avatar) { return this; } + /** + *

The avatar object associated with the admin

+ */ @java.lang.Override @JsonSetter(value = "avatar", nulls = Nulls.SKIP) public _FinalStage avatar(Optional avatar) { @@ -442,6 +475,9 @@ public _FinalStage addTeamIds(Integer teamIds) { return this; } + /** + *

This object represents the avatar associated with the admin.

+ */ @java.lang.Override @JsonSetter(value = "team_ids", nulls = Nulls.SKIP) public _FinalStage teamIds(List teamIds) { @@ -460,6 +496,9 @@ public _FinalStage type(String type) { return this; } + /** + *

String representing the object's type. Always has the value admin.

+ */ @java.lang.Override @JsonSetter(value = "type", nulls = Nulls.SKIP) public _FinalStage type(Optional type) { @@ -535,6 +574,9 @@ public static ImageUrlStage builder() { } public interface ImageUrlStage { + /** + * URL of the admin's avatar image + */ _FinalStage imageUrl(@NotNull String imageUrl); Builder from(Avatar other); @@ -560,7 +602,7 @@ public Builder from(Avatar other) { } /** - *

URL of the admin's avatar image

+ * URL of the admin's avatar image

URL of the admin's avatar image

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java b/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java index 174bd55..75995d7 100644 --- a/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java +++ b/src/main/java/com/intercom/api/resources/aiagent/types/AiAgent.java @@ -155,6 +155,9 @@ public static SourceTypeStage builder() { } public interface SourceTypeStage { + /** + * The type of the source that triggered AI Agent involvement in the conversation. + */ _FinalStage sourceType(@NotNull SourceType sourceType); Builder from(AiAgent other); @@ -163,22 +166,37 @@ public interface SourceTypeStage { public interface _FinalStage { AiAgent build(); + /** + *

The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null.

+ */ _FinalStage sourceTitle(Optional sourceTitle); _FinalStage sourceTitle(String sourceTitle); + /** + *

The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null

+ */ _FinalStage lastAnswerType(Optional lastAnswerType); _FinalStage lastAnswerType(String lastAnswerType); + /** + *

The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null.

+ */ _FinalStage resolutionState(Optional resolutionState); _FinalStage resolutionState(String resolutionState); + /** + *

The customer satisfaction rating given to AI Agent, from 1-5.

+ */ _FinalStage rating(Optional rating); _FinalStage rating(Integer rating); + /** + *

The customer satisfaction rating remark given to AI Agent.

+ */ _FinalStage ratingRemark(Optional ratingRemark); _FinalStage ratingRemark(String ratingRemark); @@ -222,7 +240,7 @@ public Builder from(AiAgent other) { } /** - *

The type of the source that triggered AI Agent involvement in the conversation.

+ * The type of the source that triggered AI Agent involvement in the conversation.

The type of the source that triggered AI Agent involvement in the conversation.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -255,6 +273,9 @@ public _FinalStage ratingRemark(String ratingRemark) { return this; } + /** + *

The customer satisfaction rating remark given to AI Agent.

+ */ @java.lang.Override @JsonSetter(value = "rating_remark", nulls = Nulls.SKIP) public _FinalStage ratingRemark(Optional ratingRemark) { @@ -272,6 +293,9 @@ public _FinalStage rating(Integer rating) { return this; } + /** + *

The customer satisfaction rating given to AI Agent, from 1-5.

+ */ @java.lang.Override @JsonSetter(value = "rating", nulls = Nulls.SKIP) public _FinalStage rating(Optional rating) { @@ -289,6 +313,9 @@ public _FinalStage resolutionState(String resolutionState) { return this; } + /** + *

The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null.

+ */ @java.lang.Override @JsonSetter(value = "resolution_state", nulls = Nulls.SKIP) public _FinalStage resolutionState(Optional resolutionState) { @@ -306,6 +333,9 @@ public _FinalStage lastAnswerType(String lastAnswerType) { return this; } + /** + *

The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null

+ */ @java.lang.Override @JsonSetter(value = "last_answer_type", nulls = Nulls.SKIP) public _FinalStage lastAnswerType(Optional lastAnswerType) { @@ -323,6 +353,9 @@ public _FinalStage sourceTitle(String sourceTitle) { return this; } + /** + *

The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null.

+ */ @java.lang.Override @JsonSetter(value = "source_title", nulls = Nulls.SKIP) public _FinalStage sourceTitle(Optional sourceTitle) { diff --git a/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java b/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java index 510a294..cdfb998 100644 --- a/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java +++ b/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java @@ -96,16 +96,25 @@ public static UrlStage builder() { } public interface UrlStage { + /** + * The internal URL linking to the content source for teammates. + */ TitleStage url(@NotNull String url); Builder from(ContentSource other); } public interface TitleStage { + /** + * The title of the content source. + */ LocaleStage title(@NotNull String title); } public interface LocaleStage { + /** + * The ISO 639 language code of the content source. + */ _FinalStage locale(@NotNull String locale); } @@ -135,7 +144,7 @@ public Builder from(ContentSource other) { } /** - *

The internal URL linking to the content source for teammates.

+ * The internal URL linking to the content source for teammates.

The internal URL linking to the content source for teammates.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -146,7 +155,7 @@ public TitleStage url(@NotNull String url) { } /** - *

The title of the content source.

+ * The title of the content source.

The title of the content source.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -157,7 +166,7 @@ public LocaleStage title(@NotNull String title) { } /** - *

The ISO 639 language code of the content source.

+ * The ISO 639 language code of the content source.

The ISO 639 language code of the content source.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/articles/requests/CreateArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/CreateArticleRequest.java index fdafcd5..b32929a 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/CreateArticleRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/CreateArticleRequest.java @@ -169,34 +169,55 @@ public static TitleStage builder() { } public interface TitleStage { + /** + * The title of the article.For multilingual articles, this will be the title of the default language's content. + */ AuthorIdStage title(@NotNull String title); Builder from(CreateArticleRequest other); } public interface AuthorIdStage { + /** + * The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ _FinalStage authorId(int authorId); } public interface _FinalStage { CreateArticleRequest build(); + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

The content of the article. For multilingual articles, this will be the body of the default language's content.

+ */ _FinalStage body(Optional body); _FinalStage body(String body); + /** + *

Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content.

+ */ _FinalStage state(Optional state); _FinalStage state(State state); + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ _FinalStage parentId(Optional parentId); _FinalStage parentId(Integer parentId); + /** + *

The type of parent, which can either be a collection or section.

+ */ _FinalStage parentType(Optional parentType); _FinalStage parentType(ParentType parentType); @@ -243,7 +264,7 @@ public Builder from(CreateArticleRequest other) { } /** - *

The title of the article.For multilingual articles, this will be the title of the default language's content.

+ * The title of the article.For multilingual articles, this will be the title of the default language's content.

The title of the article.For multilingual articles, this will be the title of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -254,7 +275,7 @@ public AuthorIdStage title(@NotNull String title) { } /** - *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ * The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -287,6 +308,9 @@ public _FinalStage parentType(ParentType parentType) { return this; } + /** + *

The type of parent, which can either be a collection or section.

+ */ @java.lang.Override @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) public _FinalStage parentType(Optional parentType) { @@ -304,6 +328,9 @@ public _FinalStage parentId(Integer parentId) { return this; } + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ @java.lang.Override @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) public _FinalStage parentId(Optional parentId) { @@ -321,6 +348,9 @@ public _FinalStage state(State state) { return this; } + /** + *

Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "state", nulls = Nulls.SKIP) public _FinalStage state(Optional state) { @@ -338,6 +368,9 @@ public _FinalStage body(String body) { return this; } + /** + *

The content of the article. For multilingual articles, this will be the body of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Optional body) { @@ -355,6 +388,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { diff --git a/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java index 3c574dc..dd09632 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/DeleteArticleRequest.java @@ -66,6 +66,9 @@ public static ArticleIdStage builder() { } public interface ArticleIdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ _FinalStage articleId(@NotNull String articleId); Builder from(DeleteArticleRequest other); @@ -91,7 +94,7 @@ public Builder from(DeleteArticleRequest other) { } /** - *

The unique identifier for the article which is given by Intercom.

+ * The unique identifier for the article which is given by Intercom.

The unique identifier for the article which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java index 6141b65..66535e1 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/FindArticleRequest.java @@ -66,6 +66,9 @@ public static ArticleIdStage builder() { } public interface ArticleIdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ _FinalStage articleId(@NotNull String articleId); Builder from(FindArticleRequest other); @@ -91,7 +94,7 @@ public Builder from(FindArticleRequest other) { } /** - *

The unique identifier for the article which is given by Intercom.

+ * The unique identifier for the article which is given by Intercom.

The unique identifier for the article which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java index 26ab01c..6165a06 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/ListArticlesRequest.java @@ -95,6 +95,9 @@ public Builder from(ListArticlesRequest other) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -106,6 +109,9 @@ public Builder page(Integer page) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public Builder perPage(Optional perPage) { this.perPage = perPage; diff --git a/src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java index bd65181..f0209f0 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/SearchArticlesRequest.java @@ -130,6 +130,9 @@ public Builder from(SearchArticlesRequest other) { return this; } + /** + *

The phrase within your articles to search for.

+ */ @JsonSetter(value = "phrase", nulls = Nulls.SKIP) public Builder phrase(Optional phrase) { this.phrase = phrase; @@ -141,6 +144,9 @@ public Builder phrase(String phrase) { return this; } + /** + *

The state of the Articles returned. One of published, draft or all.

+ */ @JsonSetter(value = "state", nulls = Nulls.SKIP) public Builder state(Optional state) { this.state = state; @@ -152,6 +158,9 @@ public Builder state(String state) { return this; } + /** + *

The ID of the Help Center to search in.

+ */ @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) public Builder helpCenterId(Optional helpCenterId) { this.helpCenterId = helpCenterId; @@ -163,6 +172,9 @@ public Builder helpCenterId(Integer helpCenterId) { return this; } + /** + *

Return a highlighted version of the matching content within your articles. Refer to the response schema for more details.

+ */ @JsonSetter(value = "highlight", nulls = Nulls.SKIP) public Builder highlight(Optional highlight) { this.highlight = highlight; diff --git a/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java b/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java index 2799159..fb1bf1c 100644 --- a/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java +++ b/src/main/java/com/intercom/api/resources/articles/requests/UpdateArticleRequest.java @@ -183,6 +183,9 @@ public static ArticleIdStage builder() { } public interface ArticleIdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ _FinalStage articleId(@NotNull String articleId); Builder from(UpdateArticleRequest other); @@ -191,30 +194,51 @@ public interface ArticleIdStage { public interface _FinalStage { UpdateArticleRequest build(); + /** + *

The title of the article.For multilingual articles, this will be the title of the default language's content.

+ */ _FinalStage title(Optional title); _FinalStage title(String title); + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

The content of the article. For multilingual articles, this will be the body of the default language's content.

+ */ _FinalStage body(Optional body); _FinalStage body(String body); + /** + *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ */ _FinalStage authorId(Optional authorId); _FinalStage authorId(Integer authorId); + /** + *

Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content.

+ */ _FinalStage state(Optional state); _FinalStage state(State state); + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ _FinalStage parentId(Optional parentId); _FinalStage parentId(String parentId); + /** + *

The type of parent, which can either be a collection or section.

+ */ _FinalStage parentType(Optional parentType); _FinalStage parentType(ParentType parentType); @@ -264,7 +288,7 @@ public Builder from(UpdateArticleRequest other) { } /** - *

The unique identifier for the article which is given by Intercom.

+ * The unique identifier for the article which is given by Intercom.

The unique identifier for the article which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -297,6 +321,9 @@ public _FinalStage parentType(ParentType parentType) { return this; } + /** + *

The type of parent, which can either be a collection or section.

+ */ @java.lang.Override @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) public _FinalStage parentType(Optional parentType) { @@ -314,6 +341,9 @@ public _FinalStage parentId(String parentId) { return this; } + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ @java.lang.Override @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) public _FinalStage parentId(Optional parentId) { @@ -331,6 +361,9 @@ public _FinalStage state(State state) { return this; } + /** + *

Whether the article will be published or will be a draft. Defaults to draft. For multilingual articles, this will be the state of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "state", nulls = Nulls.SKIP) public _FinalStage state(Optional state) { @@ -348,6 +381,9 @@ public _FinalStage authorId(Integer authorId) { return this; } + /** + *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ */ @java.lang.Override @JsonSetter(value = "author_id", nulls = Nulls.SKIP) public _FinalStage authorId(Optional authorId) { @@ -365,6 +401,9 @@ public _FinalStage body(String body) { return this; } + /** + *

The content of the article. For multilingual articles, this will be the body of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Optional body) { @@ -382,6 +421,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { @@ -399,6 +441,9 @@ public _FinalStage title(String title) { return this; } + /** + *

The title of the article.For multilingual articles, this will be the title of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "title", nulls = Nulls.SKIP) public _FinalStage title(Optional title) { diff --git a/src/main/java/com/intercom/api/resources/articles/types/Article.java b/src/main/java/com/intercom/api/resources/articles/types/Article.java index e209512..aee34c2 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/Article.java +++ b/src/main/java/com/intercom/api/resources/articles/types/Article.java @@ -294,36 +294,60 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ WorkspaceIdStage id(@NotNull String id); Builder from(Article other); } public interface WorkspaceIdStage { + /** + * The id of the workspace which the article belongs to. + */ TitleStage workspaceId(@NotNull String workspaceId); } public interface TitleStage { + /** + * The title of the article. For multilingual articles, this will be the title of the default language's content. + */ AuthorIdStage title(@NotNull String title); } public interface AuthorIdStage { + /** + * The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ StateStage authorId(int authorId); } public interface StateStage { + /** + * Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. + */ CreatedAtStage state(@NotNull State state); } public interface CreatedAtStage { + /** + * The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. + */ UpdatedAtStage createdAt(int createdAt); } public interface UpdatedAtStage { + /** + * The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. + */ DefaultLocaleStage updatedAt(int updatedAt); } public interface DefaultLocaleStage { + /** + * The default locale of the help center. This field is only returned for multilingual help centers. + */ TranslatedContentStage defaultLocale(@NotNull String defaultLocale); } @@ -334,30 +358,51 @@ public interface TranslatedContentStage { public interface _FinalStage { Article build(); + /** + *

The type of object - article.

+ */ _FinalStage type(Optional type); _FinalStage type(String type); + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ */ _FinalStage body(Optional body); _FinalStage body(String body); + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ */ _FinalStage url(Optional url); _FinalStage url(String url); + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ _FinalStage parentId(Optional parentId); _FinalStage parentId(Integer parentId); + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ */ _FinalStage parentIds(Optional> parentIds); _FinalStage parentIds(List parentIds); + /** + *

The type of parent, which can either be a collection or section.

+ */ _FinalStage parentType(Optional parentType); _FinalStage parentType(String parentType); @@ -441,7 +486,7 @@ public Builder from(Article other) { } /** - *

The unique identifier for the article which is given by Intercom.

+ * The unique identifier for the article which is given by Intercom.

The unique identifier for the article which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -452,7 +497,7 @@ public WorkspaceIdStage id(@NotNull String id) { } /** - *

The id of the workspace which the article belongs to.

+ * The id of the workspace which the article belongs to.

The id of the workspace which the article belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -463,7 +508,7 @@ public TitleStage workspaceId(@NotNull String workspaceId) { } /** - *

The title of the article. For multilingual articles, this will be the title of the default language's content.

+ * The title of the article. For multilingual articles, this will be the title of the default language's content.

The title of the article. For multilingual articles, this will be the title of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -474,7 +519,7 @@ public AuthorIdStage title(@NotNull String title) { } /** - *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ * The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -485,7 +530,7 @@ public StateStage authorId(int authorId) { } /** - *

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

+ * Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content.

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -496,7 +541,7 @@ public CreatedAtStage state(@NotNull State state) { } /** - *

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

+ * The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -507,7 +552,7 @@ public UpdatedAtStage createdAt(int createdAt) { } /** - *

The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

+ * The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -518,7 +563,7 @@ public DefaultLocaleStage updatedAt(int updatedAt) { } /** - *

The default locale of the help center. This field is only returned for multilingual help centers.

+ * The default locale of the help center. This field is only returned for multilingual help centers.

The default locale of the help center. This field is only returned for multilingual help centers.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -558,6 +603,9 @@ public _FinalStage parentType(String parentType) { return this; } + /** + *

The type of parent, which can either be a collection or section.

+ */ @java.lang.Override @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) public _FinalStage parentType(Optional parentType) { @@ -575,6 +623,9 @@ public _FinalStage parentIds(List parentIds) { return this; } + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ */ @java.lang.Override @JsonSetter(value = "parent_ids", nulls = Nulls.SKIP) public _FinalStage parentIds(Optional> parentIds) { @@ -592,6 +643,9 @@ public _FinalStage parentId(Integer parentId) { return this; } + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ @java.lang.Override @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) public _FinalStage parentId(Optional parentId) { @@ -609,6 +663,9 @@ public _FinalStage url(String url) { return this; } + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "url", nulls = Nulls.SKIP) public _FinalStage url(Optional url) { @@ -626,6 +683,9 @@ public _FinalStage body(String body) { return this; } + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Optional body) { @@ -643,6 +703,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { @@ -660,6 +723,9 @@ public _FinalStage type(String type) { return this; } + /** + *

The type of object - article.

+ */ @java.lang.Override @JsonSetter(value = "type", nulls = Nulls.SKIP) public _FinalStage type(Optional type) { diff --git a/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java b/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java index c1a639f..ec33c25 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleListItem.java @@ -282,36 +282,60 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ WorkspaceIdStage id(@NotNull String id); Builder from(ArticleListItem other); } public interface WorkspaceIdStage { + /** + * The id of the workspace which the article belongs to. + */ TitleStage workspaceId(@NotNull String workspaceId); } public interface TitleStage { + /** + * The title of the article. For multilingual articles, this will be the title of the default language's content. + */ AuthorIdStage title(@NotNull String title); } public interface AuthorIdStage { + /** + * The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ StateStage authorId(int authorId); } public interface StateStage { + /** + * Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. + */ CreatedAtStage state(@NotNull State state); } public interface CreatedAtStage { + /** + * The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. + */ UpdatedAtStage createdAt(int createdAt); } public interface UpdatedAtStage { + /** + * The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. + */ DefaultLocaleStage updatedAt(int updatedAt); } public interface DefaultLocaleStage { + /** + * The default locale of the help center. This field is only returned for multilingual help centers. + */ TranslatedContentStage defaultLocale(@NotNull String defaultLocale); } @@ -322,30 +346,51 @@ public interface TranslatedContentStage { public interface _FinalStage { ArticleListItem build(); + /** + *

The type of object - article.

+ */ _FinalStage type(Optional type); _FinalStage type(String type); + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ */ _FinalStage body(Optional body); _FinalStage body(String body); + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ */ _FinalStage url(Optional url); _FinalStage url(String url); + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ _FinalStage parentId(Optional parentId); _FinalStage parentId(Integer parentId); + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ */ _FinalStage parentIds(Optional> parentIds); _FinalStage parentIds(List parentIds); + /** + *

The type of parent, which can either be a collection or section.

+ */ _FinalStage parentType(Optional parentType); _FinalStage parentType(String parentType); @@ -422,7 +467,7 @@ public Builder from(ArticleListItem other) { } /** - *

The unique identifier for the article which is given by Intercom.

+ * The unique identifier for the article which is given by Intercom.

The unique identifier for the article which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -433,7 +478,7 @@ public WorkspaceIdStage id(@NotNull String id) { } /** - *

The id of the workspace which the article belongs to.

+ * The id of the workspace which the article belongs to.

The id of the workspace which the article belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -444,7 +489,7 @@ public TitleStage workspaceId(@NotNull String workspaceId) { } /** - *

The title of the article. For multilingual articles, this will be the title of the default language's content.

+ * The title of the article. For multilingual articles, this will be the title of the default language's content.

The title of the article. For multilingual articles, this will be the title of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -455,7 +500,7 @@ public AuthorIdStage title(@NotNull String title) { } /** - *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ * The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -466,7 +511,7 @@ public StateStage authorId(int authorId) { } /** - *

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

+ * Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content.

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -477,7 +522,7 @@ public CreatedAtStage state(@NotNull State state) { } /** - *

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

+ * The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -488,7 +533,7 @@ public UpdatedAtStage createdAt(int createdAt) { } /** - *

The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

+ * The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -499,7 +544,7 @@ public DefaultLocaleStage updatedAt(int updatedAt) { } /** - *

The default locale of the help center. This field is only returned for multilingual help centers.

+ * The default locale of the help center. This field is only returned for multilingual help centers.

The default locale of the help center. This field is only returned for multilingual help centers.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -526,6 +571,9 @@ public _FinalStage parentType(String parentType) { return this; } + /** + *

The type of parent, which can either be a collection or section.

+ */ @java.lang.Override @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) public _FinalStage parentType(Optional parentType) { @@ -543,6 +591,9 @@ public _FinalStage parentIds(List parentIds) { return this; } + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ */ @java.lang.Override @JsonSetter(value = "parent_ids", nulls = Nulls.SKIP) public _FinalStage parentIds(Optional> parentIds) { @@ -560,6 +611,9 @@ public _FinalStage parentId(Integer parentId) { return this; } + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ @java.lang.Override @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) public _FinalStage parentId(Optional parentId) { @@ -577,6 +631,9 @@ public _FinalStage url(String url) { return this; } + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "url", nulls = Nulls.SKIP) public _FinalStage url(Optional url) { @@ -594,6 +651,9 @@ public _FinalStage body(String body) { return this; } + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Optional body) { @@ -611,6 +671,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { @@ -628,6 +691,9 @@ public _FinalStage type(String type) { return this; } + /** + *

The type of object - article.

+ */ @java.lang.Override @JsonSetter(value = "type", nulls = Nulls.SKIP) public _FinalStage type(Optional type) { diff --git a/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java index f6259d9..dbb6bc6 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchHighlights.java @@ -100,6 +100,9 @@ public static ArticleIdStage builder() { } public interface ArticleIdStage { + /** + * The ID of the corresponding article. + */ _FinalStage articleId(@NotNull String articleId); Builder from(ArticleSearchHighlights other); @@ -108,12 +111,18 @@ public interface ArticleIdStage { public interface _FinalStage { ArticleSearchHighlights build(); + /** + *

An Article title highlighted.

+ */ _FinalStage highlightedTitle(List highlightedTitle); _FinalStage addHighlightedTitle(HighlightedTitleItem highlightedTitle); _FinalStage addAllHighlightedTitle(List highlightedTitle); + /** + *

An Article description and body text highlighted.

+ */ _FinalStage highlightedSummary(List> highlightedSummary); _FinalStage addHighlightedSummary(List highlightedSummary); @@ -143,7 +152,7 @@ public Builder from(ArticleSearchHighlights other) { } /** - *

The ID of the corresponding article.

+ * The ID of the corresponding article.

The ID of the corresponding article.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -173,6 +182,9 @@ public _FinalStage addHighlightedSummary(List highli return this; } + /** + *

An Article description and body text highlighted.

+ */ @java.lang.Override @JsonSetter(value = "highlighted_summary", nulls = Nulls.SKIP) public _FinalStage highlightedSummary(List> highlightedSummary) { @@ -201,6 +213,9 @@ public _FinalStage addHighlightedTitle(HighlightedTitleItem highlightedTitle) { return this; } + /** + *

An Article title highlighted.

+ */ @java.lang.Override @JsonSetter(value = "highlighted_title", nulls = Nulls.SKIP) public _FinalStage highlightedTitle(List highlightedTitle) { @@ -293,6 +308,9 @@ public Builder from(HighlightedTitleItem other) { return this; } + /** + *

The type of text - highlight or plain.

+ */ @JsonSetter(value = "type", nulls = Nulls.SKIP) public Builder type(Optional type) { this.type = type; @@ -304,6 +322,9 @@ public Builder type(Type type) { return this; } + /** + *

The text of the title.

+ */ @JsonSetter(value = "text", nulls = Nulls.SKIP) public Builder text(Optional text) { this.text = text; @@ -474,6 +495,9 @@ public Builder from(HighlightedSummaryItemItem other) { return this; } + /** + *

The type of text - highlight or plain.

+ */ @JsonSetter(value = "type", nulls = Nulls.SKIP) public Builder type(Optional type) { this.type = type; @@ -485,6 +509,9 @@ public Builder type(Type type) { return this; } + /** + *

The text of the title.

+ */ @JsonSetter(value = "text", nulls = Nulls.SKIP) public Builder text(Optional text) { this.text = text; diff --git a/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java b/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java index ee32f02..173874f 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java +++ b/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java @@ -98,12 +98,18 @@ public static TotalCountStage builder() { } public interface TotalCountStage { + /** + * The total number of Articles matching the search query + */ DataStage totalCount(int totalCount); Builder from(SearchArticlesResponse other); } public interface DataStage { + /** + * An object containing the results of the search. + */ _FinalStage data(@NotNull Data data); } @@ -137,7 +143,7 @@ public Builder from(SearchArticlesResponse other) { } /** - *

The total number of Articles matching the search query

+ * The total number of Articles matching the search query

The total number of Articles matching the search query

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -148,7 +154,7 @@ public DataStage totalCount(int totalCount) { } /** - *

An object containing the results of the search.

+ * An object containing the results of the search.

An object containing the results of the search.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -257,6 +263,9 @@ public Builder from(Data other) { return this; } + /** + *

An array of Article objects

+ */ @JsonSetter(value = "articles", nulls = Nulls.SKIP) public Builder articles(Optional> articles) { this.articles = articles; @@ -268,6 +277,9 @@ public Builder articles(List
articles) { return this; } + /** + *

A corresponding array of highlighted Article content

+ */ @JsonSetter(value = "highlights", nulls = Nulls.SKIP) public Builder highlights(Optional> highlights) { this.highlights = highlights; diff --git a/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java index 796a953..615bf52 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/AttachContactToCompanyRequest.java @@ -78,12 +78,18 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ CompanyIdStage contactId(@NotNull String contactId); Builder from(AttachContactToCompanyRequest other); } public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ _FinalStage companyId(@NotNull String companyId); } @@ -110,7 +116,7 @@ public Builder from(AttachContactToCompanyRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -121,7 +127,7 @@ public CompanyIdStage contactId(@NotNull String contactId) { } /** - *

The unique identifier for the company which is given by Intercom

+ * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java index 4186800..f485d52 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/CreateOrUpdateCompanyRequest.java @@ -219,6 +219,9 @@ public Builder from(CreateOrUpdateCompanyRequest other) { return this; } + /** + *

The name of the Company

+ */ @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -230,6 +233,9 @@ public Builder name(String name) { return this; } + /** + *

The company id you have defined for the company. Can't be updated

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -241,6 +247,9 @@ public Builder companyId(String companyId) { return this; } + /** + *

The name of the plan you have associated with the company.

+ */ @JsonSetter(value = "plan", nulls = Nulls.SKIP) public Builder plan(Optional plan) { this.plan = plan; @@ -252,6 +261,9 @@ public Builder plan(String plan) { return this; } + /** + *

The number of employees in this company.

+ */ @JsonSetter(value = "size", nulls = Nulls.SKIP) public Builder size(Optional size) { this.size = size; @@ -263,6 +275,9 @@ public Builder size(Integer size) { return this; } + /** + *

The URL for this company's website. Please note that the value specified here is not validated. Accepts any string.

+ */ @JsonSetter(value = "website", nulls = Nulls.SKIP) public Builder website(Optional website) { this.website = website; @@ -274,6 +289,9 @@ public Builder website(String website) { return this; } + /** + *

The industry that this company operates in.

+ */ @JsonSetter(value = "industry", nulls = Nulls.SKIP) public Builder industry(Optional industry) { this.industry = industry; @@ -285,6 +303,9 @@ public Builder industry(String industry) { return this; } + /** + *

A hash of key/value pairs containing any other data about the company you want Intercom to store.

+ */ @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) public Builder customAttributes(Optional> customAttributes) { this.customAttributes = customAttributes; @@ -296,6 +317,9 @@ public Builder customAttributes(Map customAttributes) { return this; } + /** + *

The time the company was created by you.

+ */ @JsonSetter(value = "remote_created_at", nulls = Nulls.SKIP) public Builder remoteCreatedAt(Optional remoteCreatedAt) { this.remoteCreatedAt = remoteCreatedAt; @@ -307,6 +331,9 @@ public Builder remoteCreatedAt(Integer remoteCreatedAt) { return this; } + /** + *

How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647..

+ */ @JsonSetter(value = "monthly_spend", nulls = Nulls.SKIP) public Builder monthlySpend(Optional monthlySpend) { this.monthlySpend = monthlySpend; diff --git a/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java index b0f262f..7ec0ea0 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java @@ -66,6 +66,9 @@ public static CompanyIdStage builder() { } public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ _FinalStage companyId(@NotNull String companyId); Builder from(DeleteCompanyRequest other); @@ -91,7 +94,7 @@ public Builder from(DeleteCompanyRequest other) { } /** - *

The unique identifier for the company which is given by Intercom

+ * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java index 516819e..fd51def 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/DetachContactFromCompanyRequest.java @@ -78,12 +78,18 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ CompanyIdStage contactId(@NotNull String contactId); Builder from(DetachContactFromCompanyRequest other); } public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ _FinalStage companyId(@NotNull String companyId); } @@ -110,7 +116,7 @@ public Builder from(DetachContactFromCompanyRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -121,7 +127,7 @@ public CompanyIdStage contactId(@NotNull String contactId) { } /** - *

The unique identifier for the company which is given by Intercom

+ * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java index 0c03143..7b57351 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/FindCompanyRequest.java @@ -66,6 +66,9 @@ public static CompanyIdStage builder() { } public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ _FinalStage companyId(@NotNull String companyId); Builder from(FindCompanyRequest other); @@ -91,7 +94,7 @@ public Builder from(FindCompanyRequest other) { } /** - *

The unique identifier for the company which is given by Intercom

+ * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java index 628530c..9985bf0 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/ListAttachedContactsRequest.java @@ -94,6 +94,9 @@ public static CompanyIdStage builder() { } public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ _FinalStage companyId(@NotNull String companyId); Builder from(ListAttachedContactsRequest other); @@ -102,10 +105,16 @@ public interface CompanyIdStage { public interface _FinalStage { ListAttachedContactsRequest build(); + /** + *

The page of results to fetch. Defaults to first page

+ */ _FinalStage page(Optional page); _FinalStage page(Integer page); + /** + *

How many results to return per page. Defaults to 15

+ */ _FinalStage perPage(Optional perPage); _FinalStage perPage(Integer perPage); @@ -133,7 +142,7 @@ public Builder from(ListAttachedContactsRequest other) { } /** - *

The unique identifier for the company which is given by Intercom

+ * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -153,6 +162,9 @@ public _FinalStage perPage(Integer perPage) { return this; } + /** + *

How many results to return per page. Defaults to 15

+ */ @java.lang.Override @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public _FinalStage perPage(Optional perPage) { @@ -170,6 +182,9 @@ public _FinalStage page(Integer page) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @java.lang.Override @JsonSetter(value = "page", nulls = Nulls.SKIP) public _FinalStage page(Optional page) { diff --git a/src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java index 3244026..bbb6b4c 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/ListCompaniesRequest.java @@ -112,6 +112,9 @@ public Builder from(ListCompaniesRequest other) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -123,6 +126,9 @@ public Builder page(Integer page) { return this; } + /** + *

How many results to return per page. Defaults to 15

+ */ @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public Builder perPage(Optional perPage) { this.perPage = perPage; @@ -134,6 +140,9 @@ public Builder perPage(Integer perPage) { return this; } + /** + *

asc or desc. Return the companies in ascending or descending order. Defaults to desc

+ */ @JsonSetter(value = "order", nulls = Nulls.SKIP) public Builder order(Optional order) { this.order = order; diff --git a/src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java index 491e06d..def61ad 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/ListSegmentsAttachedToCompanyRequest.java @@ -67,6 +67,9 @@ public static CompanyIdStage builder() { } public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ _FinalStage companyId(@NotNull String companyId); Builder from(ListSegmentsAttachedToCompanyRequest other); @@ -92,7 +95,7 @@ public Builder from(ListSegmentsAttachedToCompanyRequest other) { } /** - *

The unique identifier for the company which is given by Intercom

+ * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java index a4305b4..ce0fc36 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/RetrieveCompanyRequest.java @@ -162,6 +162,9 @@ public Builder from(RetrieveCompanyRequest other) { return this; } + /** + *

The name of the company to filter by.

+ */ @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; @@ -173,6 +176,9 @@ public Builder name(String name) { return this; } + /** + *

The company_id of the company to filter by.

+ */ @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -184,6 +190,9 @@ public Builder companyId(String companyId) { return this; } + /** + *

The tag_id of the company to filter by.

+ */ @JsonSetter(value = "tag_id", nulls = Nulls.SKIP) public Builder tagId(Optional tagId) { this.tagId = tagId; @@ -195,6 +204,9 @@ public Builder tagId(String tagId) { return this; } + /** + *

The segment_id of the company to filter by.

+ */ @JsonSetter(value = "segment_id", nulls = Nulls.SKIP) public Builder segmentId(Optional segmentId) { this.segmentId = segmentId; @@ -206,6 +218,9 @@ public Builder segmentId(String segmentId) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -217,6 +232,9 @@ public Builder page(Integer page) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public Builder perPage(Optional perPage) { this.perPage = perPage; diff --git a/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java index 5df445f..8d77e60 100644 --- a/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java +++ b/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java @@ -66,6 +66,9 @@ public static CompanyIdStage builder() { } public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ _FinalStage companyId(@NotNull String companyId); Builder from(UpdateCompanyRequest other); @@ -91,7 +94,7 @@ public Builder from(UpdateCompanyRequest other) { } /** - *

The unique identifier for the company which is given by Intercom

+ * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override 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 99e4810..4231d07 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 @@ -308,60 +308,102 @@ public static IdStage builder() { } public interface IdStage { + /** + * The Intercom defined id representing the company. + */ NameStage id(@NotNull String id); Builder from(Company other); } public interface NameStage { + /** + * The name of the company. + */ AppIdStage name(@NotNull String name); } public interface AppIdStage { + /** + * The Intercom defined code of the workspace the company is associated to. + */ CompanyIdStage appId(@NotNull String appId); } public interface CompanyIdStage { + /** + * The company id you have defined for the company. + */ RemoteCreatedAtStage companyId(@NotNull String companyId); } public interface RemoteCreatedAtStage { + /** + * The time the company was created by you. + */ CreatedAtStage remoteCreatedAt(int remoteCreatedAt); } public interface CreatedAtStage { + /** + * The time the company was added in Intercom. + */ UpdatedAtStage createdAt(int createdAt); } public interface UpdatedAtStage { + /** + * The last time the company was updated. + */ LastRequestAtStage updatedAt(int updatedAt); } public interface LastRequestAtStage { + /** + * The time the company last recorded making a request. + */ SizeStage lastRequestAt(int lastRequestAt); } public interface SizeStage { + /** + * The number of employees in the company. + */ WebsiteStage size(int size); } public interface WebsiteStage { + /** + * The URL for the company website. + */ IndustryStage website(@NotNull String website); } public interface IndustryStage { + /** + * The industry that the company operates in. + */ MonthlySpendStage industry(@NotNull String industry); } public interface MonthlySpendStage { + /** + * How much revenue the company generates for your business. + */ SessionCountStage monthlySpend(int monthlySpend); } public interface SessionCountStage { + /** + * How many sessions the company has recorded. + */ UserCountStage sessionCount(int sessionCount); } public interface UserCountStage { + /** + * The number of users in the company. + */ _FinalStage userCount(int userCount); } @@ -372,14 +414,23 @@ public interface _FinalStage { _FinalStage plan(Plan plan); + /** + *

The custom attributes you have set on the company.

+ */ _FinalStage customAttributes(Optional> customAttributes); _FinalStage customAttributes(Map customAttributes); + /** + *

The list of tags associated with the company

+ */ _FinalStage tags(Optional tags); _FinalStage tags(Tags tags); + /** + *

The list of segments associated with the company

+ */ _FinalStage segments(Optional segments); _FinalStage segments(Segments segments); @@ -467,7 +518,7 @@ public Builder from(Company other) { } /** - *

The Intercom defined id representing the company.

+ * The Intercom defined id representing the company.

The Intercom defined id representing the company.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -478,7 +529,7 @@ public NameStage id(@NotNull String id) { } /** - *

The name of the company.

+ * The name of the company.

The name of the company.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -489,7 +540,7 @@ public AppIdStage name(@NotNull String name) { } /** - *

The Intercom defined code of the workspace the company is associated to.

+ * The Intercom defined code of the workspace the company is associated to.

The Intercom defined code of the workspace the company is associated to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -500,7 +551,7 @@ public CompanyIdStage appId(@NotNull String appId) { } /** - *

The company id you have defined for the company.

+ * The company id you have defined for the company.

The company id you have defined for the company.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -511,7 +562,7 @@ public RemoteCreatedAtStage companyId(@NotNull String companyId) { } /** - *

The time the company was created by you.

+ * The time the company was created by you.

The time the company was created by you.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -522,7 +573,7 @@ public CreatedAtStage remoteCreatedAt(int remoteCreatedAt) { } /** - *

The time the company was added in Intercom.

+ * The time the company was added in Intercom.

The time the company was added in Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -533,7 +584,7 @@ public UpdatedAtStage createdAt(int createdAt) { } /** - *

The last time the company was updated.

+ * The last time the company was updated.

The last time the company was updated.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -544,7 +595,7 @@ public LastRequestAtStage updatedAt(int updatedAt) { } /** - *

The time the company last recorded making a request.

+ * The time the company last recorded making a request.

The time the company last recorded making a request.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -555,7 +606,7 @@ public SizeStage lastRequestAt(int lastRequestAt) { } /** - *

The number of employees in the company.

+ * The number of employees in the company.

The number of employees in the company.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -566,7 +617,7 @@ public WebsiteStage size(int size) { } /** - *

The URL for the company website.

+ * The URL for the company website.

The URL for the company website.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -577,7 +628,7 @@ public IndustryStage website(@NotNull String website) { } /** - *

The industry that the company operates in.

+ * The industry that the company operates in.

The industry that the company operates in.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -588,7 +639,7 @@ public MonthlySpendStage industry(@NotNull String industry) { } /** - *

How much revenue the company generates for your business.

+ * How much revenue the company generates for your business.

How much revenue the company generates for your business.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -599,7 +650,7 @@ public SessionCountStage monthlySpend(int monthlySpend) { } /** - *

How many sessions the company has recorded.

+ * How many sessions the company has recorded.

How many sessions the company has recorded.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -610,7 +661,7 @@ public UserCountStage sessionCount(int sessionCount) { } /** - *

The number of users in the company.

+ * The number of users in the company.

The number of users in the company.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -630,6 +681,9 @@ public _FinalStage segments(Segments segments) { return this; } + /** + *

The list of segments associated with the company

+ */ @java.lang.Override @JsonSetter(value = "segments", nulls = Nulls.SKIP) public _FinalStage segments(Optional segments) { @@ -647,6 +701,9 @@ public _FinalStage tags(Tags tags) { return this; } + /** + *

The list of tags associated with the company

+ */ @java.lang.Override @JsonSetter(value = "tags", nulls = Nulls.SKIP) public _FinalStage tags(Optional tags) { @@ -664,6 +721,9 @@ public _FinalStage customAttributes(Map customAttributes) { return this; } + /** + *

The custom attributes you have set on the company.

+ */ @java.lang.Override @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) public _FinalStage customAttributes(Optional> customAttributes) { @@ -783,6 +843,9 @@ public Builder from(Tags other) { return this; } + /** + *

The type of the object

+ */ @JsonSetter(value = "type", nulls = Nulls.SKIP) public Builder type(Optional type) { this.type = type; @@ -886,6 +949,9 @@ public Builder from(Segments other) { return this; } + /** + *

The type of the object

+ */ @JsonSetter(value = "type", nulls = Nulls.SKIP) public Builder type(Optional type) { this.type = type; @@ -1009,6 +1075,9 @@ public Builder from(Plan other) { return this; } + /** + *

Value is always "plan"

+ */ @JsonSetter(value = "type", nulls = Nulls.SKIP) public Builder type(Optional type) { this.type = type; @@ -1020,6 +1089,9 @@ public Builder type(String type) { return this; } + /** + *

The id of the plan

+ */ @JsonSetter(value = "id", nulls = Nulls.SKIP) public Builder id(Optional id) { this.id = id; @@ -1031,6 +1103,9 @@ public Builder id(String id) { return this; } + /** + *

The name of the plan

+ */ @JsonSetter(value = "name", nulls = Nulls.SKIP) public Builder name(Optional name) { this.name = name; diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java index b0fbe13..a1c5637 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ArchiveContactRequest.java @@ -66,6 +66,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * id + */ _FinalStage contactId(@NotNull String contactId); Builder from(ArchiveContactRequest other); @@ -91,7 +94,7 @@ public Builder from(ArchiveContactRequest other) { } /** - *

id

+ * id

id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java index bb940a6..2cea956 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/AttachSubscriptionToContactRequest.java @@ -92,16 +92,25 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ SubscriptionIdStage contactId(@NotNull String contactId); Builder from(AttachSubscriptionToContactRequest other); } public interface SubscriptionIdStage { + /** + * The unique identifier for the subscription which is given by Intercom + */ ConsentTypeStage subscriptionId(@NotNull String subscriptionId); } public interface ConsentTypeStage { + /** + * The consent_type of a subscription, opt_out or opt_in. + */ _FinalStage consentType(@NotNull String consentType); } @@ -131,7 +140,7 @@ public Builder from(AttachSubscriptionToContactRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -142,7 +151,7 @@ public SubscriptionIdStage contactId(@NotNull String contactId) { } /** - *

The unique identifier for the subscription which is given by Intercom

+ * The unique identifier for the subscription which is given by Intercom

The unique identifier for the subscription which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -153,7 +162,7 @@ public ConsentTypeStage subscriptionId(@NotNull String subscriptionId) { } /** - *

The consent_type of a subscription, opt_out or opt_in.

+ * The consent_type of a subscription, opt_out or opt_in.

The consent_type of a subscription, opt_out or opt_in.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java index 1d0f355..82c4d68 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/DeleteContactRequest.java @@ -66,6 +66,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * id + */ _FinalStage contactId(@NotNull String contactId); Builder from(DeleteContactRequest other); @@ -91,7 +94,7 @@ public Builder from(DeleteContactRequest other) { } /** - *

id

+ * id

id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java index 2928b09..369fbcd 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/DetachSubscriptionFromContactRequest.java @@ -79,12 +79,18 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ SubscriptionIdStage contactId(@NotNull String contactId); Builder from(DetachSubscriptionFromContactRequest other); } public interface SubscriptionIdStage { + /** + * The unique identifier for the subscription type which is given by Intercom + */ _FinalStage subscriptionId(@NotNull String subscriptionId); } @@ -111,7 +117,7 @@ public Builder from(DetachSubscriptionFromContactRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -122,7 +128,7 @@ public SubscriptionIdStage contactId(@NotNull String contactId) { } /** - *

The unique identifier for the subscription type which is given by Intercom

+ * The unique identifier for the subscription type which is given by Intercom

The unique identifier for the subscription type which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java index 21a43e9..28fdb9e 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/FindContactRequest.java @@ -66,6 +66,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * id + */ _FinalStage contactId(@NotNull String contactId); Builder from(FindContactRequest other); @@ -91,7 +94,7 @@ public Builder from(FindContactRequest other) { } /** - *

id

+ * id

id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java index 91883da..9763506 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedCompaniesRequest.java @@ -94,6 +94,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ _FinalStage contactId(@NotNull String contactId); Builder from(ListAttachedCompaniesRequest other); @@ -102,10 +105,16 @@ public interface ContactIdStage { public interface _FinalStage { ListAttachedCompaniesRequest build(); + /** + *

The page of results to fetch. Defaults to first page

+ */ _FinalStage page(Optional page); _FinalStage page(Integer page); + /** + *

How many results to display per page. Defaults to 15

+ */ _FinalStage perPage(Optional perPage); _FinalStage perPage(Integer perPage); @@ -133,7 +142,7 @@ public Builder from(ListAttachedCompaniesRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -153,6 +162,9 @@ public _FinalStage perPage(Integer perPage) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @java.lang.Override @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public _FinalStage perPage(Optional perPage) { @@ -170,6 +182,9 @@ public _FinalStage page(Integer page) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @java.lang.Override @JsonSetter(value = "page", nulls = Nulls.SKIP) public _FinalStage page(Optional page) { diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java index e280e4a..ee21bea 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java @@ -66,6 +66,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ _FinalStage contactId(@NotNull String contactId); Builder from(ListAttachedSubscriptionsRequest other); @@ -91,7 +94,7 @@ public Builder from(ListAttachedSubscriptionsRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java index 5eab608..af15c20 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListContactsRequest.java @@ -112,6 +112,9 @@ public Builder from(ListContactsRequest other) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -123,6 +126,9 @@ public Builder page(Integer page) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public Builder perPage(Optional perPage) { this.perPage = perPage; @@ -134,6 +140,9 @@ public Builder perPage(Integer perPage) { return this; } + /** + *

String used to get the next page of conversations.

+ */ @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) public Builder startingAfter(Optional startingAfter) { this.startingAfter = startingAfter; diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java index 86c5f6b..961dbc5 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java @@ -67,6 +67,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ _FinalStage contactId(@NotNull String contactId); Builder from(ListSegmentsAttachedToContactRequest other); @@ -92,7 +95,7 @@ public Builder from(ListSegmentsAttachedToContactRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java index d7b518e..826d2d1 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ListTagsAttachedToContactRequest.java @@ -66,6 +66,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ _FinalStage contactId(@NotNull String contactId); Builder from(ListTagsAttachedToContactRequest other); @@ -91,7 +94,7 @@ public Builder from(ListTagsAttachedToContactRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java index d69c753..600f2ea 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/MergeContactsRequest.java @@ -77,12 +77,18 @@ public static LeadIdStage builder() { } public interface LeadIdStage { + /** + * The unique identifier for the contact to merge away from. Must be a lead. + */ ContactIdStage leadId(@NotNull String leadId); Builder from(MergeContactsRequest other); } public interface ContactIdStage { + /** + * The unique identifier for the contact to merge into. Must be a user. + */ _FinalStage contactId(@NotNull String contactId); } @@ -109,7 +115,7 @@ public Builder from(MergeContactsRequest other) { } /** - *

The unique identifier for the contact to merge away from. Must be a lead.

+ * The unique identifier for the contact to merge away from. Must be a lead.

The unique identifier for the contact to merge away from. Must be a lead.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -120,7 +126,7 @@ public ContactIdStage leadId(@NotNull String leadId) { } /** - *

The unique identifier for the contact to merge into. Must be a user.

+ * The unique identifier for the contact to merge into. Must be a user.

The unique identifier for the contact to merge into. Must be a user.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java index 9482a4b..b232367 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java @@ -66,6 +66,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * id + */ _FinalStage contactId(@NotNull String contactId); Builder from(UnarchiveContactRequest other); @@ -91,7 +94,7 @@ public Builder from(UnarchiveContactRequest other) { } /** - *

id

+ * id

id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java index 81d58f3..a0f7ea4 100644 --- a/src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java +++ b/src/main/java/com/intercom/api/resources/contacts/requests/UpdateContactRequest.java @@ -225,6 +225,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * id + */ _FinalStage contactId(@NotNull String contactId); Builder from(UpdateContactRequest other); @@ -233,46 +236,79 @@ public interface ContactIdStage { public interface _FinalStage { UpdateContactRequest build(); + /** + *

The role of the contact.

+ */ _FinalStage role(Optional role); _FinalStage role(String role); + /** + *

A unique identifier for the contact which is given to Intercom

+ */ _FinalStage externalId(Optional externalId); _FinalStage externalId(String externalId); + /** + *

The contacts email

+ */ _FinalStage email(Optional email); _FinalStage email(String email); + /** + *

The contacts phone

+ */ _FinalStage phone(Optional phone); _FinalStage phone(String phone); + /** + *

The contacts name

+ */ _FinalStage name(Optional name); _FinalStage name(String name); + /** + *

An image URL containing the avatar of a contact

+ */ _FinalStage avatar(Optional avatar); _FinalStage avatar(String avatar); + /** + *

The time specified for when a contact signed up

+ */ _FinalStage signedUpAt(Optional signedUpAt); _FinalStage signedUpAt(Integer signedUpAt); + /** + *

The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually)

+ */ _FinalStage lastSeenAt(Optional lastSeenAt); _FinalStage lastSeenAt(Integer lastSeenAt); + /** + *

The id of an admin that has been assigned account ownership of the contact

+ */ _FinalStage ownerId(Optional ownerId); _FinalStage ownerId(Integer ownerId); + /** + *

Whether the contact is unsubscribed from emails

+ */ _FinalStage unsubscribedFromEmails(Optional unsubscribedFromEmails); _FinalStage unsubscribedFromEmails(Boolean unsubscribedFromEmails); + /** + *

The custom attributes which are set for the contact

+ */ _FinalStage customAttributes(Optional> customAttributes); _FinalStage customAttributes(Map customAttributes); @@ -327,7 +363,7 @@ public Builder from(UpdateContactRequest other) { } /** - *

id

+ * id

id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -347,6 +383,9 @@ public _FinalStage customAttributes(Map customAttributes) { return this; } + /** + *

The custom attributes which are set for the contact

+ */ @java.lang.Override @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) public _FinalStage customAttributes(Optional> customAttributes) { @@ -364,6 +403,9 @@ public _FinalStage unsubscribedFromEmails(Boolean unsubscribedFromEmails) { return this; } + /** + *

Whether the contact is unsubscribed from emails

+ */ @java.lang.Override @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) public _FinalStage unsubscribedFromEmails(Optional unsubscribedFromEmails) { @@ -381,6 +423,9 @@ public _FinalStage ownerId(Integer ownerId) { return this; } + /** + *

The id of an admin that has been assigned account ownership of the contact

+ */ @java.lang.Override @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) public _FinalStage ownerId(Optional ownerId) { @@ -398,6 +443,9 @@ public _FinalStage lastSeenAt(Integer lastSeenAt) { return this; } + /** + *

The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually)

+ */ @java.lang.Override @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) public _FinalStage lastSeenAt(Optional lastSeenAt) { @@ -415,6 +463,9 @@ public _FinalStage signedUpAt(Integer signedUpAt) { return this; } + /** + *

The time specified for when a contact signed up

+ */ @java.lang.Override @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) public _FinalStage signedUpAt(Optional signedUpAt) { @@ -432,6 +483,9 @@ public _FinalStage avatar(String avatar) { return this; } + /** + *

An image URL containing the avatar of a contact

+ */ @java.lang.Override @JsonSetter(value = "avatar", nulls = Nulls.SKIP) public _FinalStage avatar(Optional avatar) { @@ -449,6 +503,9 @@ public _FinalStage name(String name) { return this; } + /** + *

The contacts name

+ */ @java.lang.Override @JsonSetter(value = "name", nulls = Nulls.SKIP) public _FinalStage name(Optional name) { @@ -466,6 +523,9 @@ public _FinalStage phone(String phone) { return this; } + /** + *

The contacts phone

+ */ @java.lang.Override @JsonSetter(value = "phone", nulls = Nulls.SKIP) public _FinalStage phone(Optional phone) { @@ -483,6 +543,9 @@ public _FinalStage email(String email) { return this; } + /** + *

The contacts email

+ */ @java.lang.Override @JsonSetter(value = "email", nulls = Nulls.SKIP) public _FinalStage email(Optional email) { @@ -500,6 +563,9 @@ public _FinalStage externalId(String externalId) { return this; } + /** + *

A unique identifier for the contact which is given to Intercom

+ */ @java.lang.Override @JsonSetter(value = "external_id", nulls = Nulls.SKIP) public _FinalStage externalId(Optional externalId) { @@ -517,6 +583,9 @@ public _FinalStage role(String role) { return this; } + /** + *

The role of the contact.

+ */ @java.lang.Override @JsonSetter(value = "role", nulls = Nulls.SKIP) public _FinalStage role(Optional role) { diff --git a/src/main/java/com/intercom/api/resources/contacts/types/Contact.java b/src/main/java/com/intercom/api/resources/contacts/types/Contact.java index f8d6037..3dba6ae 100644 --- a/src/main/java/com/intercom/api/resources/contacts/types/Contact.java +++ b/src/main/java/com/intercom/api/resources/contacts/types/Contact.java @@ -691,36 +691,60 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the contact which is given by Intercom. + */ WorkspaceIdStage id(@NotNull String id); Builder from(Contact other); } public interface WorkspaceIdStage { + /** + * The id of the workspace which the contact belongs to. + */ RoleStage workspaceId(@NotNull String workspaceId); } public interface RoleStage { + /** + * The role of the contact. + */ HasHardBouncedStage role(@NotNull String role); } public interface HasHardBouncedStage { + /** + * Whether the contact has had an email sent to them hard bounce. + */ MarkedEmailAsSpamStage hasHardBounced(boolean hasHardBounced); } public interface MarkedEmailAsSpamStage { + /** + * Whether the contact has marked an email sent to them as spam. + */ UnsubscribedFromEmailsStage markedEmailAsSpam(boolean markedEmailAsSpam); } public interface UnsubscribedFromEmailsStage { + /** + * Whether the contact is unsubscribed from emails. + */ CreatedAtStage unsubscribedFromEmails(boolean unsubscribedFromEmails); } public interface CreatedAtStage { + /** + * (UNIX timestamp) The time when the contact was created. + */ UpdatedAtStage createdAt(int createdAt); } public interface UpdatedAtStage { + /** + * (UNIX timestamp) The time when the contact was last updated. + */ LocationStage updatedAt(int updatedAt); } @@ -735,134 +759,233 @@ public interface SocialProfilesStage { public interface _FinalStage { Contact build(); + /** + *

The type of object.

+ */ _FinalStage type(Optional type); _FinalStage type(String type); + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ _FinalStage externalId(Optional externalId); _FinalStage externalId(String externalId); + /** + *

The contact's email.

+ */ _FinalStage email(Optional email); _FinalStage email(String email); + /** + *

The contact's email domain.

+ */ _FinalStage emailDomain(Optional emailDomain); _FinalStage emailDomain(String emailDomain); + /** + *

The contacts phone.

+ */ _FinalStage phone(Optional phone); _FinalStage phone(String phone); + /** + *

The contacts phone number normalized to the E164 format

+ */ _FinalStage formattedPhone(Optional formattedPhone); _FinalStage formattedPhone(String formattedPhone); + /** + *

The contacts name.

+ */ _FinalStage name(Optional name); _FinalStage name(String name); + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ _FinalStage ownerId(Optional ownerId); _FinalStage ownerId(Integer ownerId); + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ _FinalStage signedUpAt(Optional signedUpAt); _FinalStage signedUpAt(Integer signedUpAt); + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ _FinalStage lastSeenAt(Optional lastSeenAt); _FinalStage lastSeenAt(Integer lastSeenAt); + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ _FinalStage lastRepliedAt(Optional lastRepliedAt); _FinalStage lastRepliedAt(Integer lastRepliedAt); + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ _FinalStage lastContactedAt(Optional lastContactedAt); _FinalStage lastContactedAt(Integer lastContactedAt); + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt); _FinalStage lastEmailOpenedAt(Integer lastEmailOpenedAt); + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt); _FinalStage lastEmailClickedAt(Integer lastEmailClickedAt); + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ _FinalStage languageOverride(Optional languageOverride); _FinalStage languageOverride(String languageOverride); + /** + *

The name of the browser which the contact is using.

+ */ _FinalStage browser(Optional browser); _FinalStage browser(String browser); + /** + *

The version of the browser which the contact is using.

+ */ _FinalStage browserVersion(Optional browserVersion); _FinalStage browserVersion(String browserVersion); + /** + *

The language set by the browser which the contact is using.

+ */ _FinalStage browserLanguage(Optional browserLanguage); _FinalStage browserLanguage(String browserLanguage); + /** + *

The operating system which the contact is using.

+ */ _FinalStage os(Optional os); _FinalStage os(String os); + /** + *

The name of the Android app which the contact is using.

+ */ _FinalStage androidAppName(Optional androidAppName); _FinalStage androidAppName(String androidAppName); + /** + *

The version of the Android app which the contact is using.

+ */ _FinalStage androidAppVersion(Optional androidAppVersion); _FinalStage androidAppVersion(String androidAppVersion); + /** + *

The Android device which the contact is using.

+ */ _FinalStage androidDevice(Optional androidDevice); _FinalStage androidDevice(String androidDevice); + /** + *

The version of the Android OS which the contact is using.

+ */ _FinalStage androidOsVersion(Optional androidOsVersion); _FinalStage androidOsVersion(String androidOsVersion); + /** + *

The version of the Android SDK which the contact is using.

+ */ _FinalStage androidSdkVersion(Optional androidSdkVersion); _FinalStage androidSdkVersion(String androidSdkVersion); + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ _FinalStage androidLastSeenAt(Optional androidLastSeenAt); _FinalStage androidLastSeenAt(Integer androidLastSeenAt); + /** + *

The name of the iOS app which the contact is using.

+ */ _FinalStage iosAppName(Optional iosAppName); _FinalStage iosAppName(String iosAppName); + /** + *

The version of the iOS app which the contact is using.

+ */ _FinalStage iosAppVersion(Optional iosAppVersion); _FinalStage iosAppVersion(String iosAppVersion); + /** + *

The iOS device which the contact is using.

+ */ _FinalStage iosDevice(Optional iosDevice); _FinalStage iosDevice(String iosDevice); + /** + *

The version of iOS which the contact is using.

+ */ _FinalStage iosOsVersion(Optional iosOsVersion); _FinalStage iosOsVersion(String iosOsVersion); + /** + *

The version of the iOS SDK which the contact is using.

+ */ _FinalStage iosSdkVersion(Optional iosSdkVersion); _FinalStage iosSdkVersion(String iosSdkVersion); + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ _FinalStage iosLastSeenAt(Optional iosLastSeenAt); _FinalStage iosLastSeenAt(Integer iosLastSeenAt); + /** + *

The custom attributes which are set for the contact.

+ */ _FinalStage customAttributes(Optional> customAttributes); _FinalStage customAttributes(Map customAttributes); + /** + *

An image URL containing the avatar of a contact.

+ */ _FinalStage avatar(Optional avatar); _FinalStage avatar(String avatar); @@ -1042,7 +1165,7 @@ public Builder from(Contact other) { } /** - *

The unique identifier for the contact which is given by Intercom.

+ * The unique identifier for the contact which is given by Intercom.

The unique identifier for the contact which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1053,7 +1176,7 @@ public WorkspaceIdStage id(@NotNull String id) { } /** - *

The id of the workspace which the contact belongs to.

+ * The id of the workspace which the contact belongs to.

The id of the workspace which the contact belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1064,7 +1187,7 @@ public RoleStage workspaceId(@NotNull String workspaceId) { } /** - *

The role of the contact.

+ * The role of the contact.

The role of the contact.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1075,7 +1198,7 @@ public HasHardBouncedStage role(@NotNull String role) { } /** - *

Whether the contact has had an email sent to them hard bounce.

+ * Whether the contact has had an email sent to them hard bounce.

Whether the contact has had an email sent to them hard bounce.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1086,7 +1209,7 @@ public MarkedEmailAsSpamStage hasHardBounced(boolean hasHardBounced) { } /** - *

Whether the contact has marked an email sent to them as spam.

+ * Whether the contact has marked an email sent to them as spam.

Whether the contact has marked an email sent to them as spam.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1097,7 +1220,7 @@ public UnsubscribedFromEmailsStage markedEmailAsSpam(boolean markedEmailAsSpam) } /** - *

Whether the contact is unsubscribed from emails.

+ * Whether the contact is unsubscribed from emails.

Whether the contact is unsubscribed from emails.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1108,7 +1231,7 @@ public CreatedAtStage unsubscribedFromEmails(boolean unsubscribedFromEmails) { } /** - *

(UNIX timestamp) The time when the contact was created.

+ * (UNIX timestamp) The time when the contact was created.

(UNIX timestamp) The time when the contact was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1119,7 +1242,7 @@ public UpdatedAtStage createdAt(int createdAt) { } /** - *

(UNIX timestamp) The time when the contact was last updated.

+ * (UNIX timestamp) The time when the contact was last updated.

(UNIX timestamp) The time when the contact was last updated.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1192,6 +1315,9 @@ public _FinalStage avatar(String avatar) { return this; } + /** + *

An image URL containing the avatar of a contact.

+ */ @java.lang.Override @JsonSetter(value = "avatar", nulls = Nulls.SKIP) public _FinalStage avatar(Optional avatar) { @@ -1209,6 +1335,9 @@ public _FinalStage customAttributes(Map customAttributes) { return this; } + /** + *

The custom attributes which are set for the contact.

+ */ @java.lang.Override @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) public _FinalStage customAttributes(Optional> customAttributes) { @@ -1226,6 +1355,9 @@ public _FinalStage iosLastSeenAt(Integer iosLastSeenAt) { return this; } + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ @java.lang.Override @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) public _FinalStage iosLastSeenAt(Optional iosLastSeenAt) { @@ -1243,6 +1375,9 @@ public _FinalStage iosSdkVersion(String iosSdkVersion) { return this; } + /** + *

The version of the iOS SDK which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) public _FinalStage iosSdkVersion(Optional iosSdkVersion) { @@ -1260,6 +1395,9 @@ public _FinalStage iosOsVersion(String iosOsVersion) { return this; } + /** + *

The version of iOS which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) public _FinalStage iosOsVersion(Optional iosOsVersion) { @@ -1277,6 +1415,9 @@ public _FinalStage iosDevice(String iosDevice) { return this; } + /** + *

The iOS device which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) public _FinalStage iosDevice(Optional iosDevice) { @@ -1294,6 +1435,9 @@ public _FinalStage iosAppVersion(String iosAppVersion) { return this; } + /** + *

The version of the iOS app which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) public _FinalStage iosAppVersion(Optional iosAppVersion) { @@ -1311,6 +1455,9 @@ public _FinalStage iosAppName(String iosAppName) { return this; } + /** + *

The name of the iOS app which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) public _FinalStage iosAppName(Optional iosAppName) { @@ -1328,6 +1475,9 @@ public _FinalStage androidLastSeenAt(Integer androidLastSeenAt) { return this; } + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ @java.lang.Override @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) public _FinalStage androidLastSeenAt(Optional androidLastSeenAt) { @@ -1345,6 +1495,9 @@ public _FinalStage androidSdkVersion(String androidSdkVersion) { return this; } + /** + *

The version of the Android SDK which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) public _FinalStage androidSdkVersion(Optional androidSdkVersion) { @@ -1362,6 +1515,9 @@ public _FinalStage androidOsVersion(String androidOsVersion) { return this; } + /** + *

The version of the Android OS which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) public _FinalStage androidOsVersion(Optional androidOsVersion) { @@ -1379,6 +1535,9 @@ public _FinalStage androidDevice(String androidDevice) { return this; } + /** + *

The Android device which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "android_device", nulls = Nulls.SKIP) public _FinalStage androidDevice(Optional androidDevice) { @@ -1396,6 +1555,9 @@ public _FinalStage androidAppVersion(String androidAppVersion) { return this; } + /** + *

The version of the Android app which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) public _FinalStage androidAppVersion(Optional androidAppVersion) { @@ -1413,6 +1575,9 @@ public _FinalStage androidAppName(String androidAppName) { return this; } + /** + *

The name of the Android app which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) public _FinalStage androidAppName(Optional androidAppName) { @@ -1430,6 +1595,9 @@ public _FinalStage os(String os) { return this; } + /** + *

The operating system which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "os", nulls = Nulls.SKIP) public _FinalStage os(Optional os) { @@ -1447,6 +1615,9 @@ public _FinalStage browserLanguage(String browserLanguage) { return this; } + /** + *

The language set by the browser which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) public _FinalStage browserLanguage(Optional browserLanguage) { @@ -1464,6 +1635,9 @@ public _FinalStage browserVersion(String browserVersion) { return this; } + /** + *

The version of the browser which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) public _FinalStage browserVersion(Optional browserVersion) { @@ -1481,6 +1655,9 @@ public _FinalStage browser(String browser) { return this; } + /** + *

The name of the browser which the contact is using.

+ */ @java.lang.Override @JsonSetter(value = "browser", nulls = Nulls.SKIP) public _FinalStage browser(Optional browser) { @@ -1498,6 +1675,9 @@ public _FinalStage languageOverride(String languageOverride) { return this; } + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ @java.lang.Override @JsonSetter(value = "language_override", nulls = Nulls.SKIP) public _FinalStage languageOverride(Optional languageOverride) { @@ -1515,6 +1695,9 @@ public _FinalStage lastEmailClickedAt(Integer lastEmailClickedAt) { return this; } + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ @java.lang.Override @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) public _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt) { @@ -1532,6 +1715,9 @@ public _FinalStage lastEmailOpenedAt(Integer lastEmailOpenedAt) { return this; } + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ @java.lang.Override @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) public _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt) { @@ -1549,6 +1735,9 @@ public _FinalStage lastContactedAt(Integer lastContactedAt) { return this; } + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ @java.lang.Override @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) public _FinalStage lastContactedAt(Optional lastContactedAt) { @@ -1566,6 +1755,9 @@ public _FinalStage lastRepliedAt(Integer lastRepliedAt) { return this; } + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ @java.lang.Override @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) public _FinalStage lastRepliedAt(Optional lastRepliedAt) { @@ -1583,6 +1775,9 @@ public _FinalStage lastSeenAt(Integer lastSeenAt) { return this; } + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ @java.lang.Override @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) public _FinalStage lastSeenAt(Optional lastSeenAt) { @@ -1600,6 +1795,9 @@ public _FinalStage signedUpAt(Integer signedUpAt) { return this; } + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ @java.lang.Override @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) public _FinalStage signedUpAt(Optional signedUpAt) { @@ -1617,6 +1815,9 @@ public _FinalStage ownerId(Integer ownerId) { return this; } + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ @java.lang.Override @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) public _FinalStage ownerId(Optional ownerId) { @@ -1634,6 +1835,9 @@ public _FinalStage name(String name) { return this; } + /** + *

The contacts name.

+ */ @java.lang.Override @JsonSetter(value = "name", nulls = Nulls.SKIP) public _FinalStage name(Optional name) { @@ -1651,6 +1855,9 @@ public _FinalStage formattedPhone(String formattedPhone) { return this; } + /** + *

The contacts phone number normalized to the E164 format

+ */ @java.lang.Override @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) public _FinalStage formattedPhone(Optional formattedPhone) { @@ -1668,6 +1875,9 @@ public _FinalStage phone(String phone) { return this; } + /** + *

The contacts phone.

+ */ @java.lang.Override @JsonSetter(value = "phone", nulls = Nulls.SKIP) public _FinalStage phone(Optional phone) { @@ -1685,6 +1895,9 @@ public _FinalStage emailDomain(String emailDomain) { return this; } + /** + *

The contact's email domain.

+ */ @java.lang.Override @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) public _FinalStage emailDomain(Optional emailDomain) { @@ -1702,6 +1915,9 @@ public _FinalStage email(String email) { return this; } + /** + *

The contact's email.

+ */ @java.lang.Override @JsonSetter(value = "email", nulls = Nulls.SKIP) public _FinalStage email(Optional email) { @@ -1719,6 +1935,9 @@ public _FinalStage externalId(String externalId) { return this; } + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ @java.lang.Override @JsonSetter(value = "external_id", nulls = Nulls.SKIP) public _FinalStage externalId(Optional externalId) { @@ -1736,6 +1955,9 @@ public _FinalStage type(String type) { return this; } + /** + *

The type of object.

+ */ @java.lang.Override @JsonSetter(value = "type", nulls = Nulls.SKIP) public _FinalStage type(Optional type) { diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java index 1fba65c..840efc5 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/AttachContactToConversationRequest.java @@ -101,6 +101,9 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The identifier for the conversation as given by Intercom. + */ _FinalStage conversationId(@NotNull String conversationId); Builder from(AttachContactToConversationRequest other); @@ -109,6 +112,9 @@ public interface ConversationIdStage { public interface _FinalStage { AttachContactToConversationRequest build(); + /** + *

The id of the admin who is adding the new participant.

+ */ _FinalStage adminId(Optional adminId); _FinalStage adminId(String adminId); @@ -140,7 +146,7 @@ public Builder from(AttachContactToConversationRequest other) { } /** - *

The identifier for the conversation as given by Intercom.

+ * The identifier for the conversation as given by Intercom.

The identifier for the conversation as given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -173,6 +179,9 @@ public _FinalStage adminId(String adminId) { return this; } + /** + *

The id of the admin who is adding the new participant.

+ */ @java.lang.Override @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) public _FinalStage adminId(Optional adminId) { @@ -202,6 +211,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((IntercomUserId) this.value); @@ -336,6 +346,9 @@ public static UserIdStage builder() { } public interface UserIdStage { + /** + * The external_id you have defined for the contact who is being added as a participant. + */ _FinalStage userId(@NotNull String userId); Builder from(UserId other); @@ -368,7 +381,7 @@ public Builder from(UserId other) { } /** - *

The external_id you have defined for the contact who is being added as a participant.

+ * The external_id you have defined for the contact who is being added as a participant.

The external_id you have defined for the contact who is being added as a participant.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -457,6 +470,9 @@ public static EmailStage builder() { } public interface EmailStage { + /** + * The email you have defined for the contact who is being added as a participant. + */ _FinalStage email(@NotNull String email); Builder from(Customer_ other); @@ -489,7 +505,7 @@ public Builder from(Customer_ other) { } /** - *

The email you have defined for the contact who is being added as a participant.

+ * The email you have defined for the contact who is being added as a participant.

The email you have defined for the contact who is being added as a participant.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -580,6 +596,9 @@ public static IntercomUserIdStage builder() { } public interface IntercomUserIdStage { + /** + * The identifier for the contact as given by Intercom. + */ _FinalStage intercomUserId(@NotNull String intercomUserId); Builder from(IntercomUserId other); @@ -612,7 +631,7 @@ public Builder from(IntercomUserId other) { } /** - *

The identifier for the contact as given by Intercom.

+ * The identifier for the contact as given by Intercom.

The identifier for the contact as given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java index c584339..8225e4c 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/AutoAssignConversationRequest.java @@ -66,6 +66,9 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The identifier for the conversation as given by Intercom. + */ _FinalStage conversationId(@NotNull String conversationId); Builder from(AutoAssignConversationRequest other); @@ -91,7 +94,7 @@ public Builder from(AutoAssignConversationRequest other) { } /** - *

The identifier for the conversation as given by Intercom.

+ * The identifier for the conversation as given by Intercom.

The identifier for the conversation as given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override 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 2b578ad..2affc19 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 @@ -94,12 +94,18 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The id of the conversation to target + */ TicketTypeIdStage conversationId(@NotNull String conversationId); Builder from(ConvertConversationToTicketRequest other); } public interface TicketTypeIdStage { + /** + * The ID of the type of ticket you want to convert the conversation to + */ _FinalStage ticketTypeId(@NotNull String ticketTypeId); } @@ -133,7 +139,7 @@ public Builder from(ConvertConversationToTicketRequest other) { } /** - *

The id of the conversation to target

+ * The id of the conversation to target

The id of the conversation to target

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -144,7 +150,7 @@ public TicketTypeIdStage conversationId(@NotNull String conversationId) { } /** - *

The ID of the type of ticket you want to convert the conversation to

+ * The ID of the type of ticket you want to convert the conversation to

The ID of the type of ticket you want to convert the conversation to

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java index b05af58..c1986b0 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/CreateConversationRequest.java @@ -96,12 +96,18 @@ public interface FromStage { } public interface BodyStage { + /** + * The content of the message. HTML is not supported. + */ _FinalStage body(@NotNull String body); } public interface _FinalStage { CreateConversationRequest build(); + /** + *

The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom.

+ */ _FinalStage createdAt(Optional createdAt); _FinalStage createdAt(Integer createdAt); @@ -136,7 +142,7 @@ public BodyStage from(@NotNull From from) { } /** - *

The content of the message. HTML is not supported.

+ * The content of the message. HTML is not supported.

The content of the message. HTML is not supported.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -156,6 +162,9 @@ public _FinalStage createdAt(Integer createdAt) { return this; } + /** + *

The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom.

+ */ @java.lang.Override @JsonSetter(value = "created_at", nulls = Nulls.SKIP) public _FinalStage createdAt(Optional createdAt) { @@ -230,12 +239,18 @@ public static TypeStage builder() { } public interface TypeStage { + /** + * The role associated to the contact - user or lead. + */ IdStage type(@NotNull Type type); Builder from(From other); } public interface IdStage { + /** + * The identifier for the contact which is given by Intercom. + */ _FinalStage id(@NotNull String id); } @@ -262,7 +277,7 @@ public Builder from(From other) { } /** - *

The role associated to the contact - user or lead.

+ * The role associated to the contact - user or lead.

The role associated to the contact - user or lead.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -273,7 +288,7 @@ public IdStage type(@NotNull Type type) { } /** - *

The identifier for the contact which is given by Intercom.

+ * The identifier for the contact which is given by Intercom.

The identifier for the contact which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java index 7c0881a..ec9b6f3 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/DetachContactFromConversationRequest.java @@ -92,16 +92,25 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The identifier for the conversation as given by Intercom. + */ ContactIdStage conversationId(@NotNull String conversationId); Builder from(DetachContactFromConversationRequest other); } public interface ContactIdStage { + /** + * The identifier for the contact as given by Intercom. + */ AdminIdStage contactId(@NotNull String contactId); } public interface AdminIdStage { + /** + * The `id` of the admin who is performing the action. + */ _FinalStage adminId(@NotNull String adminId); } @@ -131,7 +140,7 @@ public Builder from(DetachContactFromConversationRequest other) { } /** - *

The identifier for the conversation as given by Intercom.

+ * The identifier for the conversation as given by Intercom.

The identifier for the conversation as given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -142,7 +151,7 @@ public ContactIdStage conversationId(@NotNull String conversationId) { } /** - *

The identifier for the contact as given by Intercom.

+ * The identifier for the contact as given by Intercom.

The identifier for the contact as given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -153,7 +162,7 @@ public AdminIdStage contactId(@NotNull String contactId) { } /** - *

The id of the admin who is performing the action.

+ * The `id` of the admin who is performing the action.

The id of the admin who is performing the action.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java index 044ce4d..dd75ae6 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/FindConversationRequest.java @@ -80,6 +80,9 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The id of the conversation to target + */ _FinalStage conversationId(@NotNull String conversationId); Builder from(FindConversationRequest other); @@ -88,6 +91,9 @@ public interface ConversationIdStage { public interface _FinalStage { FindConversationRequest build(); + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ _FinalStage displayAs(Optional displayAs); _FinalStage displayAs(String displayAs); @@ -112,7 +118,7 @@ public Builder from(FindConversationRequest other) { } /** - *

The id of the conversation to target

+ * The id of the conversation to target

The id of the conversation to target

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -132,6 +138,9 @@ public _FinalStage displayAs(String displayAs) { return this; } + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ @java.lang.Override @JsonSetter(value = "display_as", nulls = Nulls.SKIP) public _FinalStage displayAs(Optional displayAs) { diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java index ee840bb..79ba7bd 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ListConversationsRequest.java @@ -95,6 +95,9 @@ public Builder from(ListConversationsRequest other) { return this; } + /** + *

How many results per page

+ */ @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public Builder perPage(Optional perPage) { this.perPage = perPage; @@ -106,6 +109,9 @@ public Builder perPage(Integer perPage) { return this; } + /** + *

String used to get the next page of conversations.

+ */ @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) public Builder startingAfter(Optional startingAfter) { this.startingAfter = startingAfter; diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java index 7079419..702e2e2 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ManageConversationPartsRequest.java @@ -76,6 +76,9 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The identifier for the conversation as given by Intercom. + */ BodyStage conversationId(@NotNull String conversationId); Builder from(ManageConversationPartsRequest other); @@ -108,7 +111,7 @@ public Builder from(ManageConversationPartsRequest other) { } /** - *

The identifier for the conversation as given by Intercom.

+ * The identifier for the conversation as given by Intercom.

The identifier for the conversation as given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java index 43c87d9..6a71fdf 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/ReplyToConversationRequest.java @@ -76,6 +76,9 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + */ BodyStage conversationId(@NotNull String conversationId); Builder from(ReplyToConversationRequest other); @@ -108,7 +111,7 @@ public Builder from(ReplyToConversationRequest other) { } /** - *

The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation

+ * The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation

The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java index 3157f99..76ad55d 100644 --- a/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/conversations/requests/UpdateConversationRequest.java @@ -106,6 +106,9 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * The id of the conversation to target + */ _FinalStage conversationId(@NotNull String conversationId); Builder from(UpdateConversationRequest other); @@ -114,10 +117,16 @@ public interface ConversationIdStage { public interface _FinalStage { UpdateConversationRequest build(); + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ _FinalStage displayAs(Optional displayAs); _FinalStage displayAs(String displayAs); + /** + *

Mark a conversation as read within Intercom.

+ */ _FinalStage read(Optional read); _FinalStage read(Boolean read); @@ -152,7 +161,7 @@ public Builder from(UpdateConversationRequest other) { } /** - *

The id of the conversation to target

+ * The id of the conversation to target

The id of the conversation to target

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -185,6 +194,9 @@ public _FinalStage read(Boolean read) { return this; } + /** + *

Mark a conversation as read within Intercom.

+ */ @java.lang.Override @JsonSetter(value = "read", nulls = Nulls.SKIP) public _FinalStage read(Optional read) { @@ -202,6 +214,9 @@ public _FinalStage displayAs(String displayAs) { return this; } + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ @java.lang.Override @JsonSetter(value = "display_as", nulls = Nulls.SKIP) public _FinalStage displayAs(Optional displayAs) { diff --git a/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java b/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java index cd10317..8b01a01 100644 --- a/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java +++ b/src/main/java/com/intercom/api/resources/conversations/types/Conversation.java @@ -399,28 +399,46 @@ public static IdStage builder() { } public interface IdStage { + /** + * The id representing the conversation. + */ CreatedAtStage id(@NotNull String id); Builder from(Conversation other); } public interface CreatedAtStage { + /** + * The time the conversation was created. + */ UpdatedAtStage createdAt(int createdAt); } public interface UpdatedAtStage { + /** + * The last time the conversation was updated. + */ OpenStage updatedAt(int updatedAt); } public interface OpenStage { + /** + * Indicates whether a conversation is open (true) or closed (false). + */ StateStage open(boolean open); } public interface StateStage { + /** + * Can be set to "open", "closed" or "snoozed". + */ ReadStage state(@NotNull State state); } public interface ReadStage { + /** + * Indicates whether a conversation has been read. + */ SourceStage read(boolean read); } @@ -439,30 +457,51 @@ public interface TeammatesStage { public interface _FinalStage { Conversation build(); + /** + *

Always conversation.

+ */ _FinalStage type(Optional type); _FinalStage type(String type); + /** + *

The title given to the conversation.

+ */ _FinalStage title(Optional title); _FinalStage title(String title); + /** + *

The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin.

+ */ _FinalStage waitingSince(Optional waitingSince); _FinalStage waitingSince(Integer waitingSince); + /** + *

If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time.

+ */ _FinalStage snoozedUntil(Optional snoozedUntil); _FinalStage snoozedUntil(Integer snoozedUntil); + /** + *

If marked as priority, it will return priority or else not_priority.

+ */ _FinalStage priority(Optional priority); _FinalStage priority(Priority priority); + /** + *

The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null.

+ */ _FinalStage adminAssigneeId(Optional adminAssigneeId); _FinalStage adminAssigneeId(Integer adminAssigneeId); + /** + *

The id of the team assigned to the conversation. If it's not assigned to a team it will return null.

+ */ _FinalStage teamAssigneeId(Optional teamAssigneeId); _FinalStage teamAssigneeId(String teamAssigneeId); @@ -501,6 +540,9 @@ public interface _FinalStage { _FinalStage linkedObjects(LinkedObjectList linkedObjects); + /** + *

Indicates whether the AI Agent participated in the conversation.

+ */ _FinalStage aiAgentParticipated(Optional aiAgentParticipated); _FinalStage aiAgentParticipated(Boolean aiAgentParticipated); @@ -611,7 +653,7 @@ public Builder from(Conversation other) { } /** - *

The id representing the conversation.

+ * The id representing the conversation.

The id representing the conversation.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -622,7 +664,7 @@ public CreatedAtStage id(@NotNull String id) { } /** - *

The time the conversation was created.

+ * The time the conversation was created.

The time the conversation was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -633,7 +675,7 @@ public UpdatedAtStage createdAt(int createdAt) { } /** - *

The last time the conversation was updated.

+ * The last time the conversation was updated.

The last time the conversation was updated.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -644,7 +686,7 @@ public OpenStage updatedAt(int updatedAt) { } /** - *

Indicates whether a conversation is open (true) or closed (false).

+ * Indicates whether a conversation is open (true) or closed (false).

Indicates whether a conversation is open (true) or closed (false).

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -655,7 +697,7 @@ public StateStage open(boolean open) { } /** - *

Can be set to "open", "closed" or "snoozed".

+ * Can be set to "open", "closed" or "snoozed".

Can be set to "open", "closed" or "snoozed".

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -666,7 +708,7 @@ public ReadStage state(@NotNull State state) { } /** - *

Indicates whether a conversation has been read.

+ * Indicates whether a conversation has been read.

Indicates whether a conversation has been read.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -720,6 +762,9 @@ public _FinalStage aiAgentParticipated(Boolean aiAgentParticipated) { return this; } + /** + *

Indicates whether the AI Agent participated in the conversation.

+ */ @java.lang.Override @JsonSetter(value = "ai_agent_participated", nulls = Nulls.SKIP) public _FinalStage aiAgentParticipated(Optional aiAgentParticipated) { @@ -848,6 +893,9 @@ public _FinalStage teamAssigneeId(String teamAssigneeId) { return this; } + /** + *

The id of the team assigned to the conversation. If it's not assigned to a team it will return null.

+ */ @java.lang.Override @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) public _FinalStage teamAssigneeId(Optional teamAssigneeId) { @@ -865,6 +913,9 @@ public _FinalStage adminAssigneeId(Integer adminAssigneeId) { return this; } + /** + *

The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null.

+ */ @java.lang.Override @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) public _FinalStage adminAssigneeId(Optional adminAssigneeId) { @@ -882,6 +933,9 @@ public _FinalStage priority(Priority priority) { return this; } + /** + *

If marked as priority, it will return priority or else not_priority.

+ */ @java.lang.Override @JsonSetter(value = "priority", nulls = Nulls.SKIP) public _FinalStage priority(Optional priority) { @@ -899,6 +953,9 @@ public _FinalStage snoozedUntil(Integer snoozedUntil) { return this; } + /** + *

If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time.

+ */ @java.lang.Override @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) public _FinalStage snoozedUntil(Optional snoozedUntil) { @@ -916,6 +973,9 @@ public _FinalStage waitingSince(Integer waitingSince) { return this; } + /** + *

The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin.

+ */ @java.lang.Override @JsonSetter(value = "waiting_since", nulls = Nulls.SKIP) public _FinalStage waitingSince(Optional waitingSince) { @@ -933,6 +993,9 @@ public _FinalStage title(String title) { return this; } + /** + *

The title given to the conversation.

+ */ @java.lang.Override @JsonSetter(value = "title", nulls = Nulls.SKIP) public _FinalStage title(Optional title) { @@ -950,6 +1013,9 @@ public _FinalStage type(String type) { return this; } + /** + *

Always conversation.

+ */ @java.lang.Override @JsonSetter(value = "type", nulls = Nulls.SKIP) public _FinalStage type(Optional type) { diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java deleted file mode 100644 index a3ab9fd..0000000 --- a/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.intercom.api.resources.customchannelevents; - -import com.intercom.api.core.ClientOptions; -import com.intercom.api.core.RequestOptions; -import java.util.concurrent.CompletableFuture; - -public class AsyncCustomChannelEventsClient { - protected final ClientOptions clientOptions; - - private final AsyncRawCustomChannelEventsClient rawClient; - - public AsyncCustomChannelEventsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawCustomChannelEventsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawCustomChannelEventsClient withRawResponse() { - return this.rawClient; - } - - public CompletableFuture notifyAttributeCollected() { - return this.rawClient.notifyAttributeCollected().thenApply(response -> response.body()); - } - - public CompletableFuture notifyAttributeCollected(RequestOptions requestOptions) { - return this.rawClient.notifyAttributeCollected(requestOptions).thenApply(response -> response.body()); - } - - public CompletableFuture notifyNewMessage() { - return this.rawClient.notifyNewMessage().thenApply(response -> response.body()); - } - - public CompletableFuture notifyNewMessage(RequestOptions requestOptions) { - return this.rawClient.notifyNewMessage(requestOptions).thenApply(response -> response.body()); - } - - public CompletableFuture notifyNewConversation() { - return this.rawClient.notifyNewConversation().thenApply(response -> response.body()); - } - - public CompletableFuture notifyNewConversation(RequestOptions requestOptions) { - return this.rawClient.notifyNewConversation(requestOptions).thenApply(response -> response.body()); - } - - public CompletableFuture notifyQuickReplySelected() { - return this.rawClient.notifyQuickReplySelected().thenApply(response -> response.body()); - } - - public CompletableFuture notifyQuickReplySelected(RequestOptions requestOptions) { - return this.rawClient.notifyQuickReplySelected(requestOptions).thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java deleted file mode 100644 index d6abd88..0000000 --- a/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.intercom.api.resources.customchannelevents; - -import com.intercom.api.core.ClientOptions; -import com.intercom.api.core.RequestOptions; - -public class CustomChannelEventsClient { - protected final ClientOptions clientOptions; - - private final RawCustomChannelEventsClient rawClient; - - public CustomChannelEventsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawCustomChannelEventsClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawCustomChannelEventsClient withRawResponse() { - return this.rawClient; - } - - public void notifyAttributeCollected() { - this.rawClient.notifyAttributeCollected().body(); - } - - public void notifyAttributeCollected(RequestOptions requestOptions) { - this.rawClient.notifyAttributeCollected(requestOptions).body(); - } - - public void notifyNewMessage() { - this.rawClient.notifyNewMessage().body(); - } - - public void notifyNewMessage(RequestOptions requestOptions) { - this.rawClient.notifyNewMessage(requestOptions).body(); - } - - public void notifyNewConversation() { - this.rawClient.notifyNewConversation().body(); - } - - public void notifyNewConversation(RequestOptions requestOptions) { - this.rawClient.notifyNewConversation(requestOptions).body(); - } - - public void notifyQuickReplySelected() { - this.rawClient.notifyQuickReplySelected().body(); - } - - public void notifyQuickReplySelected(RequestOptions requestOptions) { - this.rawClient.notifyQuickReplySelected(requestOptions).body(); - } -} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java deleted file mode 100644 index 5b9dd42..0000000 --- a/src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.intercom.api.resources.customchannelevents; - -import com.intercom.api.core.ClientOptions; -import com.intercom.api.core.IntercomApiException; -import com.intercom.api.core.IntercomException; -import com.intercom.api.core.IntercomHttpResponse; -import com.intercom.api.core.ObjectMappers; -import com.intercom.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawCustomChannelEventsClient { - protected final ClientOptions clientOptions; - - public RawCustomChannelEventsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - public IntercomHttpResponse notifyAttributeCollected() { - return notifyAttributeCollected(null); - } - - public IntercomHttpResponse notifyAttributeCollected(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("custom_channel_events/notify_attribute_collected") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new IntercomHttpResponse<>(null, response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new IntercomException("Network error executing HTTP request", e); - } - } - - public IntercomHttpResponse notifyNewMessage() { - return notifyNewMessage(null); - } - - public IntercomHttpResponse notifyNewMessage(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("custom_channel_events/notify_new_message") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new IntercomHttpResponse<>(null, response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new IntercomException("Network error executing HTTP request", e); - } - } - - public IntercomHttpResponse notifyNewConversation() { - return notifyNewConversation(null); - } - - public IntercomHttpResponse notifyNewConversation(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("custom_channel_events/notify_new_conversation") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new IntercomHttpResponse<>(null, response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new IntercomException("Network error executing HTTP request", e); - } - } - - public IntercomHttpResponse notifyQuickReplySelected() { - return notifyQuickReplySelected(null); - } - - public IntercomHttpResponse notifyQuickReplySelected(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("custom_channel_events/notify_quick_reply_selected") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new IntercomHttpResponse<>(null, response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new IntercomException("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java b/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java index 1707fc2..fb47c39 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java @@ -139,30 +139,48 @@ public static NameStage builder() { } public interface NameStage { + /** + * The name of the data attribute. + */ ModelStage name(@NotNull String name); Builder from(CreateDataAttributeRequest other); } public interface ModelStage { + /** + * The model that the data attribute belongs to. + */ DataTypeStage model(@NotNull Model model); } public interface DataTypeStage { + /** + * The type of data stored for this attribute. + */ _FinalStage dataType(@NotNull DataType dataType); } public interface _FinalStage { CreateDataAttributeRequest build(); + /** + *

The readable description you see in the UI for the attribute.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ _FinalStage options(Optional> options); _FinalStage options(List options); + /** + *

Can this attribute be updated by the Messenger

+ */ _FinalStage messengerWritable(Optional messengerWritable); _FinalStage messengerWritable(Boolean messengerWritable); @@ -199,7 +217,7 @@ public Builder from(CreateDataAttributeRequest other) { } /** - *

The name of the data attribute.

+ * The name of the data attribute.

The name of the data attribute.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -210,7 +228,7 @@ public ModelStage name(@NotNull String name) { } /** - *

The model that the data attribute belongs to.

+ * The model that the data attribute belongs to.

The model that the data attribute belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -221,7 +239,7 @@ public DataTypeStage model(@NotNull Model model) { } /** - *

The type of data stored for this attribute.

+ * The type of data stored for this attribute.

The type of data stored for this attribute.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -241,6 +259,9 @@ public _FinalStage messengerWritable(Boolean messengerWritable) { return this; } + /** + *

Can this attribute be updated by the Messenger

+ */ @java.lang.Override @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) public _FinalStage messengerWritable(Optional messengerWritable) { @@ -258,6 +279,9 @@ public _FinalStage options(List options) { return this; } + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ @java.lang.Override @JsonSetter(value = "options", nulls = Nulls.SKIP) public _FinalStage options(Optional> options) { @@ -275,6 +299,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The readable description you see in the UI for the attribute.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { diff --git a/src/main/java/com/intercom/api/resources/dataattributes/requests/ListDataAttributesRequest.java b/src/main/java/com/intercom/api/resources/dataattributes/requests/ListDataAttributesRequest.java index 210ecb7..c44658b 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/requests/ListDataAttributesRequest.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/requests/ListDataAttributesRequest.java @@ -98,6 +98,9 @@ public Builder from(ListDataAttributesRequest other) { return this; } + /** + *

Specify the data attribute model to return.

+ */ @JsonSetter(value = "model", nulls = Nulls.SKIP) public Builder model(Optional model) { this.model = model; @@ -109,6 +112,9 @@ public Builder model(DataAttributesListRequestModel model) { return this; } + /** + *

Include archived attributes in the list. By default we return only non archived data attributes.

+ */ @JsonSetter(value = "include_archived", nulls = Nulls.SKIP) public Builder includeArchived(Optional includeArchived) { this.includeArchived = includeArchived; diff --git a/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java b/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java index 392b7ae..23e4d8f 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java @@ -124,6 +124,9 @@ public static DataAttributeIdStage builder() { } public interface DataAttributeIdStage { + /** + * The data attribute id + */ _FinalStage dataAttributeId(@NotNull String dataAttributeId); Builder from(UpdateDataAttributeRequest other); @@ -132,18 +135,30 @@ public interface DataAttributeIdStage { public interface _FinalStage { UpdateDataAttributeRequest build(); + /** + *

Whether the attribute is to be archived or not.

+ */ _FinalStage archived(Optional archived); _FinalStage archived(Boolean archived); + /** + *

The readable description you see in the UI for the attribute.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ _FinalStage options(Optional> options); _FinalStage options(List options); + /** + *

Can this attribute be updated by the Messenger

+ */ _FinalStage messengerWritable(Optional messengerWritable); _FinalStage messengerWritable(Boolean messengerWritable); @@ -177,7 +192,7 @@ public Builder from(UpdateDataAttributeRequest other) { } /** - *

The data attribute id

+ * The data attribute id

The data attribute id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -197,6 +212,9 @@ public _FinalStage messengerWritable(Boolean messengerWritable) { return this; } + /** + *

Can this attribute be updated by the Messenger

+ */ @java.lang.Override @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) public _FinalStage messengerWritable(Optional messengerWritable) { @@ -214,6 +232,9 @@ public _FinalStage options(List options) { return this; } + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ @java.lang.Override @JsonSetter(value = "options", nulls = Nulls.SKIP) public _FinalStage options(Optional> options) { @@ -231,6 +252,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The readable description you see in the UI for the attribute.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { @@ -248,6 +272,9 @@ public _FinalStage archived(Boolean archived) { return this; } + /** + *

Whether the attribute is to be archived or not.

+ */ @java.lang.Override @JsonSetter(value = "archived", nulls = Nulls.SKIP) public _FinalStage archived(Optional archived) { diff --git a/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java b/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java index d5a2bbc..f8a11fe 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/types/DataAttribute.java @@ -292,70 +292,118 @@ public static NameStage builder() { } public interface NameStage { + /** + * Name of the attribute. + */ FullNameStage name(@NotNull String name); Builder from(DataAttribute other); } public interface FullNameStage { + /** + * Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on `.` to access nested user object values. + */ LabelStage fullName(@NotNull String fullName); } public interface LabelStage { + /** + * Readable name of the attribute (i.e. name you see in the UI) + */ DescriptionStage label(@NotNull String label); } public interface DescriptionStage { + /** + * Readable description of the attribute. + */ DataTypeStage description(@NotNull String description); } public interface DataTypeStage { + /** + * The data type of the attribute. + */ _FinalStage dataType(@NotNull DataType dataType); } public interface _FinalStage { DataAttribute build(); + /** + *

The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes.

+ */ _FinalStage id(Optional id); _FinalStage id(Integer id); + /** + *

Value is contact for user/lead attributes and company for company attributes.

+ */ _FinalStage model(Optional model); _FinalStage model(Model model); + /** + *

List of predefined options for attribute value.

+ */ _FinalStage options(Optional> options); _FinalStage options(List options); + /** + *

Can this attribute be updated through API

+ */ _FinalStage apiWritable(Optional apiWritable); _FinalStage apiWritable(Boolean apiWritable); + /** + *

Can this attribute be updated by the Messenger

+ */ _FinalStage messengerWritable(Optional messengerWritable); _FinalStage messengerWritable(Boolean messengerWritable); + /** + *

Can this attribute be updated in the UI

+ */ _FinalStage uiWritable(Optional uiWritable); _FinalStage uiWritable(Boolean uiWritable); + /** + *

Set to true if this is a CDA

+ */ _FinalStage custom(Optional custom); _FinalStage custom(Boolean custom); + /** + *

Is this attribute archived. (Only applicable to CDAs)

+ */ _FinalStage archived(Optional archived); _FinalStage archived(Boolean archived); + /** + *

The time the attribute was created as a UTC Unix timestamp

+ */ _FinalStage createdAt(Optional createdAt); _FinalStage createdAt(Integer createdAt); + /** + *

The time the attribute was last updated as a UTC Unix timestamp

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); + /** + *

Teammate who created the attribute. Only applicable to CDAs

+ */ _FinalStage adminId(Optional adminId); _FinalStage adminId(String adminId); @@ -423,7 +471,7 @@ public Builder from(DataAttribute other) { } /** - *

Name of the attribute.

+ * Name of the attribute.

Name of the attribute.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -434,7 +482,7 @@ public FullNameStage name(@NotNull String name) { } /** - *

Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on . to access nested user object values.

+ * Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on `.` to access nested user object values.

Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on . to access nested user object values.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -445,7 +493,7 @@ public LabelStage fullName(@NotNull String fullName) { } /** - *

Readable name of the attribute (i.e. name you see in the UI)

+ * Readable name of the attribute (i.e. name you see in the UI)

Readable name of the attribute (i.e. name you see in the UI)

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -456,7 +504,7 @@ public DescriptionStage label(@NotNull String label) { } /** - *

Readable description of the attribute.

+ * Readable description of the attribute.

Readable description of the attribute.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -467,7 +515,7 @@ public DataTypeStage description(@NotNull String description) { } /** - *

The data type of the attribute.

+ * The data type of the attribute.

The data type of the attribute.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -487,6 +535,9 @@ public _FinalStage adminId(String adminId) { return this; } + /** + *

Teammate who created the attribute. Only applicable to CDAs

+ */ @java.lang.Override @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) public _FinalStage adminId(Optional adminId) { @@ -504,6 +555,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

The time the attribute was last updated as a UTC Unix timestamp

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { @@ -521,6 +575,9 @@ public _FinalStage createdAt(Integer createdAt) { return this; } + /** + *

The time the attribute was created as a UTC Unix timestamp

+ */ @java.lang.Override @JsonSetter(value = "created_at", nulls = Nulls.SKIP) public _FinalStage createdAt(Optional createdAt) { @@ -538,6 +595,9 @@ public _FinalStage archived(Boolean archived) { return this; } + /** + *

Is this attribute archived. (Only applicable to CDAs)

+ */ @java.lang.Override @JsonSetter(value = "archived", nulls = Nulls.SKIP) public _FinalStage archived(Optional archived) { @@ -555,6 +615,9 @@ public _FinalStage custom(Boolean custom) { return this; } + /** + *

Set to true if this is a CDA

+ */ @java.lang.Override @JsonSetter(value = "custom", nulls = Nulls.SKIP) public _FinalStage custom(Optional custom) { @@ -572,6 +635,9 @@ public _FinalStage uiWritable(Boolean uiWritable) { return this; } + /** + *

Can this attribute be updated in the UI

+ */ @java.lang.Override @JsonSetter(value = "ui_writable", nulls = Nulls.SKIP) public _FinalStage uiWritable(Optional uiWritable) { @@ -589,6 +655,9 @@ public _FinalStage messengerWritable(Boolean messengerWritable) { return this; } + /** + *

Can this attribute be updated by the Messenger

+ */ @java.lang.Override @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) public _FinalStage messengerWritable(Optional messengerWritable) { @@ -606,6 +675,9 @@ public _FinalStage apiWritable(Boolean apiWritable) { return this; } + /** + *

Can this attribute be updated through API

+ */ @java.lang.Override @JsonSetter(value = "api_writable", nulls = Nulls.SKIP) public _FinalStage apiWritable(Optional apiWritable) { @@ -623,6 +695,9 @@ public _FinalStage options(List options) { return this; } + /** + *

List of predefined options for attribute value.

+ */ @java.lang.Override @JsonSetter(value = "options", nulls = Nulls.SKIP) public _FinalStage options(Optional> options) { @@ -640,6 +715,9 @@ public _FinalStage model(Model model) { return this; } + /** + *

Value is contact for user/lead attributes and company for company attributes.

+ */ @java.lang.Override @JsonSetter(value = "model", nulls = Nulls.SKIP) public _FinalStage model(Optional model) { @@ -657,6 +735,9 @@ public _FinalStage id(Integer id) { return this; } + /** + *

The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes.

+ */ @java.lang.Override @JsonSetter(value = "id", nulls = Nulls.SKIP) public _FinalStage id(Optional id) { diff --git a/src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java b/src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java index 3ea858f..630d1bd 100644 --- a/src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java +++ b/src/main/java/com/intercom/api/resources/dataevents/types/DataEvent.java @@ -169,38 +169,62 @@ public static EventNameStage builder() { } public interface EventNameStage { + /** + * The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. + */ CreatedAtStage eventName(@NotNull String eventName); Builder from(DataEvent other); } public interface CreatedAtStage { + /** + * The time the event occurred as a UTC Unix timestamp + */ _FinalStage createdAt(int createdAt); } public interface _FinalStage { DataEvent build(); + /** + *

The type of the object

+ */ _FinalStage type(Optional type); _FinalStage type(String type); + /** + *

Your identifier for the user.

+ */ _FinalStage userId(Optional userId); _FinalStage userId(String userId); + /** + *

Your identifier for a lead or a user.

+ */ _FinalStage id(Optional id); _FinalStage id(String id); + /** + *

The Intercom identifier for the user.

+ */ _FinalStage intercomUserId(Optional intercomUserId); _FinalStage intercomUserId(String intercomUserId); + /** + *

An email address for your user. An email should only be used where your application uses email to uniquely identify users.

+ */ _FinalStage email(Optional email); _FinalStage email(String email); + /** + *

Optional metadata about the event.

+ */ _FinalStage metadata(Optional> metadata); _FinalStage metadata(Map metadata); @@ -243,7 +267,7 @@ public Builder from(DataEvent other) { } /** - *

The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

+ * The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`.

The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -254,7 +278,7 @@ public CreatedAtStage eventName(@NotNull String eventName) { } /** - *

The time the event occurred as a UTC Unix timestamp

+ * The time the event occurred as a UTC Unix timestamp

The time the event occurred as a UTC Unix timestamp

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -274,6 +298,9 @@ public _FinalStage metadata(Map metadata) { return this; } + /** + *

Optional metadata about the event.

+ */ @java.lang.Override @JsonSetter(value = "metadata", nulls = Nulls.SKIP) public _FinalStage metadata(Optional> metadata) { @@ -291,6 +318,9 @@ public _FinalStage email(String email) { return this; } + /** + *

An email address for your user. An email should only be used where your application uses email to uniquely identify users.

+ */ @java.lang.Override @JsonSetter(value = "email", nulls = Nulls.SKIP) public _FinalStage email(Optional email) { @@ -308,6 +338,9 @@ public _FinalStage intercomUserId(String intercomUserId) { return this; } + /** + *

The Intercom identifier for the user.

+ */ @java.lang.Override @JsonSetter(value = "intercom_user_id", nulls = Nulls.SKIP) public _FinalStage intercomUserId(Optional intercomUserId) { @@ -325,6 +358,9 @@ public _FinalStage id(String id) { return this; } + /** + *

Your identifier for a lead or a user.

+ */ @java.lang.Override @JsonSetter(value = "id", nulls = Nulls.SKIP) public _FinalStage id(Optional id) { @@ -342,6 +378,9 @@ public _FinalStage userId(String userId) { return this; } + /** + *

Your identifier for the user.

+ */ @java.lang.Override @JsonSetter(value = "user_id", nulls = Nulls.SKIP) public _FinalStage userId(Optional userId) { @@ -359,6 +398,9 @@ public _FinalStage type(String type) { return this; } + /** + *

The type of the object

+ */ @java.lang.Override @JsonSetter(value = "type", nulls = Nulls.SKIP) public _FinalStage type(Optional type) { diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java index 2894247..f8bc876 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/CancelDataExportRequest.java @@ -66,6 +66,9 @@ public static JobIdentifierStage builder() { } public interface JobIdentifierStage { + /** + * job_identifier + */ _FinalStage jobIdentifier(@NotNull String jobIdentifier); Builder from(CancelDataExportRequest other); @@ -91,7 +94,7 @@ public Builder from(CancelDataExportRequest other) { } /** - *

job_identifier

+ * job_identifier

job_identifier

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java index 7c1dd82..7e8babb 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/CreateDataExportRequest.java @@ -76,12 +76,18 @@ public static CreatedAtAfterStage builder() { } public interface CreatedAtAfterStage { + /** + * The start date that you request data for. It must be formatted as a unix timestamp. + */ CreatedAtBeforeStage createdAtAfter(int createdAtAfter); Builder from(CreateDataExportRequest other); } public interface CreatedAtBeforeStage { + /** + * The end date that you request data for. It must be formatted as a unix timestamp. + */ _FinalStage createdAtBefore(int createdAtBefore); } @@ -108,7 +114,7 @@ public Builder from(CreateDataExportRequest other) { } /** - *

The start date that you request data for. It must be formatted as a unix timestamp.

+ * The start date that you request data for. It must be formatted as a unix timestamp.

The start date that you request data for. It must be formatted as a unix timestamp.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -119,7 +125,7 @@ public CreatedAtBeforeStage createdAtAfter(int createdAtAfter) { } /** - *

The end date that you request data for. It must be formatted as a unix timestamp.

+ * The end date that you request data for. It must be formatted as a unix timestamp.

The end date that you request data for. It must be formatted as a unix timestamp.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java index 72bc928..f8fba0d 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadDataExportRequest.java @@ -66,6 +66,9 @@ public static JobIdentifierStage builder() { } public interface JobIdentifierStage { + /** + * job_identifier + */ _FinalStage jobIdentifier(@NotNull String jobIdentifier); Builder from(DownloadDataExportRequest other); @@ -91,7 +94,7 @@ public Builder from(DownloadDataExportRequest other) { } /** - *

job_identifier

+ * job_identifier

job_identifier

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java index 1768413..b5cc684 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/FindDataExportRequest.java @@ -66,6 +66,9 @@ public static JobIdentifierStage builder() { } public interface JobIdentifierStage { + /** + * job_identifier + */ _FinalStage jobIdentifier(@NotNull String jobIdentifier); Builder from(FindDataExportRequest other); @@ -91,7 +94,7 @@ public Builder from(FindDataExportRequest other) { } /** - *

job_identifier

+ * job_identifier

job_identifier

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java b/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java index 94745fa..3638989 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java +++ b/src/main/java/com/intercom/api/resources/dataexport/types/DataExport.java @@ -109,20 +109,32 @@ public static JobIdentifierStage builder() { } public interface JobIdentifierStage { + /** + * The identifier for your job. + */ StatusStage jobIdentifier(@NotNull String jobIdentifier); Builder from(DataExport other); } public interface StatusStage { + /** + * The current state of your job. + */ DownloadExpiresAtStage status(@NotNull Status status); } public interface DownloadExpiresAtStage { + /** + * The time after which you will not be able to access the data. + */ DownloadUrlStage downloadExpiresAt(@NotNull String downloadExpiresAt); } public interface DownloadUrlStage { + /** + * The location where you can download your data. + */ _FinalStage downloadUrl(@NotNull String downloadUrl); } @@ -156,7 +168,7 @@ public Builder from(DataExport other) { } /** - *

The identifier for your job.

+ * The identifier for your job.

The identifier for your job.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -167,7 +179,7 @@ public StatusStage jobIdentifier(@NotNull String jobIdentifier) { } /** - *

The current state of your job.

+ * The current state of your job.

The current state of your job.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -178,7 +190,7 @@ public DownloadExpiresAtStage status(@NotNull Status status) { } /** - *

The time after which you will not be able to access the data.

+ * The time after which you will not be able to access the data.

The time after which you will not be able to access the data.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -189,7 +201,7 @@ public DownloadUrlStage downloadExpiresAt(@NotNull String downloadExpiresAt) { } /** - *

The location where you can download your data.

+ * The location where you can download your data.

The location where you can download your data.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java b/src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java index d22a31f..5fb7fe0 100644 --- a/src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java +++ b/src/main/java/com/intercom/api/resources/events/requests/ListEventSummariesRequest.java @@ -97,6 +97,9 @@ public Builder from(ListEventSummariesRequest other) { return this; } + /** + *

Your identifier for the user.

+ */ @JsonSetter(value = "user_id", nulls = Nulls.SKIP) public Builder userId(Optional userId) { this.userId = userId; @@ -108,6 +111,9 @@ public Builder userId(String userId) { return this; } + /** + *

A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

+ */ @JsonSetter(value = "event_summaries", nulls = Nulls.SKIP) public Builder eventSummaries(Optional eventSummaries) { this.eventSummaries = eventSummaries; @@ -237,6 +243,9 @@ public Builder from(EventSummaries other) { return this; } + /** + *

The name of the event that occurred. A good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

+ */ @JsonSetter(value = "event_name", nulls = Nulls.SKIP) public Builder eventName(Optional eventName) { this.eventName = eventName; @@ -248,6 +257,9 @@ public Builder eventName(String eventName) { return this; } + /** + *

The number of times the event occurred.

+ */ @JsonSetter(value = "count", nulls = Nulls.SKIP) public Builder count(Optional count) { this.count = count; @@ -259,6 +271,9 @@ public Builder count(Integer count) { return this; } + /** + *

The first time the event was sent

+ */ @JsonSetter(value = "first", nulls = Nulls.SKIP) public Builder first(Optional first) { this.first = first; @@ -270,6 +285,9 @@ public Builder first(Integer first) { return this; } + /** + *

The last time the event was sent

+ */ @JsonSetter(value = "last", nulls = Nulls.SKIP) public Builder last(Optional last) { this.last = last; diff --git a/src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java b/src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java index e36c34c..038fa0c 100644 --- a/src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java +++ b/src/main/java/com/intercom/api/resources/events/requests/ListEventsRequest.java @@ -135,6 +135,9 @@ public static TypeStage builder() { } public interface TypeStage { + /** + * The value must be user + */ _FinalStage type(@NotNull String type); Builder from(ListEventsRequest other); @@ -143,22 +146,37 @@ public interface TypeStage { public interface _FinalStage { ListEventsRequest build(); + /** + *

user_id query parameter

+ */ _FinalStage userId(Optional userId); _FinalStage userId(String userId); + /** + *

intercom_user_id query parameter

+ */ _FinalStage intercomUserId(Optional intercomUserId); _FinalStage intercomUserId(String intercomUserId); + /** + *

email query parameter

+ */ _FinalStage email(Optional email); _FinalStage email(String email); + /** + *

summary flag

+ */ _FinalStage summary(Optional summary); _FinalStage summary(Boolean summary); + /** + *

How many results to display per page. Defaults to 15

+ */ _FinalStage perPage(Optional perPage); _FinalStage perPage(Integer perPage); @@ -195,7 +213,7 @@ public Builder from(ListEventsRequest other) { } /** - *

The value must be user

+ * The value must be user

The value must be user

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -215,6 +233,9 @@ public _FinalStage perPage(Integer perPage) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @java.lang.Override @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public _FinalStage perPage(Optional perPage) { @@ -232,6 +253,9 @@ public _FinalStage summary(Boolean summary) { return this; } + /** + *

summary flag

+ */ @java.lang.Override @JsonSetter(value = "summary", nulls = Nulls.SKIP) public _FinalStage summary(Optional summary) { @@ -249,6 +273,9 @@ public _FinalStage email(String email) { return this; } + /** + *

email query parameter

+ */ @java.lang.Override @JsonSetter(value = "email", nulls = Nulls.SKIP) public _FinalStage email(Optional email) { @@ -266,6 +293,9 @@ public _FinalStage intercomUserId(String intercomUserId) { return this; } + /** + *

intercom_user_id query parameter

+ */ @java.lang.Override @JsonSetter(value = "intercom_user_id", nulls = Nulls.SKIP) public _FinalStage intercomUserId(Optional intercomUserId) { @@ -283,6 +313,9 @@ public _FinalStage userId(String userId) { return this; } + /** + *

user_id query parameter

+ */ @java.lang.Override @JsonSetter(value = "user_id", nulls = Nulls.SKIP) public _FinalStage userId(Optional userId) { diff --git a/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java b/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java index bf4d916..1231cee 100644 --- a/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java @@ -237,46 +237,76 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ WorkspaceIdStage id(@NotNull String id); Builder from(Collection other); } public interface WorkspaceIdStage { + /** + * The id of the workspace which the collection belongs to. + */ NameStage workspaceId(@NotNull String workspaceId); } public interface NameStage { + /** + * The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ CreatedAtStage name(@NotNull String name); } public interface CreatedAtStage { + /** + * The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content. + */ OrderStage createdAt(int createdAt); } public interface OrderStage { + /** + * The order of the section in relation to others sections within a collection. Values go from `0` upwards. `0` is the default if there's no order. + */ DefaultLocaleStage order(int order); } public interface DefaultLocaleStage { + /** + * The default locale of the help center. This field is only returned for multilingual help centers. + */ _FinalStage defaultLocale(@NotNull String defaultLocale); } public interface _FinalStage { Collection build(); + /** + *

The description of the collection. For multilingual help centers, this will be the description of the collection for the default language.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); + /** + *

The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language.

+ */ _FinalStage url(Optional url); _FinalStage url(String url); + /** + *

The icon of the collection.

+ */ _FinalStage icon(Optional icon); _FinalStage icon(String icon); @@ -285,10 +315,16 @@ public interface _FinalStage { _FinalStage translatedContent(GroupTranslatedContent translatedContent); + /** + *

The id of the parent collection. If null then it is the first level collection.

+ */ _FinalStage parentId(Optional parentId); _FinalStage parentId(String parentId); + /** + *

The id of the help center the collection is in.

+ */ _FinalStage helpCenterId(Optional helpCenterId); _FinalStage helpCenterId(Integer helpCenterId); @@ -353,7 +389,7 @@ public Builder from(Collection other) { } /** - *

The unique identifier for the collection which is given by Intercom.

+ * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -364,7 +400,7 @@ public WorkspaceIdStage id(@NotNull String id) { } /** - *

The id of the workspace which the collection belongs to.

+ * The id of the workspace which the collection belongs to.

The id of the workspace which the collection belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -375,7 +411,7 @@ public NameStage workspaceId(@NotNull String workspaceId) { } /** - *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ * The name of the collection. For multilingual collections, this will be the name of the default language's content.

The name of the collection. For multilingual collections, this will be the name of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -386,7 +422,7 @@ public CreatedAtStage name(@NotNull String name) { } /** - *

The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content.

+ * The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content.

The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -397,7 +433,7 @@ public OrderStage createdAt(int createdAt) { } /** - *

The order of the section in relation to others sections within a collection. Values go from 0 upwards. 0 is the default if there's no order.

+ * The order of the section in relation to others sections within a collection. Values go from `0` upwards. `0` is the default if there's no order.

The order of the section in relation to others sections within a collection. Values go from 0 upwards. 0 is the default if there's no order.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -408,7 +444,7 @@ public DefaultLocaleStage order(int order) { } /** - *

The default locale of the help center. This field is only returned for multilingual help centers.

+ * The default locale of the help center. This field is only returned for multilingual help centers.

The default locale of the help center. This field is only returned for multilingual help centers.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -428,6 +464,9 @@ public _FinalStage helpCenterId(Integer helpCenterId) { return this; } + /** + *

The id of the help center the collection is in.

+ */ @java.lang.Override @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) public _FinalStage helpCenterId(Optional helpCenterId) { @@ -445,6 +484,9 @@ public _FinalStage parentId(String parentId) { return this; } + /** + *

The id of the parent collection. If null then it is the first level collection.

+ */ @java.lang.Override @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) public _FinalStage parentId(Optional parentId) { @@ -475,6 +517,9 @@ public _FinalStage icon(String icon) { return this; } + /** + *

The icon of the collection.

+ */ @java.lang.Override @JsonSetter(value = "icon", nulls = Nulls.SKIP) public _FinalStage icon(Optional icon) { @@ -492,6 +537,9 @@ public _FinalStage url(String url) { return this; } + /** + *

The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language.

+ */ @java.lang.Override @JsonSetter(value = "url", nulls = Nulls.SKIP) public _FinalStage url(Optional url) { @@ -509,6 +557,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { @@ -526,6 +577,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the collection. For multilingual help centers, this will be the description of the collection for the default language.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { diff --git a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java index dbd21b0..bb52590 100644 --- a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenter.java @@ -155,34 +155,55 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the Help Center which is given by Intercom. + */ WorkspaceIdStage id(@NotNull String id); Builder from(HelpCenter other); } public interface WorkspaceIdStage { + /** + * The id of the workspace which the Help Center belongs to. + */ CreatedAtStage workspaceId(@NotNull String workspaceId); } public interface CreatedAtStage { + /** + * The time when the Help Center was created. + */ IdentifierStage createdAt(int createdAt); } public interface IdentifierStage { + /** + * The identifier of the Help Center. This is used in the URL of the Help Center. + */ WebsiteTurnedOnStage identifier(@NotNull String identifier); } public interface WebsiteTurnedOnStage { + /** + * Whether the Help Center is turned on or not. This is controlled in your Help Center settings. + */ DisplayNameStage websiteTurnedOn(boolean websiteTurnedOn); } public interface DisplayNameStage { + /** + * The display name of the Help Center only seen by teammates. + */ _FinalStage displayName(@NotNull String displayName); } public interface _FinalStage { HelpCenter build(); + /** + *

The time when the Help Center was last updated.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); @@ -229,7 +250,7 @@ public Builder from(HelpCenter other) { } /** - *

The unique identifier for the Help Center which is given by Intercom.

+ * The unique identifier for the Help Center which is given by Intercom.

The unique identifier for the Help Center which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -240,7 +261,7 @@ public WorkspaceIdStage id(@NotNull String id) { } /** - *

The id of the workspace which the Help Center belongs to.

+ * The id of the workspace which the Help Center belongs to.

The id of the workspace which the Help Center belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -251,7 +272,7 @@ public CreatedAtStage workspaceId(@NotNull String workspaceId) { } /** - *

The time when the Help Center was created.

+ * The time when the Help Center was created.

The time when the Help Center was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -262,7 +283,7 @@ public IdentifierStage createdAt(int createdAt) { } /** - *

The identifier of the Help Center. This is used in the URL of the Help Center.

+ * The identifier of the Help Center. This is used in the URL of the Help Center.

The identifier of the Help Center. This is used in the URL of the Help Center.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -273,7 +294,7 @@ public WebsiteTurnedOnStage identifier(@NotNull String identifier) { } /** - *

Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

+ * Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -284,7 +305,7 @@ public DisplayNameStage websiteTurnedOn(boolean websiteTurnedOn) { } /** - *

The display name of the Help Center only seen by teammates.

+ * The display name of the Help Center only seen by teammates.

The display name of the Help Center only seen by teammates.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -304,6 +325,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

The time when the Help Center was last updated.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { diff --git a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java index 3cfb6bd..623d7e0 100644 --- a/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java +++ b/src/main/java/com/intercom/api/resources/helpcenter/types/HelpCenterList.java @@ -89,6 +89,9 @@ public Builder from(HelpCenterList other) { return this; } + /** + *

An array of Help Center objects

+ */ @JsonSetter(value = "data", nulls = Nulls.SKIP) public Builder data(List data) { this.data.clear(); diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java index 1f7453d..2a8dd01 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/CreateCollectionRequest.java @@ -120,6 +120,9 @@ public static NameStage builder() { } public interface NameStage { + /** + * The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ _FinalStage name(@NotNull String name); Builder from(CreateCollectionRequest other); @@ -128,6 +131,9 @@ public interface NameStage { public interface _FinalStage { CreateCollectionRequest build(); + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); @@ -136,10 +142,16 @@ public interface _FinalStage { _FinalStage translatedContent(GroupTranslatedContent translatedContent); + /** + *

The id of the parent collection. If null then it will be created as the first level collection.

+ */ _FinalStage parentId(Optional parentId); _FinalStage parentId(String parentId); + /** + *

The id of the help center where the collection will be created. If null then it will be created in the default help center.

+ */ _FinalStage helpCenterId(Optional helpCenterId); _FinalStage helpCenterId(Integer helpCenterId); @@ -173,7 +185,7 @@ public Builder from(CreateCollectionRequest other) { } /** - *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ * The name of the collection. For multilingual collections, this will be the name of the default language's content.

The name of the collection. For multilingual collections, this will be the name of the default language's content.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -193,6 +205,9 @@ public _FinalStage helpCenterId(Integer helpCenterId) { return this; } + /** + *

The id of the help center where the collection will be created. If null then it will be created in the default help center.

+ */ @java.lang.Override @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) public _FinalStage helpCenterId(Optional helpCenterId) { @@ -210,6 +225,9 @@ public _FinalStage parentId(String parentId) { return this; } + /** + *

The id of the parent collection. If null then it will be created as the first level collection.

+ */ @java.lang.Override @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) public _FinalStage parentId(Optional parentId) { @@ -240,6 +258,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java index 5755262..acfdd76 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/DeleteCollectionRequest.java @@ -66,6 +66,9 @@ public static CollectionIdStage builder() { } public interface CollectionIdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ _FinalStage collectionId(@NotNull String collectionId); Builder from(DeleteCollectionRequest other); @@ -91,7 +94,7 @@ public Builder from(DeleteCollectionRequest other) { } /** - *

The unique identifier for the collection which is given by Intercom.

+ * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java index 70aef5f..bd42768 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/FindCollectionRequest.java @@ -66,6 +66,9 @@ public static CollectionIdStage builder() { } public interface CollectionIdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ _FinalStage collectionId(@NotNull String collectionId); Builder from(FindCollectionRequest other); @@ -91,7 +94,7 @@ public Builder from(FindCollectionRequest other) { } /** - *

The unique identifier for the collection which is given by Intercom.

+ * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java index 63230d7..5ea0264 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/ListCollectionsRequest.java @@ -95,6 +95,9 @@ public Builder from(ListCollectionsRequest other) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -106,6 +109,9 @@ public Builder page(Integer page) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public Builder perPage(Optional perPage) { this.perPage = perPage; diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java index f849187..965fa00 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/requests/UpdateCollectionRequest.java @@ -120,6 +120,9 @@ public static CollectionIdStage builder() { } public interface CollectionIdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ _FinalStage collectionId(@NotNull String collectionId); Builder from(UpdateCollectionRequest other); @@ -128,10 +131,16 @@ public interface CollectionIdStage { public interface _FinalStage { UpdateCollectionRequest build(); + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ */ _FinalStage name(Optional name); _FinalStage name(String name); + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); @@ -140,6 +149,9 @@ public interface _FinalStage { _FinalStage translatedContent(GroupTranslatedContent translatedContent); + /** + *

The id of the parent collection. If null then it will be updated as the first level collection.

+ */ _FinalStage parentId(Optional parentId); _FinalStage parentId(String parentId); @@ -173,7 +185,7 @@ public Builder from(UpdateCollectionRequest other) { } /** - *

The unique identifier for the collection which is given by Intercom.

+ * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -193,6 +205,9 @@ public _FinalStage parentId(String parentId) { return this; } + /** + *

The id of the parent collection. If null then it will be updated as the first level collection.

+ */ @java.lang.Override @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) public _FinalStage parentId(Optional parentId) { @@ -223,6 +238,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { @@ -240,6 +258,9 @@ public _FinalStage name(String name) { return this; } + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ */ @java.lang.Override @JsonSetter(value = "name", nulls = Nulls.SKIP) public _FinalStage name(Optional name) { diff --git a/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java index d6c4a40..6814db5 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/requests/FindHelpCenterRequest.java @@ -66,6 +66,9 @@ public static HelpCenterIdStage builder() { } public interface HelpCenterIdStage { + /** + * The unique identifier for the Help Center which is given by Intercom. + */ _FinalStage helpCenterId(@NotNull String helpCenterId); Builder from(FindHelpCenterRequest other); @@ -91,7 +94,7 @@ public Builder from(FindHelpCenterRequest other) { } /** - *

The unique identifier for the Help Center which is given by Intercom.

+ * The unique identifier for the Help Center which is given by Intercom.

The unique identifier for the Help Center which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java b/src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java index 4d694fb..e47a8f9 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/requests/ListHelpCentersRequest.java @@ -95,6 +95,9 @@ public Builder from(ListHelpCentersRequest other) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -106,6 +109,9 @@ public Builder page(Integer page) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public Builder perPage(Optional perPage) { this.perPage = perPage; diff --git a/src/main/java/com/intercom/api/resources/messages/types/Message.java b/src/main/java/com/intercom/api/resources/messages/types/Message.java index 76b75d5..2ad8f7d 100644 --- a/src/main/java/com/intercom/api/resources/messages/types/Message.java +++ b/src/main/java/com/intercom/api/resources/messages/types/Message.java @@ -149,32 +149,53 @@ public static TypeStage builder() { } public interface TypeStage { + /** + * The type of the message + */ IdStage type(@NotNull String type); Builder from(Message other); } public interface IdStage { + /** + * The id representing the message. + */ CreatedAtStage id(@NotNull String id); } public interface CreatedAtStage { + /** + * The time the conversation was created. + */ SubjectStage createdAt(int createdAt); } public interface SubjectStage { + /** + * The subject of the message. Only present if message_type: email. + */ BodyStage subject(@NotNull String subject); } public interface BodyStage { + /** + * The message body, which may contain HTML. + */ MessageTypeStage body(@NotNull String body); } public interface MessageTypeStage { + /** + * The type of message that was sent. Can be email, inapp, facebook or twitter. + */ ConversationIdStage messageType(@NotNull MessageType messageType); } public interface ConversationIdStage { + /** + * The associated conversation_id + */ _FinalStage conversationId(@NotNull String conversationId); } @@ -224,7 +245,7 @@ public Builder from(Message other) { } /** - *

The type of the message

+ * The type of the message

The type of the message

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -235,7 +256,7 @@ public IdStage type(@NotNull String type) { } /** - *

The id representing the message.

+ * The id representing the message.

The id representing the message.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -246,7 +267,7 @@ public CreatedAtStage id(@NotNull String id) { } /** - *

The time the conversation was created.

+ * The time the conversation was created.

The time the conversation was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -257,7 +278,7 @@ public SubjectStage createdAt(int createdAt) { } /** - *

The subject of the message. Only present if message_type: email.

+ * The subject of the message. Only present if message_type: email.

The subject of the message. Only present if message_type: email.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -268,7 +289,7 @@ public BodyStage subject(@NotNull String subject) { } /** - *

The message body, which may contain HTML.

+ * The message body, which may contain HTML.

The message body, which may contain HTML.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -279,7 +300,7 @@ public MessageTypeStage body(@NotNull String body) { } /** - *

The type of message that was sent. Can be email, inapp, facebook or twitter.

+ * The type of message that was sent. Can be email, inapp, facebook or twitter.

The type of message that was sent. Can be email, inapp, facebook or twitter.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -290,7 +311,7 @@ public ConversationIdStage messageType(@NotNull MessageType messageType) { } /** - *

The associated conversation_id

+ * The associated conversation_id

The associated conversation_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java b/src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java index 74dadb5..b2c1f9a 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/requests/FindNewsFeedRequest.java @@ -66,6 +66,9 @@ public static NewsfeedIdStage builder() { } public interface NewsfeedIdStage { + /** + * The unique identifier for the news feed item which is given by Intercom. + */ _FinalStage newsfeedId(@NotNull String newsfeedId); Builder from(FindNewsFeedRequest other); @@ -91,7 +94,7 @@ public Builder from(FindNewsFeedRequest other) { } /** - *

The unique identifier for the news feed item which is given by Intercom.

+ * The unique identifier for the news feed item which is given by Intercom.

The unique identifier for the news feed item which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java b/src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java index b48246b..4e67013 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/requests/ListNewsFeedItemsRequest.java @@ -66,6 +66,9 @@ public static NewsfeedIdStage builder() { } public interface NewsfeedIdStage { + /** + * The unique identifier for the news feed item which is given by Intercom. + */ _FinalStage newsfeedId(@NotNull String newsfeedId); Builder from(ListNewsFeedItemsRequest other); @@ -91,7 +94,7 @@ public Builder from(ListNewsFeedItemsRequest other) { } /** - *

The unique identifier for the news feed item which is given by Intercom.

+ * The unique identifier for the news feed item which is given by Intercom.

The unique identifier for the news feed item which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java b/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java index d72eb7c..a75407f 100644 --- a/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java +++ b/src/main/java/com/intercom/api/resources/news/items/requests/DeleteNewsItemRequest.java @@ -66,6 +66,9 @@ public static NewsItemIdStage builder() { } public interface NewsItemIdStage { + /** + * The unique identifier for the news item which is given by Intercom. + */ _FinalStage newsItemId(@NotNull String newsItemId); Builder from(DeleteNewsItemRequest other); @@ -91,7 +94,7 @@ public Builder from(DeleteNewsItemRequest other) { } /** - *

The unique identifier for the news item which is given by Intercom.

+ * The unique identifier for the news item which is given by Intercom.

The unique identifier for the news item which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java b/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java index db2422e..e67e4cb 100644 --- a/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java +++ b/src/main/java/com/intercom/api/resources/news/items/requests/FindNewsItemRequest.java @@ -66,6 +66,9 @@ public static NewsItemIdStage builder() { } public interface NewsItemIdStage { + /** + * The unique identifier for the news item which is given by Intercom. + */ _FinalStage newsItemId(@NotNull String newsItemId); Builder from(FindNewsItemRequest other); @@ -91,7 +94,7 @@ public Builder from(FindNewsItemRequest other) { } /** - *

The unique identifier for the news item which is given by Intercom.

+ * The unique identifier for the news item which is given by Intercom.

The unique identifier for the news item which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java b/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java index 266f995..0c5caf1 100644 --- a/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java +++ b/src/main/java/com/intercom/api/resources/news/items/requests/UpdateNewsItemRequest.java @@ -75,6 +75,9 @@ public static NewsItemIdStage builder() { } public interface NewsItemIdStage { + /** + * The unique identifier for the news item which is given by Intercom. + */ BodyStage newsItemId(@NotNull String newsItemId); Builder from(UpdateNewsItemRequest other); @@ -107,7 +110,7 @@ public Builder from(UpdateNewsItemRequest other) { } /** - *

The unique identifier for the news item which is given by Intercom.

+ * The unique identifier for the news item which is given by Intercom.

The unique identifier for the news item which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/news/types/NewsItem.java b/src/main/java/com/intercom/api/resources/news/types/NewsItem.java index f9845f1..a971ca3 100644 --- a/src/main/java/com/intercom/api/resources/news/types/NewsItem.java +++ b/src/main/java/com/intercom/api/resources/news/types/NewsItem.java @@ -250,58 +250,97 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the news item which is given by Intercom. + */ WorkspaceIdStage id(@NotNull String id); Builder from(NewsItem other); } public interface WorkspaceIdStage { + /** + * The id of the workspace which the news item belongs to. + */ TitleStage workspaceId(@NotNull String workspaceId); } public interface TitleStage { + /** + * The title of the news item. + */ BodyStage title(@NotNull String title); } public interface BodyStage { + /** + * The news item body, which may contain HTML. + */ SenderIdStage body(@NotNull String body); } public interface SenderIdStage { + /** + * The id of the sender of the news item. Must be a teammate on the workspace. + */ StateStage senderId(int senderId); } public interface StateStage { + /** + * News items will not be visible to your users in the assigned newsfeeds until they are set live. + */ CreatedAtStage state(@NotNull State state); } public interface CreatedAtStage { + /** + * Timestamp for when the news item was created. + */ _FinalStage createdAt(int createdAt); } public interface _FinalStage { NewsItem build(); + /** + *

A list of newsfeed_assignments to assign to the specified newsfeed.

+ */ _FinalStage newsfeedAssignments(Optional> newsfeedAssignments); _FinalStage newsfeedAssignments(List newsfeedAssignments); + /** + *

Label names displayed to users to categorize the news item.

+ */ _FinalStage labels(Optional>> labels); _FinalStage labels(List> labels); + /** + *

URL of the image used as cover. Must have .jpg or .png extension.

+ */ _FinalStage coverImageUrl(Optional coverImageUrl); _FinalStage coverImageUrl(String coverImageUrl); + /** + *

Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

+ */ _FinalStage reactions(Optional>> reactions); _FinalStage reactions(List> reactions); + /** + *

When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

+ */ _FinalStage deliverSilently(Optional deliverSilently); _FinalStage deliverSilently(Boolean deliverSilently); + /** + *

Timestamp for when the news item was last updated.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); @@ -367,7 +406,7 @@ public Builder from(NewsItem other) { } /** - *

The unique identifier for the news item which is given by Intercom.

+ * The unique identifier for the news item which is given by Intercom.

The unique identifier for the news item which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -378,7 +417,7 @@ public WorkspaceIdStage id(@NotNull String id) { } /** - *

The id of the workspace which the news item belongs to.

+ * The id of the workspace which the news item belongs to.

The id of the workspace which the news item belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -389,7 +428,7 @@ public TitleStage workspaceId(@NotNull String workspaceId) { } /** - *

The title of the news item.

+ * The title of the news item.

The title of the news item.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -400,7 +439,7 @@ public BodyStage title(@NotNull String title) { } /** - *

The news item body, which may contain HTML.

+ * The news item body, which may contain HTML.

The news item body, which may contain HTML.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -411,7 +450,7 @@ public SenderIdStage body(@NotNull String body) { } /** - *

The id of the sender of the news item. Must be a teammate on the workspace.

+ * The id of the sender of the news item. Must be a teammate on the workspace.

The id of the sender of the news item. Must be a teammate on the workspace.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -422,7 +461,7 @@ public StateStage senderId(int senderId) { } /** - *

News items will not be visible to your users in the assigned newsfeeds until they are set live.

+ * News items will not be visible to your users in the assigned newsfeeds until they are set live.

News items will not be visible to your users in the assigned newsfeeds until they are set live.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -433,7 +472,7 @@ public CreatedAtStage state(@NotNull State state) { } /** - *

Timestamp for when the news item was created.

+ * Timestamp for when the news item was created.

Timestamp for when the news item was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -453,6 +492,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

Timestamp for when the news item was last updated.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { @@ -470,6 +512,9 @@ public _FinalStage deliverSilently(Boolean deliverSilently) { return this; } + /** + *

When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

+ */ @java.lang.Override @JsonSetter(value = "deliver_silently", nulls = Nulls.SKIP) public _FinalStage deliverSilently(Optional deliverSilently) { @@ -487,6 +532,9 @@ public _FinalStage reactions(List> reactions) { return this; } + /** + *

Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

+ */ @java.lang.Override @JsonSetter(value = "reactions", nulls = Nulls.SKIP) public _FinalStage reactions(Optional>> reactions) { @@ -504,6 +552,9 @@ public _FinalStage coverImageUrl(String coverImageUrl) { return this; } + /** + *

URL of the image used as cover. Must have .jpg or .png extension.

+ */ @java.lang.Override @JsonSetter(value = "cover_image_url", nulls = Nulls.SKIP) public _FinalStage coverImageUrl(Optional coverImageUrl) { @@ -521,6 +572,9 @@ public _FinalStage labels(List> labels) { return this; } + /** + *

Label names displayed to users to categorize the news item.

+ */ @java.lang.Override @JsonSetter(value = "labels", nulls = Nulls.SKIP) public _FinalStage labels(Optional>> labels) { @@ -538,6 +592,9 @@ public _FinalStage newsfeedAssignments(List newsfeedAssignme return this; } + /** + *

A list of newsfeed_assignments to assign to the specified newsfeed.

+ */ @java.lang.Override @JsonSetter(value = "newsfeed_assignments", nulls = Nulls.SKIP) public _FinalStage newsfeedAssignments(Optional> newsfeedAssignments) { diff --git a/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java b/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java index 647865c..a0056b3 100644 --- a/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java +++ b/src/main/java/com/intercom/api/resources/news/types/Newsfeed.java @@ -117,22 +117,34 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the newsfeed which is given by Intercom. + */ NameStage id(@NotNull String id); Builder from(Newsfeed other); } public interface NameStage { + /** + * The name of the newsfeed. This name will never be visible to your users. + */ CreatedAtStage name(@NotNull String name); } public interface CreatedAtStage { + /** + * Timestamp for when the newsfeed was created. + */ _FinalStage createdAt(int createdAt); } public interface _FinalStage { Newsfeed build(); + /** + *

Timestamp for when the newsfeed was last updated.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); @@ -163,7 +175,7 @@ public Builder from(Newsfeed other) { } /** - *

The unique identifier for the newsfeed which is given by Intercom.

+ * The unique identifier for the newsfeed which is given by Intercom.

The unique identifier for the newsfeed which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -174,7 +186,7 @@ public NameStage id(@NotNull String id) { } /** - *

The name of the newsfeed. This name will never be visible to your users.

+ * The name of the newsfeed. This name will never be visible to your users.

The name of the newsfeed. This name will never be visible to your users.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -185,7 +197,7 @@ public CreatedAtStage name(@NotNull String name) { } /** - *

Timestamp for when the newsfeed was created.

+ * Timestamp for when the newsfeed was created.

Timestamp for when the newsfeed was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -205,6 +217,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

Timestamp for when the newsfeed was last updated.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { diff --git a/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java b/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java index 1a30395..f7ba8e7 100644 --- a/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java +++ b/src/main/java/com/intercom/api/resources/news/types/NewsfeedAssignment.java @@ -76,12 +76,18 @@ public static NewsfeedIdStage builder() { } public interface NewsfeedIdStage { + /** + * The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). + */ PublishedAtStage newsfeedId(int newsfeedId); Builder from(NewsfeedAssignment other); } public interface PublishedAtStage { + /** + * Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". + */ _FinalStage publishedAt(int publishedAt); } @@ -108,7 +114,7 @@ public Builder from(NewsfeedAssignment other) { } /** - *

The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article).

+ * The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article).

The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article).

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -119,7 +125,7 @@ public PublishedAtStage newsfeedId(int newsfeedId) { } /** - *

Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft".

+ * Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft".

Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft".

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java b/src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java index 3805aa9..5baaee8 100644 --- a/src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java +++ b/src/main/java/com/intercom/api/resources/notes/requests/CreateContactNoteRequest.java @@ -91,18 +91,27 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier of a given contact. + */ BodyStage contactId(@NotNull String contactId); Builder from(CreateContactNoteRequest other); } public interface BodyStage { + /** + * The text of the note. + */ _FinalStage body(@NotNull String body); } public interface _FinalStage { CreateContactNoteRequest build(); + /** + *

The unique identifier of a given admin.

+ */ _FinalStage adminId(Optional adminId); _FinalStage adminId(String adminId); @@ -130,7 +139,7 @@ public Builder from(CreateContactNoteRequest other) { } /** - *

The unique identifier of a given contact.

+ * The unique identifier of a given contact.

The unique identifier of a given contact.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -141,7 +150,7 @@ public BodyStage contactId(@NotNull String contactId) { } /** - *

The text of the note.

+ * The text of the note.

The text of the note.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -161,6 +170,9 @@ public _FinalStage adminId(String adminId) { return this; } + /** + *

The unique identifier of a given admin.

+ */ @java.lang.Override @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) public _FinalStage adminId(Optional adminId) { diff --git a/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java b/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java index 1388e1a..e51a52b 100644 --- a/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java +++ b/src/main/java/com/intercom/api/resources/notes/requests/FindNoteRequest.java @@ -66,6 +66,9 @@ public static NoteIdStage builder() { } public interface NoteIdStage { + /** + * The unique identifier of a given note + */ _FinalStage noteId(@NotNull String noteId); Builder from(FindNoteRequest other); @@ -91,7 +94,7 @@ public Builder from(FindNoteRequest other) { } /** - *

The unique identifier of a given note

+ * The unique identifier of a given note

The unique identifier of a given note

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java b/src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java index d38cde1..54e8897 100644 --- a/src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java +++ b/src/main/java/com/intercom/api/resources/notes/requests/ListContactNotesRequest.java @@ -94,6 +94,9 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier of a contact. + */ _FinalStage contactId(@NotNull String contactId); Builder from(ListContactNotesRequest other); @@ -102,10 +105,16 @@ public interface ContactIdStage { public interface _FinalStage { ListContactNotesRequest build(); + /** + *

The page of results to fetch. Defaults to first page

+ */ _FinalStage page(Optional page); _FinalStage page(Integer page); + /** + *

How many results to display per page. Defaults to 15

+ */ _FinalStage perPage(Optional perPage); _FinalStage perPage(Integer perPage); @@ -133,7 +142,7 @@ public Builder from(ListContactNotesRequest other) { } /** - *

The unique identifier of a contact.

+ * The unique identifier of a contact.

The unique identifier of a contact.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -153,6 +162,9 @@ public _FinalStage perPage(Integer perPage) { return this; } + /** + *

How many results to display per page. Defaults to 15

+ */ @java.lang.Override @JsonSetter(value = "per_page", nulls = Nulls.SKIP) public _FinalStage perPage(Optional perPage) { @@ -170,6 +182,9 @@ public _FinalStage page(Integer page) { return this; } + /** + *

The page of results to fetch. Defaults to first page

+ */ @java.lang.Override @JsonSetter(value = "page", nulls = Nulls.SKIP) public _FinalStage page(Optional page) { diff --git a/src/main/java/com/intercom/api/resources/notes/types/Note.java b/src/main/java/com/intercom/api/resources/notes/types/Note.java index 5cdb7d8..3e303c4 100644 --- a/src/main/java/com/intercom/api/resources/notes/types/Note.java +++ b/src/main/java/com/intercom/api/resources/notes/types/Note.java @@ -131,26 +131,41 @@ public static IdStage builder() { } public interface IdStage { + /** + * The id of the note. + */ CreatedAtStage id(@NotNull String id); Builder from(Note other); } public interface CreatedAtStage { + /** + * The time the note was created. + */ AuthorStage createdAt(int createdAt); } public interface AuthorStage { + /** + * Optional. Represents the Admin that created the note. + */ BodyStage author(@NotNull Admin author); } public interface BodyStage { + /** + * The body text of the note. + */ _FinalStage body(@NotNull String body); } public interface _FinalStage { Note build(); + /** + *

Represents the contact that the note was created about.

+ */ _FinalStage contact(Optional contact); _FinalStage contact(Contact contact); @@ -184,7 +199,7 @@ public Builder from(Note other) { } /** - *

The id of the note.

+ * The id of the note.

The id of the note.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -195,7 +210,7 @@ public CreatedAtStage id(@NotNull String id) { } /** - *

The time the note was created.

+ * The time the note was created.

The time the note was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -206,7 +221,7 @@ public AuthorStage createdAt(int createdAt) { } /** - *

Optional. Represents the Admin that created the note.

+ * Optional. Represents the Admin that created the note.

Optional. Represents the Admin that created the note.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -217,7 +232,7 @@ public BodyStage author(@NotNull Admin author) { } /** - *

The body text of the note.

+ * The body text of the note.

The body text of the note.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -237,6 +252,9 @@ public _FinalStage contact(Contact contact) { return this; } + /** + *

Represents the contact that the note was created about.

+ */ @java.lang.Override @JsonSetter(value = "contact", nulls = Nulls.SKIP) public _FinalStage contact(Optional contact) { @@ -327,6 +345,9 @@ public Builder from(Contact other) { return this; } + /** + *

String representing the object's type. Always has the value contact.

+ */ @JsonSetter(value = "type", nulls = Nulls.SKIP) public Builder type(Optional type) { this.type = type; @@ -338,6 +359,9 @@ public Builder type(String type) { return this; } + /** + *

The id of the contact.

+ */ @JsonSetter(value = "id", nulls = Nulls.SKIP) public Builder id(Optional id) { this.id = id; diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java b/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java index 8b4d26b..29c1a05 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java @@ -77,6 +77,9 @@ public static PhoneStage builder() { } public interface PhoneStage { + /** + * Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. + */ _FinalStage phone(@NotNull String phone); Builder from(CreatePhoneCallRedirectRequest other); @@ -109,7 +112,7 @@ public Builder from(CreatePhoneCallRedirectRequest other) { } /** - *

Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger.

+ * Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger.

Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java b/src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java index 3234207..2aafb27 100644 --- a/src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java +++ b/src/main/java/com/intercom/api/resources/segments/requests/FindSegmentRequest.java @@ -66,6 +66,9 @@ public static SegmentIdStage builder() { } public interface SegmentIdStage { + /** + * The unique identified of a given segment. + */ _FinalStage segmentId(@NotNull String segmentId); Builder from(FindSegmentRequest other); @@ -91,7 +94,7 @@ public Builder from(FindSegmentRequest other) { } /** - *

The unique identified of a given segment.

+ * The unique identified of a given segment.

The unique identified of a given segment.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java b/src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java index c11a504..0d49b3f 100644 --- a/src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java +++ b/src/main/java/com/intercom/api/resources/segments/requests/ListSegmentsRequest.java @@ -80,6 +80,9 @@ public Builder from(ListSegmentsRequest other) { return this; } + /** + *

It includes the count of contacts that belong to each segment.

+ */ @JsonSetter(value = "include_count", nulls = Nulls.SKIP) public Builder includeCount(Optional includeCount) { this.includeCount = includeCount; diff --git a/src/main/java/com/intercom/api/resources/segments/types/Segment.java b/src/main/java/com/intercom/api/resources/segments/types/Segment.java index 3657dd5..fb148fa 100644 --- a/src/main/java/com/intercom/api/resources/segments/types/Segment.java +++ b/src/main/java/com/intercom/api/resources/segments/types/Segment.java @@ -145,30 +145,48 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier representing the segment. + */ NameStage id(@NotNull String id); Builder from(Segment other); } public interface NameStage { + /** + * The name of the segment. + */ CreatedAtStage name(@NotNull String name); } public interface CreatedAtStage { + /** + * The time the segment was created. + */ PersonTypeStage createdAt(int createdAt); } public interface PersonTypeStage { + /** + * Type of the contact: contact (lead) or user. + */ _FinalStage personType(@NotNull PersonType personType); } public interface _FinalStage { Segment build(); + /** + *

The time the segment was updated.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); + /** + *

The number of items in the user segment. It's returned when include_count=true is included in the request.

+ */ _FinalStage count(Optional count); _FinalStage count(Integer count); @@ -205,7 +223,7 @@ public Builder from(Segment other) { } /** - *

The unique identifier representing the segment.

+ * The unique identifier representing the segment.

The unique identifier representing the segment.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -216,7 +234,7 @@ public NameStage id(@NotNull String id) { } /** - *

The name of the segment.

+ * The name of the segment.

The name of the segment.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -227,7 +245,7 @@ public CreatedAtStage name(@NotNull String name) { } /** - *

The time the segment was created.

+ * The time the segment was created.

The time the segment was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -238,7 +256,7 @@ public PersonTypeStage createdAt(int createdAt) { } /** - *

Type of the contact: contact (lead) or user.

+ * Type of the contact: contact (lead) or user.

Type of the contact: contact (lead) or user.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -258,6 +276,9 @@ public _FinalStage count(Integer count) { return this; } + /** + *

The number of items in the user segment. It's returned when include_count=true is included in the request.

+ */ @java.lang.Override @JsonSetter(value = "count", nulls = Nulls.SKIP) public _FinalStage count(Optional count) { @@ -275,6 +296,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

The time the segment was updated.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { diff --git a/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java b/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java index eff4663..a02f3b4 100644 --- a/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java +++ b/src/main/java/com/intercom/api/resources/subscriptiontypes/types/SubscriptionType.java @@ -145,12 +145,18 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier representing the subscription type. + */ StateStage id(@NotNull String id); Builder from(SubscriptionType other); } public interface StateStage { + /** + * The state of the subscription type. + */ DefaultTranslationStage state(@NotNull State state); } @@ -159,18 +165,27 @@ public interface DefaultTranslationStage { } public interface ConsentTypeStage { + /** + * Describes the type of consent. + */ _FinalStage consentType(@NotNull ConsentType consentType); } public interface _FinalStage { SubscriptionType build(); + /** + *

An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

+ */ _FinalStage translations(List translations); _FinalStage addTranslations(Translation translations); _FinalStage addAllTranslations(List translations); + /** + *

The message types that this subscription supports - can contain email or sms_message.

+ */ _FinalStage contentTypes(List contentTypes); _FinalStage addContentTypes(ContentTypesItem contentTypes); @@ -210,7 +225,7 @@ public Builder from(SubscriptionType other) { } /** - *

The unique identifier representing the subscription type.

+ * The unique identifier representing the subscription type.

The unique identifier representing the subscription type.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -221,7 +236,7 @@ public StateStage id(@NotNull String id) { } /** - *

The state of the subscription type.

+ * The state of the subscription type.

The state of the subscription type.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -239,7 +254,7 @@ public ConsentTypeStage defaultTranslation(@NotNull Translation defaultTranslati } /** - *

Describes the type of consent.

+ * Describes the type of consent.

Describes the type of consent.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -269,6 +284,9 @@ public _FinalStage addContentTypes(ContentTypesItem contentTypes) { return this; } + /** + *

The message types that this subscription supports - can contain email or sms_message.

+ */ @java.lang.Override @JsonSetter(value = "content_types", nulls = Nulls.SKIP) public _FinalStage contentTypes(List contentTypes) { @@ -297,6 +315,9 @@ public _FinalStage addTranslations(Translation translations) { return this; } + /** + *

An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

+ */ @java.lang.Override @JsonSetter(value = "translations", nulls = Nulls.SKIP) public _FinalStage translations(List translations) { diff --git a/src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java index 359272f..56c2df6 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/DeleteTagRequest.java @@ -66,6 +66,9 @@ public static TagIdStage builder() { } public interface TagIdStage { + /** + * The unique identifier of a given tag + */ _FinalStage tagId(@NotNull String tagId); Builder from(DeleteTagRequest other); @@ -91,7 +94,7 @@ public Builder from(DeleteTagRequest other) { } /** - *

The unique identifier of a given tag

+ * The unique identifier of a given tag

The unique identifier of a given tag

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java index 1b16282..f8aaee1 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/FindTagRequest.java @@ -66,6 +66,9 @@ public static TagIdStage builder() { } public interface TagIdStage { + /** + * The unique identifier of a given tag + */ _FinalStage tagId(@NotNull String tagId); Builder from(FindTagRequest other); @@ -91,7 +94,7 @@ public Builder from(FindTagRequest other) { } /** - *

The unique identifier of a given tag

+ * The unique identifier of a given tag

The unique identifier of a given tag

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java index 12d5116..ecabd57 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/TagContactRequest.java @@ -77,12 +77,18 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ TagIdStage contactId(@NotNull String contactId); Builder from(TagContactRequest other); } public interface TagIdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ _FinalStage tagId(@NotNull String tagId); } @@ -109,7 +115,7 @@ public Builder from(TagContactRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -120,7 +126,7 @@ public TagIdStage contactId(@NotNull String contactId) { } /** - *

The unique identifier for the tag which is given by Intercom

+ * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java index 8245315..b8b25bb 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/TagConversationRequest.java @@ -91,16 +91,25 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * conversation_id + */ TagIdStage conversationId(@NotNull String conversationId); Builder from(TagConversationRequest other); } public interface TagIdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ AdminIdStage tagId(@NotNull String tagId); } public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ _FinalStage adminId(@NotNull String adminId); } @@ -130,7 +139,7 @@ public Builder from(TagConversationRequest other) { } /** - *

conversation_id

+ * conversation_id

conversation_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -141,7 +150,7 @@ public TagIdStage conversationId(@NotNull String conversationId) { } /** - *

The unique identifier for the tag which is given by Intercom

+ * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -152,7 +161,7 @@ public AdminIdStage tagId(@NotNull String tagId) { } /** - *

The unique identifier for the admin which is given by Intercom.

+ * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java index 193cfa4..46607ac 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/TagTicketRequest.java @@ -88,16 +88,25 @@ public static TicketIdStage builder() { } public interface TicketIdStage { + /** + * ticket_id + */ TagIdStage ticketId(@NotNull String ticketId); Builder from(TagTicketRequest other); } public interface TagIdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ AdminIdStage tagId(@NotNull String tagId); } public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ _FinalStage adminId(@NotNull String adminId); } @@ -127,7 +136,7 @@ public Builder from(TagTicketRequest other) { } /** - *

ticket_id

+ * ticket_id

ticket_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -138,7 +147,7 @@ public TagIdStage ticketId(@NotNull String ticketId) { } /** - *

The unique identifier for the tag which is given by Intercom

+ * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -149,7 +158,7 @@ public AdminIdStage tagId(@NotNull String tagId) { } /** - *

The unique identifier for the admin which is given by Intercom.

+ * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java index 469a4d0..3cdc95b 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/UntagContactRequest.java @@ -77,12 +77,18 @@ public static ContactIdStage builder() { } public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ TagIdStage contactId(@NotNull String contactId); Builder from(UntagContactRequest other); } public interface TagIdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ _FinalStage tagId(@NotNull String tagId); } @@ -109,7 +115,7 @@ public Builder from(UntagContactRequest other) { } /** - *

The unique identifier for the contact which is given by Intercom

+ * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -120,7 +126,7 @@ public TagIdStage contactId(@NotNull String contactId) { } /** - *

The unique identifier for the tag which is given by Intercom

+ * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java index 4999dd0..6a4faa6 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/UntagConversationRequest.java @@ -91,16 +91,25 @@ public static ConversationIdStage builder() { } public interface ConversationIdStage { + /** + * conversation_id + */ TagIdStage conversationId(@NotNull String conversationId); Builder from(UntagConversationRequest other); } public interface TagIdStage { + /** + * id + */ AdminIdStage tagId(@NotNull String tagId); } public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ _FinalStage adminId(@NotNull String adminId); } @@ -130,7 +139,7 @@ public Builder from(UntagConversationRequest other) { } /** - *

conversation_id

+ * conversation_id

conversation_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -141,7 +150,7 @@ public TagIdStage conversationId(@NotNull String conversationId) { } /** - *

id

+ * id

id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -152,7 +161,7 @@ public AdminIdStage tagId(@NotNull String tagId) { } /** - *

The unique identifier for the admin which is given by Intercom.

+ * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java b/src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java index a29cbcd..f26fb15 100644 --- a/src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/tags/requests/UntagTicketRequest.java @@ -89,16 +89,25 @@ public static TicketIdStage builder() { } public interface TicketIdStage { + /** + * ticket_id + */ TagIdStage ticketId(@NotNull String ticketId); Builder from(UntagTicketRequest other); } public interface TagIdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ AdminIdStage tagId(@NotNull String tagId); } public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ _FinalStage adminId(@NotNull String adminId); } @@ -128,7 +137,7 @@ public Builder from(UntagTicketRequest other) { } /** - *

ticket_id

+ * ticket_id

ticket_id

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -139,7 +148,7 @@ public TagIdStage ticketId(@NotNull String ticketId) { } /** - *

The unique identifier for the tag which is given by Intercom

+ * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -150,7 +159,7 @@ public AdminIdStage tagId(@NotNull String tagId) { } /** - *

The unique identifier for the admin which is given by Intercom.

+ * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/types/Tag.java b/src/main/java/com/intercom/api/resources/tags/types/Tag.java index 98bae10..86ff399 100644 --- a/src/main/java/com/intercom/api/resources/tags/types/Tag.java +++ b/src/main/java/com/intercom/api/resources/tags/types/Tag.java @@ -108,16 +108,25 @@ public static IdStage builder() { } public interface IdStage { + /** + * The id of the tag + */ NameStage id(@NotNull String id); Builder from(Tag other); } public interface NameStage { + /** + * The name of the tag + */ AppliedAtStage name(@NotNull String name); } public interface AppliedAtStage { + /** + * The time when the tag was applied to the object + */ AppliedByStage appliedAt(int appliedAt); } @@ -154,7 +163,7 @@ public Builder from(Tag other) { } /** - *

The id of the tag

+ * The id of the tag

The id of the tag

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -165,7 +174,7 @@ public NameStage id(@NotNull String id) { } /** - *

The name of the tag

+ * The name of the tag

The name of the tag

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -176,7 +185,7 @@ public AppliedAtStage name(@NotNull String name) { } /** - *

The time when the tag was applied to the object

+ * The time when the tag was applied to the object

The time when the tag was applied to the object

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java b/src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java index e170a8a..ee53855 100644 --- a/src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java +++ b/src/main/java/com/intercom/api/resources/tags/types/TagsCreateRequestBody.java @@ -33,6 +33,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((CreateOrUpdateTagRequest) this.value); diff --git a/src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java b/src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java index a9f592f..a402fa0 100644 --- a/src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java +++ b/src/main/java/com/intercom/api/resources/teams/requests/FindTeamRequest.java @@ -66,6 +66,9 @@ public static TeamIdStage builder() { } public interface TeamIdStage { + /** + * The unique identifier of a given team. + */ _FinalStage teamId(@NotNull String teamId); Builder from(FindTeamRequest other); @@ -91,7 +94,7 @@ public Builder from(FindTeamRequest other) { } /** - *

The unique identifier of a given team.

+ * The unique identifier of a given team.

The unique identifier of a given team.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/teams/types/Team.java b/src/main/java/com/intercom/api/resources/teams/types/Team.java index 707d487..3a166c1 100644 --- a/src/main/java/com/intercom/api/resources/teams/types/Team.java +++ b/src/main/java/com/intercom/api/resources/teams/types/Team.java @@ -117,18 +117,27 @@ public static IdStage builder() { } public interface IdStage { + /** + * The id of the team + */ NameStage id(@NotNull String id); Builder from(Team other); } public interface NameStage { + /** + * The name of the team + */ _FinalStage name(@NotNull String name); } public interface _FinalStage { Team build(); + /** + *

The list of admin IDs that are a part of the team.

+ */ _FinalStage adminIds(List adminIds); _FinalStage addAdminIds(Integer adminIds); @@ -165,7 +174,7 @@ public Builder from(Team other) { } /** - *

The id of the team

+ * The id of the team

The id of the team

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -176,7 +185,7 @@ public NameStage id(@NotNull String id) { } /** - *

The name of the team

+ * The name of the team

The name of the team

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -219,6 +228,9 @@ public _FinalStage addAdminIds(Integer adminIds) { return this; } + /** + *

The list of admin IDs that are a part of the team.

+ */ @java.lang.Override @JsonSetter(value = "admin_ids", nulls = Nulls.SKIP) public _FinalStage adminIds(List adminIds) { diff --git a/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java index a081d11..56fcbfa 100644 --- a/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java @@ -15,11 +15,11 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; -import com.intercom.api.resources.tickets.requests.CreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; import com.intercom.api.types.SearchRequest; diff --git a/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java index 40832be..5bb05fd 100644 --- a/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java @@ -6,11 +6,11 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; -import com.intercom.api.resources.tickets.requests.CreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.TicketReply; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java index 7fd2ea5..843c70a 100644 --- a/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java @@ -15,11 +15,11 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; -import com.intercom.api.resources.tickets.requests.CreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; import com.intercom.api.types.SearchRequest; diff --git a/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java b/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java index ccfdb01..cee318a 100644 --- a/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java @@ -6,11 +6,11 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; -import com.intercom.api.resources.tickets.requests.CreateTicketRequest; import com.intercom.api.resources.tickets.requests.FindTicketRequest; import com.intercom.api.resources.tickets.requests.ReplyToTicketRequest; import com.intercom.api.resources.tickets.requests.UpdateTicketRequest; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.CreateTicketRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.TicketReply; diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java index 2393315..6850516 100644 --- a/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java @@ -66,6 +66,9 @@ public static TicketIdStage builder() { } public interface TicketIdStage { + /** + * The unique identifier for the ticket which is given by Intercom. + */ _FinalStage ticketId(@NotNull String ticketId); Builder from(FindTicketRequest other); @@ -91,7 +94,7 @@ public Builder from(FindTicketRequest other) { } /** - *

The unique identifier for the ticket which is given by Intercom.

+ * The unique identifier for the ticket which is given by Intercom.

The unique identifier for the ticket which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java index 5faf4bc..9392614 100644 --- a/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java +++ b/src/main/java/com/intercom/api/resources/tickets/requests/UpdateTicketRequest.java @@ -154,6 +154,9 @@ public static TicketIdStage builder() { } public interface TicketIdStage { + /** + * The unique identifier for the ticket which is given by Intercom + */ _FinalStage ticketId(@NotNull String ticketId); Builder from(UpdateTicketRequest other); @@ -162,22 +165,37 @@ public interface TicketIdStage { public interface _FinalStage { UpdateTicketRequest build(); + /** + *

The attributes set on the ticket.

+ */ _FinalStage ticketAttributes(Optional> ticketAttributes); _FinalStage ticketAttributes(Map ticketAttributes); + /** + *

The state of the ticket.

+ */ _FinalStage state(Optional state); _FinalStage state(State state); + /** + *

Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

+ */ _FinalStage open(Optional open); _FinalStage open(Boolean open); + /** + *

Specify whether the ticket is visible to users.

+ */ _FinalStage isShared(Optional isShared); _FinalStage isShared(Boolean isShared); + /** + *

The time you want the ticket to reopen.

+ */ _FinalStage snoozedUntil(Optional snoozedUntil); _FinalStage snoozedUntil(Integer snoozedUntil); @@ -221,7 +239,7 @@ public Builder from(UpdateTicketRequest other) { } /** - *

The unique identifier for the ticket which is given by Intercom

+ * The unique identifier for the ticket which is given by Intercom

The unique identifier for the ticket which is given by Intercom

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -254,6 +272,9 @@ public _FinalStage snoozedUntil(Integer snoozedUntil) { return this; } + /** + *

The time you want the ticket to reopen.

+ */ @java.lang.Override @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) public _FinalStage snoozedUntil(Optional snoozedUntil) { @@ -271,6 +292,9 @@ public _FinalStage isShared(Boolean isShared) { return this; } + /** + *

Specify whether the ticket is visible to users.

+ */ @java.lang.Override @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) public _FinalStage isShared(Optional isShared) { @@ -288,6 +312,9 @@ public _FinalStage open(Boolean open) { return this; } + /** + *

Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

+ */ @java.lang.Override @JsonSetter(value = "open", nulls = Nulls.SKIP) public _FinalStage open(Optional open) { @@ -305,6 +332,9 @@ public _FinalStage state(State state) { return this; } + /** + *

The state of the ticket.

+ */ @java.lang.Override @JsonSetter(value = "state", nulls = Nulls.SKIP) public _FinalStage state(Optional state) { @@ -322,6 +352,9 @@ public _FinalStage ticketAttributes(Map ticketAttributes) { return this; } + /** + *

The attributes set on the ticket.

+ */ @java.lang.Override @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) public _FinalStage ticketAttributes(Optional> ticketAttributes) { @@ -499,6 +532,9 @@ public Builder from(Assignment other) { return this; } + /** + *

The ID of the admin performing the action.

+ */ @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) public Builder adminId(Optional adminId) { this.adminId = adminId; @@ -510,6 +546,9 @@ public Builder adminId(String adminId) { return this; } + /** + *

The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

+ */ @JsonSetter(value = "assignee_id", nulls = Nulls.SKIP) public Builder assigneeId(Optional assigneeId) { this.assigneeId = assigneeId; 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 42d52dc..4fb4b46 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 @@ -307,20 +307,32 @@ public static IdStage builder() { } public interface IdStage { + /** + * The unique identifier for the ticket which is given by Intercom. + */ TicketIdStage id(@NotNull String id); Builder from(Ticket other); } public interface TicketIdStage { + /** + * The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. + */ CategoryStage ticketId(@NotNull String ticketId); } public interface CategoryStage { + /** + * Category of the Ticket. + */ TicketStateStage category(@NotNull Category category); } public interface TicketStateStage { + /** + * The state the ticket is currently in + */ TicketTypeStage ticketState(@NotNull TicketState ticketState); } @@ -341,26 +353,44 @@ public interface _FinalStage { _FinalStage ticketAttributes(String key, Object value); + /** + *

The id representing the admin assigned to the ticket.

+ */ _FinalStage adminAssigneeId(Optional adminAssigneeId); _FinalStage adminAssigneeId(String adminAssigneeId); + /** + *

The id representing the team assigned to the ticket.

+ */ _FinalStage teamAssigneeId(Optional teamAssigneeId); _FinalStage teamAssigneeId(String teamAssigneeId); + /** + *

The time the ticket was created as a UTC Unix timestamp.

+ */ _FinalStage createdAt(Optional createdAt); _FinalStage createdAt(Integer createdAt); + /** + *

The last time the ticket was updated as a UTC Unix timestamp.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); + /** + *

Whether or not the ticket is open. If false, the ticket is closed.

+ */ _FinalStage open(Optional open); _FinalStage open(Boolean open); + /** + *

The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

+ */ _FinalStage snoozedUntil(Optional snoozedUntil); _FinalStage snoozedUntil(Integer snoozedUntil); @@ -373,14 +403,23 @@ public interface _FinalStage { _FinalStage ticketParts(TicketParts ticketParts); + /** + *

Whether or not the ticket is shared with the customer.

+ */ _FinalStage isShared(Optional isShared); _FinalStage isShared(Boolean isShared); + /** + *

The state the ticket is currently in, in a human readable form - visible in Intercom

+ */ _FinalStage ticketStateInternalLabel(Optional ticketStateInternalLabel); _FinalStage ticketStateInternalLabel(String ticketStateInternalLabel); + /** + *

The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal.

+ */ _FinalStage ticketStateExternalLabel(Optional ticketStateExternalLabel); _FinalStage ticketStateExternalLabel(String ticketStateExternalLabel); @@ -460,7 +499,7 @@ public Builder from(Ticket other) { } /** - *

The unique identifier for the ticket which is given by Intercom.

+ * The unique identifier for the ticket which is given by Intercom.

The unique identifier for the ticket which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -471,7 +510,7 @@ public TicketIdStage id(@NotNull String id) { } /** - *

The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.

+ * The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.

The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -482,7 +521,7 @@ public CategoryStage ticketId(@NotNull String ticketId) { } /** - *

Category of the Ticket.

+ * Category of the Ticket.

Category of the Ticket.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -493,7 +532,7 @@ public TicketStateStage category(@NotNull Category category) { } /** - *

The state the ticket is currently in

+ * The state the ticket is currently in

The state the ticket is currently in

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -527,6 +566,9 @@ public _FinalStage ticketStateExternalLabel(String ticketStateExternalLabel) { return this; } + /** + *

The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal.

+ */ @java.lang.Override @JsonSetter(value = "ticket_state_external_label", nulls = Nulls.SKIP) public _FinalStage ticketStateExternalLabel(Optional ticketStateExternalLabel) { @@ -544,6 +586,9 @@ public _FinalStage ticketStateInternalLabel(String ticketStateInternalLabel) { return this; } + /** + *

The state the ticket is currently in, in a human readable form - visible in Intercom

+ */ @java.lang.Override @JsonSetter(value = "ticket_state_internal_label", nulls = Nulls.SKIP) public _FinalStage ticketStateInternalLabel(Optional ticketStateInternalLabel) { @@ -561,6 +606,9 @@ public _FinalStage isShared(Boolean isShared) { return this; } + /** + *

Whether or not the ticket is shared with the customer.

+ */ @java.lang.Override @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) public _FinalStage isShared(Optional isShared) { @@ -604,6 +652,9 @@ public _FinalStage snoozedUntil(Integer snoozedUntil) { return this; } + /** + *

The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

+ */ @java.lang.Override @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) public _FinalStage snoozedUntil(Optional snoozedUntil) { @@ -621,6 +672,9 @@ public _FinalStage open(Boolean open) { return this; } + /** + *

Whether or not the ticket is open. If false, the ticket is closed.

+ */ @java.lang.Override @JsonSetter(value = "open", nulls = Nulls.SKIP) public _FinalStage open(Optional open) { @@ -638,6 +692,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

The last time the ticket was updated as a UTC Unix timestamp.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { @@ -655,6 +712,9 @@ public _FinalStage createdAt(Integer createdAt) { return this; } + /** + *

The time the ticket was created as a UTC Unix timestamp.

+ */ @java.lang.Override @JsonSetter(value = "created_at", nulls = Nulls.SKIP) public _FinalStage createdAt(Optional createdAt) { @@ -672,6 +732,9 @@ public _FinalStage teamAssigneeId(String teamAssigneeId) { return this; } + /** + *

The id representing the team assigned to the ticket.

+ */ @java.lang.Override @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) public _FinalStage teamAssigneeId(Optional teamAssigneeId) { @@ -689,6 +752,9 @@ public _FinalStage adminAssigneeId(String adminAssigneeId) { return this; } + /** + *

The id representing the admin assigned to the ticket.

+ */ @java.lang.Override @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) public _FinalStage adminAssigneeId(Optional adminAssigneeId) { diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java index 925d617..b1406f9 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketContacts.java @@ -90,6 +90,9 @@ public Builder from(TicketContacts other) { return this; } + /** + *

The list of contacts affected by this ticket.

+ */ @JsonSetter(value = "contacts", nulls = Nulls.SKIP) public Builder contacts(List contacts) { this.contacts.clear(); diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java index 77d5968..fd9f787 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketPart.java @@ -236,38 +236,62 @@ public static IdStage builder() { } public interface IdStage { + /** + * The id representing the ticket part. + */ PartTypeStage id(@NotNull String id); Builder from(TicketPart other); } public interface PartTypeStage { + /** + * The type of ticket part. + */ TicketStateStage partType(@NotNull String partType); } public interface TicketStateStage { + /** + * The state of the ticket. + */ CreatedAtStage ticketState(@NotNull TicketState ticketState); } public interface CreatedAtStage { + /** + * The time the ticket part was created. + */ _FinalStage createdAt(int createdAt); } public interface _FinalStage { TicketPart build(); + /** + *

The message body, which may contain HTML.

+ */ _FinalStage body(Optional body); _FinalStage body(String body); + /** + *

The previous state of the ticket.

+ */ _FinalStage previousTicketState(Optional previousTicketState); _FinalStage previousTicketState(PreviousTicketState previousTicketState); + /** + *

The last time the ticket part was updated.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); + /** + *

The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.)

+ */ _FinalStage assignedTo(Optional assignedTo); _FinalStage assignedTo(Reference assignedTo); @@ -276,14 +300,23 @@ public interface _FinalStage { _FinalStage author(TicketPartAuthor author); + /** + *

A list of attachments for the part.

+ */ _FinalStage attachments(Optional> attachments); _FinalStage attachments(List attachments); + /** + *

The external id of the ticket part

+ */ _FinalStage externalId(Optional externalId); _FinalStage externalId(String externalId); + /** + *

Whether or not the ticket part has been redacted.

+ */ _FinalStage redacted(Optional redacted); _FinalStage redacted(Boolean redacted); @@ -338,7 +371,7 @@ public Builder from(TicketPart other) { } /** - *

The id representing the ticket part.

+ * The id representing the ticket part.

The id representing the ticket part.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -349,7 +382,7 @@ public PartTypeStage id(@NotNull String id) { } /** - *

The type of ticket part.

+ * The type of ticket part.

The type of ticket part.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -360,7 +393,7 @@ public TicketStateStage partType(@NotNull String partType) { } /** - *

The state of the ticket.

+ * The state of the ticket.

The state of the ticket.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -371,7 +404,7 @@ public CreatedAtStage ticketState(@NotNull TicketState ticketState) { } /** - *

The time the ticket part was created.

+ * The time the ticket part was created.

The time the ticket part was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -391,6 +424,9 @@ public _FinalStage redacted(Boolean redacted) { return this; } + /** + *

Whether or not the ticket part has been redacted.

+ */ @java.lang.Override @JsonSetter(value = "redacted", nulls = Nulls.SKIP) public _FinalStage redacted(Optional redacted) { @@ -408,6 +444,9 @@ public _FinalStage externalId(String externalId) { return this; } + /** + *

The external id of the ticket part

+ */ @java.lang.Override @JsonSetter(value = "external_id", nulls = Nulls.SKIP) public _FinalStage externalId(Optional externalId) { @@ -425,6 +464,9 @@ public _FinalStage attachments(List attachments) { return this; } + /** + *

A list of attachments for the part.

+ */ @java.lang.Override @JsonSetter(value = "attachments", nulls = Nulls.SKIP) public _FinalStage attachments(Optional> attachments) { @@ -455,6 +497,9 @@ public _FinalStage assignedTo(Reference assignedTo) { return this; } + /** + *

The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.)

+ */ @java.lang.Override @JsonSetter(value = "assigned_to", nulls = Nulls.SKIP) public _FinalStage assignedTo(Optional assignedTo) { @@ -472,6 +517,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

The last time the ticket part was updated.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { @@ -489,6 +537,9 @@ public _FinalStage previousTicketState(PreviousTicketState previousTicketState) return this; } + /** + *

The previous state of the ticket.

+ */ @java.lang.Override @JsonSetter(value = "previous_ticket_state", nulls = Nulls.SKIP) public _FinalStage previousTicketState(Optional previousTicketState) { @@ -506,6 +557,9 @@ public _FinalStage body(String body) { return this; } + /** + *

The message body, which may contain HTML.

+ */ @java.lang.Override @JsonSetter(value = "body", nulls = Nulls.SKIP) public _FinalStage body(Optional body) { diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketType.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketType.java index 02e45f4..60bc648 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/TicketType.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketType.java @@ -205,28 +205,46 @@ public static IdStage builder() { } public interface IdStage { + /** + * The id representing the ticket type. + */ CategoryStage id(@NotNull String id); Builder from(TicketType other); } public interface CategoryStage { + /** + * Category of the Ticket Type. + */ NameStage category(@NotNull Category category); } public interface NameStage { + /** + * The name of the ticket type + */ DescriptionStage name(@NotNull String name); } public interface DescriptionStage { + /** + * The description of the ticket type + */ IconStage description(@NotNull String description); } public interface IconStage { + /** + * The icon of the ticket type + */ WorkspaceIdStage icon(@NotNull String icon); } public interface WorkspaceIdStage { + /** + * The id of the workspace that the ticket type belongs to. + */ TicketTypeAttributesStage workspaceId(@NotNull String workspaceId); } @@ -235,16 +253,25 @@ public interface TicketTypeAttributesStage { } public interface ArchivedStage { + /** + * Whether the ticket type is archived or not. + */ CreatedAtStage archived(boolean archived); } public interface CreatedAtStage { + /** + * The date and time the ticket type was created. + */ _FinalStage createdAt(int createdAt); } public interface _FinalStage { TicketType build(); + /** + *

The date and time the ticket type was last updated.

+ */ _FinalStage updatedAt(Optional updatedAt); _FinalStage updatedAt(Integer updatedAt); @@ -303,7 +330,7 @@ public Builder from(TicketType other) { } /** - *

The id representing the ticket type.

+ * The id representing the ticket type.

The id representing the ticket type.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -314,7 +341,7 @@ public CategoryStage id(@NotNull String id) { } /** - *

Category of the Ticket Type.

+ * Category of the Ticket Type.

Category of the Ticket Type.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -325,7 +352,7 @@ public NameStage category(@NotNull Category category) { } /** - *

The name of the ticket type

+ * The name of the ticket type

The name of the ticket type

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -336,7 +363,7 @@ public DescriptionStage name(@NotNull String name) { } /** - *

The description of the ticket type

+ * The description of the ticket type

The description of the ticket type

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -347,7 +374,7 @@ public IconStage description(@NotNull String description) { } /** - *

The icon of the ticket type

+ * The icon of the ticket type

The icon of the ticket type

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -358,7 +385,7 @@ public WorkspaceIdStage icon(@NotNull String icon) { } /** - *

The id of the workspace that the ticket type belongs to.

+ * The id of the workspace that the ticket type belongs to.

The id of the workspace that the ticket type belongs to.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -377,7 +404,7 @@ public ArchivedStage ticketTypeAttributes(@NotNull TicketTypeAttributeList ticke } /** - *

Whether the ticket type is archived or not.

+ * Whether the ticket type is archived or not.

Whether the ticket type is archived or not.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -388,7 +415,7 @@ public CreatedAtStage archived(boolean archived) { } /** - *

The date and time the ticket type was created.

+ * The date and time the ticket type was created.

The date and time the ticket type was created.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -408,6 +435,9 @@ public _FinalStage updatedAt(Integer updatedAt) { return this; } + /** + *

The date and time the ticket type was last updated.

+ */ @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) public _FinalStage updatedAt(Optional updatedAt) { diff --git a/src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java b/src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java index c2d2378..2ea12c7 100644 --- a/src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java +++ b/src/main/java/com/intercom/api/resources/tickets/types/TicketsReplyRequestBody.java @@ -31,6 +31,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((ContactReplyTicketRequest) this.value); diff --git a/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java index 9d3c518..2ee983d 100644 --- a/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java +++ b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/CreateTicketTypeAttributeRequest.java @@ -213,50 +213,83 @@ public static TicketTypeIdStage builder() { } public interface TicketTypeIdStage { + /** + * The unique identifier for the ticket type which is given by Intercom. + */ NameStage ticketTypeId(@NotNull String ticketTypeId); Builder from(CreateTicketTypeAttributeRequest other); } public interface NameStage { + /** + * The name of the ticket type attribute + */ DescriptionStage name(@NotNull String name); } public interface DescriptionStage { + /** + * The description of the attribute presented to the teammate or contact + */ DataTypeStage description(@NotNull String description); } public interface DataTypeStage { + /** + * The data type of the attribute + */ _FinalStage dataType(@NotNull DataType dataType); } public interface _FinalStage { CreateTicketTypeAttributeRequest build(); + /** + *

Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox.

+ */ _FinalStage requiredToCreate(Optional requiredToCreate); _FinalStage requiredToCreate(Boolean requiredToCreate); + /** + *

Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger.

+ */ _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts); _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContacts); + /** + *

Whether the attribute is visible to teammates when creating a ticket in Inbox.

+ */ _FinalStage visibleOnCreate(Optional visibleOnCreate); _FinalStage visibleOnCreate(Boolean visibleOnCreate); + /** + *

Whether the attribute is visible to contacts when creating a ticket in Messenger.

+ */ _FinalStage visibleToContacts(Optional visibleToContacts); _FinalStage visibleToContacts(Boolean visibleToContacts); + /** + *

Whether the attribute allows multiple lines of text (only applicable to string attributes)

+ */ _FinalStage multiline(Optional multiline); _FinalStage multiline(Boolean multiline); + /** + *

A comma delimited list of items for the attribute value (only applicable to list attributes)

+ */ _FinalStage listItems(Optional listItems); _FinalStage listItems(String listItems); + /** + *

Whether the attribute allows multiple files to be attached to it (only applicable to file attributes)

+ */ _FinalStage allowMultipleValues(Optional allowMultipleValues); _FinalStage allowMultipleValues(Boolean allowMultipleValues); @@ -309,7 +342,7 @@ public Builder from(CreateTicketTypeAttributeRequest other) { } /** - *

The unique identifier for the ticket type which is given by Intercom.

+ * The unique identifier for the ticket type which is given by Intercom.

The unique identifier for the ticket type which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -320,7 +353,7 @@ public NameStage ticketTypeId(@NotNull String ticketTypeId) { } /** - *

The name of the ticket type attribute

+ * The name of the ticket type attribute

The name of the ticket type attribute

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -331,7 +364,7 @@ public DescriptionStage name(@NotNull String name) { } /** - *

The description of the attribute presented to the teammate or contact

+ * The description of the attribute presented to the teammate or contact

The description of the attribute presented to the teammate or contact

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -342,7 +375,7 @@ public DataTypeStage description(@NotNull String description) { } /** - *

The data type of the attribute

+ * The data type of the attribute

The data type of the attribute

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -362,6 +395,9 @@ public _FinalStage allowMultipleValues(Boolean allowMultipleValues) { return this; } + /** + *

Whether the attribute allows multiple files to be attached to it (only applicable to file attributes)

+ */ @java.lang.Override @JsonSetter(value = "allow_multiple_values", nulls = Nulls.SKIP) public _FinalStage allowMultipleValues(Optional allowMultipleValues) { @@ -379,6 +415,9 @@ public _FinalStage listItems(String listItems) { return this; } + /** + *

A comma delimited list of items for the attribute value (only applicable to list attributes)

+ */ @java.lang.Override @JsonSetter(value = "list_items", nulls = Nulls.SKIP) public _FinalStage listItems(Optional listItems) { @@ -396,6 +435,9 @@ public _FinalStage multiline(Boolean multiline) { return this; } + /** + *

Whether the attribute allows multiple lines of text (only applicable to string attributes)

+ */ @java.lang.Override @JsonSetter(value = "multiline", nulls = Nulls.SKIP) public _FinalStage multiline(Optional multiline) { @@ -413,6 +455,9 @@ public _FinalStage visibleToContacts(Boolean visibleToContacts) { return this; } + /** + *

Whether the attribute is visible to contacts when creating a ticket in Messenger.

+ */ @java.lang.Override @JsonSetter(value = "visible_to_contacts", nulls = Nulls.SKIP) public _FinalStage visibleToContacts(Optional visibleToContacts) { @@ -430,6 +475,9 @@ public _FinalStage visibleOnCreate(Boolean visibleOnCreate) { return this; } + /** + *

Whether the attribute is visible to teammates when creating a ticket in Inbox.

+ */ @java.lang.Override @JsonSetter(value = "visible_on_create", nulls = Nulls.SKIP) public _FinalStage visibleOnCreate(Optional visibleOnCreate) { @@ -447,6 +495,9 @@ public _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContac return this; } + /** + *

Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger.

+ */ @java.lang.Override @JsonSetter(value = "required_to_create_for_contacts", nulls = Nulls.SKIP) public _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts) { @@ -464,6 +515,9 @@ public _FinalStage requiredToCreate(Boolean requiredToCreate) { return this; } + /** + *

Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox.

+ */ @java.lang.Override @JsonSetter(value = "required_to_create", nulls = Nulls.SKIP) public _FinalStage requiredToCreate(Optional requiredToCreate) { diff --git a/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java index ccff175..6961328 100644 --- a/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java +++ b/src/main/java/com/intercom/api/resources/tickettypes/attributes/requests/UpdateTicketTypeAttributeRequest.java @@ -225,54 +225,90 @@ public static TicketTypeIdStage builder() { } public interface TicketTypeIdStage { + /** + * The unique identifier for the ticket type which is given by Intercom. + */ AttributeIdStage ticketTypeId(@NotNull String ticketTypeId); Builder from(UpdateTicketTypeAttributeRequest other); } public interface AttributeIdStage { + /** + * The unique identifier for the ticket type attribute which is given by Intercom. + */ _FinalStage attributeId(@NotNull String attributeId); } public interface _FinalStage { UpdateTicketTypeAttributeRequest build(); + /** + *

The name of the ticket type attribute

+ */ _FinalStage name(Optional name); _FinalStage name(String name); + /** + *

The description of the attribute presented to the teammate or contact

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox.

+ */ _FinalStage requiredToCreate(Optional requiredToCreate); _FinalStage requiredToCreate(Boolean requiredToCreate); + /** + *

Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger.

+ */ _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts); _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContacts); + /** + *

Whether the attribute is visible to teammates when creating a ticket in Inbox.

+ */ _FinalStage visibleOnCreate(Optional visibleOnCreate); _FinalStage visibleOnCreate(Boolean visibleOnCreate); + /** + *

Whether the attribute is visible to contacts when creating a ticket in Messenger.

+ */ _FinalStage visibleToContacts(Optional visibleToContacts); _FinalStage visibleToContacts(Boolean visibleToContacts); + /** + *

Whether the attribute allows multiple lines of text (only applicable to string attributes)

+ */ _FinalStage multiline(Optional multiline); _FinalStage multiline(Boolean multiline); + /** + *

A comma delimited list of items for the attribute value (only applicable to list attributes)

+ */ _FinalStage listItems(Optional listItems); _FinalStage listItems(String listItems); + /** + *

Whether the attribute allows multiple files to be attached to it (only applicable to file attributes)

+ */ _FinalStage allowMultipleValues(Optional allowMultipleValues); _FinalStage allowMultipleValues(Boolean allowMultipleValues); + /** + *

Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets)

+ */ _FinalStage archived(Optional archived); _FinalStage archived(Boolean archived); @@ -327,7 +363,7 @@ public Builder from(UpdateTicketTypeAttributeRequest other) { } /** - *

The unique identifier for the ticket type which is given by Intercom.

+ * The unique identifier for the ticket type which is given by Intercom.

The unique identifier for the ticket type which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -338,7 +374,7 @@ public AttributeIdStage ticketTypeId(@NotNull String ticketTypeId) { } /** - *

The unique identifier for the ticket type attribute which is given by Intercom.

+ * The unique identifier for the ticket type attribute which is given by Intercom.

The unique identifier for the ticket type attribute which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -358,6 +394,9 @@ public _FinalStage archived(Boolean archived) { return this; } + /** + *

Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets)

+ */ @java.lang.Override @JsonSetter(value = "archived", nulls = Nulls.SKIP) public _FinalStage archived(Optional archived) { @@ -375,6 +414,9 @@ public _FinalStage allowMultipleValues(Boolean allowMultipleValues) { return this; } + /** + *

Whether the attribute allows multiple files to be attached to it (only applicable to file attributes)

+ */ @java.lang.Override @JsonSetter(value = "allow_multiple_values", nulls = Nulls.SKIP) public _FinalStage allowMultipleValues(Optional allowMultipleValues) { @@ -392,6 +434,9 @@ public _FinalStage listItems(String listItems) { return this; } + /** + *

A comma delimited list of items for the attribute value (only applicable to list attributes)

+ */ @java.lang.Override @JsonSetter(value = "list_items", nulls = Nulls.SKIP) public _FinalStage listItems(Optional listItems) { @@ -409,6 +454,9 @@ public _FinalStage multiline(Boolean multiline) { return this; } + /** + *

Whether the attribute allows multiple lines of text (only applicable to string attributes)

+ */ @java.lang.Override @JsonSetter(value = "multiline", nulls = Nulls.SKIP) public _FinalStage multiline(Optional multiline) { @@ -426,6 +474,9 @@ public _FinalStage visibleToContacts(Boolean visibleToContacts) { return this; } + /** + *

Whether the attribute is visible to contacts when creating a ticket in Messenger.

+ */ @java.lang.Override @JsonSetter(value = "visible_to_contacts", nulls = Nulls.SKIP) public _FinalStage visibleToContacts(Optional visibleToContacts) { @@ -443,6 +494,9 @@ public _FinalStage visibleOnCreate(Boolean visibleOnCreate) { return this; } + /** + *

Whether the attribute is visible to teammates when creating a ticket in Inbox.

+ */ @java.lang.Override @JsonSetter(value = "visible_on_create", nulls = Nulls.SKIP) public _FinalStage visibleOnCreate(Optional visibleOnCreate) { @@ -460,6 +514,9 @@ public _FinalStage requiredToCreateForContacts(Boolean requiredToCreateForContac return this; } + /** + *

Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger.

+ */ @java.lang.Override @JsonSetter(value = "required_to_create_for_contacts", nulls = Nulls.SKIP) public _FinalStage requiredToCreateForContacts(Optional requiredToCreateForContacts) { @@ -477,6 +534,9 @@ public _FinalStage requiredToCreate(Boolean requiredToCreate) { return this; } + /** + *

Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox.

+ */ @java.lang.Override @JsonSetter(value = "required_to_create", nulls = Nulls.SKIP) public _FinalStage requiredToCreate(Optional requiredToCreate) { @@ -494,6 +554,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the attribute presented to the teammate or contact

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { @@ -511,6 +574,9 @@ public _FinalStage name(String name) { return this; } + /** + *

The name of the ticket type attribute

+ */ @java.lang.Override @JsonSetter(value = "name", nulls = Nulls.SKIP) public _FinalStage name(Optional name) { diff --git a/src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java index 08c7002..09cd615 100644 --- a/src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java +++ b/src/main/java/com/intercom/api/resources/tickettypes/requests/CreateTicketTypeRequest.java @@ -124,6 +124,9 @@ public static NameStage builder() { } public interface NameStage { + /** + * The name of the ticket type. + */ _FinalStage name(@NotNull String name); Builder from(CreateTicketTypeRequest other); @@ -132,18 +135,30 @@ public interface NameStage { public interface _FinalStage { CreateTicketTypeRequest build(); + /** + *

The description of the ticket type.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

Category of the Ticket Type.

+ */ _FinalStage category(Optional category); _FinalStage category(Category category); + /** + *

The icon of the ticket type.

+ */ _FinalStage icon(Optional icon); _FinalStage icon(String icon); + /** + *

Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute.

+ */ _FinalStage isInternal(Optional isInternal); _FinalStage isInternal(Boolean isInternal); @@ -177,7 +192,7 @@ public Builder from(CreateTicketTypeRequest other) { } /** - *

The name of the ticket type.

+ * The name of the ticket type.

The name of the ticket type.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -197,6 +212,9 @@ public _FinalStage isInternal(Boolean isInternal) { return this; } + /** + *

Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute.

+ */ @java.lang.Override @JsonSetter(value = "is_internal", nulls = Nulls.SKIP) public _FinalStage isInternal(Optional isInternal) { @@ -214,6 +232,9 @@ public _FinalStage icon(String icon) { return this; } + /** + *

The icon of the ticket type.

+ */ @java.lang.Override @JsonSetter(value = "icon", nulls = Nulls.SKIP) public _FinalStage icon(Optional icon) { @@ -231,6 +252,9 @@ public _FinalStage category(Category category) { return this; } + /** + *

Category of the Ticket Type.

+ */ @java.lang.Override @JsonSetter(value = "category", nulls = Nulls.SKIP) public _FinalStage category(Optional category) { @@ -248,6 +272,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the ticket type.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { diff --git a/src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java index 4551ea7..0915a7c 100644 --- a/src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java +++ b/src/main/java/com/intercom/api/resources/tickettypes/requests/FindTicketTypeRequest.java @@ -66,6 +66,9 @@ public static TicketTypeIdStage builder() { } public interface TicketTypeIdStage { + /** + * The unique identifier for the ticket type which is given by Intercom. + */ _FinalStage ticketTypeId(@NotNull String ticketTypeId); Builder from(FindTicketTypeRequest other); @@ -91,7 +94,7 @@ public Builder from(FindTicketTypeRequest other) { } /** - *

The unique identifier for the ticket type which is given by Intercom.

+ * The unique identifier for the ticket type which is given by Intercom.

The unique identifier for the ticket type which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override diff --git a/src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java b/src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java index ff8bbb5..5a30b0d 100644 --- a/src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java +++ b/src/main/java/com/intercom/api/resources/tickettypes/requests/UpdateTicketTypeRequest.java @@ -157,6 +157,9 @@ public static TicketTypeIdStage builder() { } public interface TicketTypeIdStage { + /** + * The unique identifier for the ticket type which is given by Intercom. + */ _FinalStage ticketTypeId(@NotNull String ticketTypeId); Builder from(UpdateTicketTypeRequest other); @@ -165,26 +168,44 @@ public interface TicketTypeIdStage { public interface _FinalStage { UpdateTicketTypeRequest build(); + /** + *

The name of the ticket type.

+ */ _FinalStage name(Optional name); _FinalStage name(String name); + /** + *

The description of the ticket type.

+ */ _FinalStage description(Optional description); _FinalStage description(String description); + /** + *

Category of the Ticket Type.

+ */ _FinalStage category(Optional category); _FinalStage category(Category category); + /** + *

The icon of the ticket type.

+ */ _FinalStage icon(Optional icon); _FinalStage icon(String icon); + /** + *

The archived status of the ticket type.

+ */ _FinalStage archived(Optional archived); _FinalStage archived(Boolean archived); + /** + *

Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute.

+ */ _FinalStage isInternal(Optional isInternal); _FinalStage isInternal(Boolean isInternal); @@ -224,7 +245,7 @@ public Builder from(UpdateTicketTypeRequest other) { } /** - *

The unique identifier for the ticket type which is given by Intercom.

+ * The unique identifier for the ticket type which is given by Intercom.

The unique identifier for the ticket type which is given by Intercom.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -244,6 +265,9 @@ public _FinalStage isInternal(Boolean isInternal) { return this; } + /** + *

Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute.

+ */ @java.lang.Override @JsonSetter(value = "is_internal", nulls = Nulls.SKIP) public _FinalStage isInternal(Optional isInternal) { @@ -261,6 +285,9 @@ public _FinalStage archived(Boolean archived) { return this; } + /** + *

The archived status of the ticket type.

+ */ @java.lang.Override @JsonSetter(value = "archived", nulls = Nulls.SKIP) public _FinalStage archived(Optional archived) { @@ -278,6 +305,9 @@ public _FinalStage icon(String icon) { return this; } + /** + *

The icon of the ticket type.

+ */ @java.lang.Override @JsonSetter(value = "icon", nulls = Nulls.SKIP) public _FinalStage icon(Optional icon) { @@ -295,6 +325,9 @@ public _FinalStage category(Category category) { return this; } + /** + *

Category of the Ticket Type.

+ */ @java.lang.Override @JsonSetter(value = "category", nulls = Nulls.SKIP) public _FinalStage category(Optional category) { @@ -312,6 +345,9 @@ public _FinalStage description(String description) { return this; } + /** + *

The description of the ticket type.

+ */ @java.lang.Override @JsonSetter(value = "description", nulls = Nulls.SKIP) public _FinalStage description(Optional description) { @@ -329,6 +365,9 @@ public _FinalStage name(String name) { return this; } + /** + *

The name of the ticket type.

+ */ @java.lang.Override @JsonSetter(value = "name", nulls = Nulls.SKIP) public _FinalStage name(Optional name) { diff --git a/src/main/java/com/intercom/api/resources/unstable/AsyncUnstableClient.java b/src/main/java/com/intercom/api/resources/unstable/AsyncUnstableClient.java new file mode 100644 index 0000000..55350be --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/AsyncUnstableClient.java @@ -0,0 +1,240 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.resources.unstable.admins.AsyncAdminsClient; +import com.intercom.api.resources.unstable.aicontent.AsyncAiContentClient; +import com.intercom.api.resources.unstable.articles.AsyncArticlesClient; +import com.intercom.api.resources.unstable.awaystatusreasons.AsyncAwayStatusReasonsClient; +import com.intercom.api.resources.unstable.companies.AsyncCompaniesClient; +import com.intercom.api.resources.unstable.contacts.AsyncContactsClient; +import com.intercom.api.resources.unstable.conversations.AsyncConversationsClient; +import com.intercom.api.resources.unstable.customchannelevents.AsyncCustomChannelEventsClient; +import com.intercom.api.resources.unstable.customobjectinstances.AsyncCustomObjectInstancesClient; +import com.intercom.api.resources.unstable.dataattributes.AsyncDataAttributesClient; +import com.intercom.api.resources.unstable.dataevents.AsyncDataEventsClient; +import com.intercom.api.resources.unstable.dataexport.AsyncDataExportClient; +import com.intercom.api.resources.unstable.export.AsyncExportClient; +import com.intercom.api.resources.unstable.helpcenter.AsyncHelpCenterClient; +import com.intercom.api.resources.unstable.jobs.AsyncJobsClient; +import com.intercom.api.resources.unstable.messages.AsyncMessagesClient; +import com.intercom.api.resources.unstable.news.AsyncNewsClient; +import com.intercom.api.resources.unstable.notes.AsyncNotesClient; +import com.intercom.api.resources.unstable.segments.AsyncSegmentsClient; +import com.intercom.api.resources.unstable.subscriptiontypes.AsyncSubscriptionTypesClient; +import com.intercom.api.resources.unstable.switch_.AsyncSwitchClient; +import com.intercom.api.resources.unstable.tags.AsyncTagsClient; +import com.intercom.api.resources.unstable.teams.AsyncTeamsClient; +import com.intercom.api.resources.unstable.tickets.AsyncTicketsClient; +import com.intercom.api.resources.unstable.ticketstates.AsyncTicketStatesClient; +import com.intercom.api.resources.unstable.tickettypeattributes.AsyncTicketTypeAttributesClient; +import com.intercom.api.resources.unstable.tickettypes.AsyncTicketTypesClient; +import com.intercom.api.resources.unstable.visitors.AsyncVisitorsClient; +import java.util.function.Supplier; + +public class AsyncUnstableClient { + protected final ClientOptions clientOptions; + + protected final Supplier adminsClient; + + protected final Supplier aiContentClient; + + protected final Supplier articlesClient; + + protected final Supplier awayStatusReasonsClient; + + protected final Supplier exportClient; + + protected final Supplier helpCenterClient; + + protected final Supplier companiesClient; + + protected final Supplier contactsClient; + + protected final Supplier notesClient; + + protected final Supplier subscriptionTypesClient; + + protected final Supplier tagsClient; + + protected final Supplier conversationsClient; + + protected final Supplier customChannelEventsClient; + + protected final Supplier customObjectInstancesClient; + + protected final Supplier dataAttributesClient; + + protected final Supplier dataEventsClient; + + protected final Supplier dataExportClient; + + protected final Supplier jobsClient; + + protected final Supplier messagesClient; + + protected final Supplier newsClient; + + protected final Supplier segmentsClient; + + protected final Supplier switchClient; + + protected final Supplier teamsClient; + + protected final Supplier ticketStatesClient; + + protected final Supplier ticketTypeAttributesClient; + + protected final Supplier ticketTypesClient; + + protected final Supplier ticketsClient; + + protected final Supplier visitorsClient; + + public AsyncUnstableClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.adminsClient = Suppliers.memoize(() -> new AsyncAdminsClient(clientOptions)); + this.aiContentClient = Suppliers.memoize(() -> new AsyncAiContentClient(clientOptions)); + this.articlesClient = Suppliers.memoize(() -> new AsyncArticlesClient(clientOptions)); + this.awayStatusReasonsClient = Suppliers.memoize(() -> new AsyncAwayStatusReasonsClient(clientOptions)); + this.exportClient = Suppliers.memoize(() -> new AsyncExportClient(clientOptions)); + this.helpCenterClient = Suppliers.memoize(() -> new AsyncHelpCenterClient(clientOptions)); + this.companiesClient = Suppliers.memoize(() -> new AsyncCompaniesClient(clientOptions)); + this.contactsClient = Suppliers.memoize(() -> new AsyncContactsClient(clientOptions)); + this.notesClient = Suppliers.memoize(() -> new AsyncNotesClient(clientOptions)); + this.subscriptionTypesClient = Suppliers.memoize(() -> new AsyncSubscriptionTypesClient(clientOptions)); + this.tagsClient = Suppliers.memoize(() -> new AsyncTagsClient(clientOptions)); + this.conversationsClient = Suppliers.memoize(() -> new AsyncConversationsClient(clientOptions)); + this.customChannelEventsClient = Suppliers.memoize(() -> new AsyncCustomChannelEventsClient(clientOptions)); + this.customObjectInstancesClient = Suppliers.memoize(() -> new AsyncCustomObjectInstancesClient(clientOptions)); + this.dataAttributesClient = Suppliers.memoize(() -> new AsyncDataAttributesClient(clientOptions)); + this.dataEventsClient = Suppliers.memoize(() -> new AsyncDataEventsClient(clientOptions)); + this.dataExportClient = Suppliers.memoize(() -> new AsyncDataExportClient(clientOptions)); + this.jobsClient = Suppliers.memoize(() -> new AsyncJobsClient(clientOptions)); + this.messagesClient = Suppliers.memoize(() -> new AsyncMessagesClient(clientOptions)); + this.newsClient = Suppliers.memoize(() -> new AsyncNewsClient(clientOptions)); + this.segmentsClient = Suppliers.memoize(() -> new AsyncSegmentsClient(clientOptions)); + this.switchClient = Suppliers.memoize(() -> new AsyncSwitchClient(clientOptions)); + this.teamsClient = Suppliers.memoize(() -> new AsyncTeamsClient(clientOptions)); + this.ticketStatesClient = Suppliers.memoize(() -> new AsyncTicketStatesClient(clientOptions)); + this.ticketTypeAttributesClient = Suppliers.memoize(() -> new AsyncTicketTypeAttributesClient(clientOptions)); + this.ticketTypesClient = Suppliers.memoize(() -> new AsyncTicketTypesClient(clientOptions)); + this.ticketsClient = Suppliers.memoize(() -> new AsyncTicketsClient(clientOptions)); + this.visitorsClient = Suppliers.memoize(() -> new AsyncVisitorsClient(clientOptions)); + } + + public AsyncAdminsClient admins() { + return this.adminsClient.get(); + } + + public AsyncAiContentClient aiContent() { + return this.aiContentClient.get(); + } + + public AsyncArticlesClient articles() { + return this.articlesClient.get(); + } + + public AsyncAwayStatusReasonsClient awayStatusReasons() { + return this.awayStatusReasonsClient.get(); + } + + public AsyncExportClient export() { + return this.exportClient.get(); + } + + public AsyncHelpCenterClient helpCenter() { + return this.helpCenterClient.get(); + } + + public AsyncCompaniesClient companies() { + return this.companiesClient.get(); + } + + public AsyncContactsClient contacts() { + return this.contactsClient.get(); + } + + public AsyncNotesClient notes() { + return this.notesClient.get(); + } + + public AsyncSubscriptionTypesClient subscriptionTypes() { + return this.subscriptionTypesClient.get(); + } + + public AsyncTagsClient tags() { + return this.tagsClient.get(); + } + + public AsyncConversationsClient conversations() { + return this.conversationsClient.get(); + } + + public AsyncCustomChannelEventsClient customChannelEvents() { + return this.customChannelEventsClient.get(); + } + + public AsyncCustomObjectInstancesClient customObjectInstances() { + return this.customObjectInstancesClient.get(); + } + + public AsyncDataAttributesClient dataAttributes() { + return this.dataAttributesClient.get(); + } + + public AsyncDataEventsClient dataEvents() { + return this.dataEventsClient.get(); + } + + public AsyncDataExportClient dataExport() { + return this.dataExportClient.get(); + } + + public AsyncJobsClient jobs() { + return this.jobsClient.get(); + } + + public AsyncMessagesClient messages() { + return this.messagesClient.get(); + } + + public AsyncNewsClient news() { + return this.newsClient.get(); + } + + public AsyncSegmentsClient segments() { + return this.segmentsClient.get(); + } + + public AsyncSwitchClient switch_() { + return this.switchClient.get(); + } + + public AsyncTeamsClient teams() { + return this.teamsClient.get(); + } + + public AsyncTicketStatesClient ticketStates() { + return this.ticketStatesClient.get(); + } + + public AsyncTicketTypeAttributesClient ticketTypeAttributes() { + return this.ticketTypeAttributesClient.get(); + } + + public AsyncTicketTypesClient ticketTypes() { + return this.ticketTypesClient.get(); + } + + public AsyncTicketsClient tickets() { + return this.ticketsClient.get(); + } + + public AsyncVisitorsClient visitors() { + return this.visitorsClient.get(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/UnstableClient.java b/src/main/java/com/intercom/api/resources/unstable/UnstableClient.java new file mode 100644 index 0000000..4fe8029 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/UnstableClient.java @@ -0,0 +1,240 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.Suppliers; +import com.intercom.api.resources.unstable.admins.AdminsClient; +import com.intercom.api.resources.unstable.aicontent.AiContentClient; +import com.intercom.api.resources.unstable.articles.ArticlesClient; +import com.intercom.api.resources.unstable.awaystatusreasons.AwayStatusReasonsClient; +import com.intercom.api.resources.unstable.companies.CompaniesClient; +import com.intercom.api.resources.unstable.contacts.ContactsClient; +import com.intercom.api.resources.unstable.conversations.ConversationsClient; +import com.intercom.api.resources.unstable.customchannelevents.CustomChannelEventsClient; +import com.intercom.api.resources.unstable.customobjectinstances.CustomObjectInstancesClient; +import com.intercom.api.resources.unstable.dataattributes.DataAttributesClient; +import com.intercom.api.resources.unstable.dataevents.DataEventsClient; +import com.intercom.api.resources.unstable.dataexport.DataExportClient; +import com.intercom.api.resources.unstable.export.ExportClient; +import com.intercom.api.resources.unstable.helpcenter.HelpCenterClient; +import com.intercom.api.resources.unstable.jobs.JobsClient; +import com.intercom.api.resources.unstable.messages.MessagesClient; +import com.intercom.api.resources.unstable.news.NewsClient; +import com.intercom.api.resources.unstable.notes.NotesClient; +import com.intercom.api.resources.unstable.segments.SegmentsClient; +import com.intercom.api.resources.unstable.subscriptiontypes.SubscriptionTypesClient; +import com.intercom.api.resources.unstable.switch_.SwitchClient; +import com.intercom.api.resources.unstable.tags.TagsClient; +import com.intercom.api.resources.unstable.teams.TeamsClient; +import com.intercom.api.resources.unstable.tickets.TicketsClient; +import com.intercom.api.resources.unstable.ticketstates.TicketStatesClient; +import com.intercom.api.resources.unstable.tickettypeattributes.TicketTypeAttributesClient; +import com.intercom.api.resources.unstable.tickettypes.TicketTypesClient; +import com.intercom.api.resources.unstable.visitors.VisitorsClient; +import java.util.function.Supplier; + +public class UnstableClient { + protected final ClientOptions clientOptions; + + protected final Supplier adminsClient; + + protected final Supplier aiContentClient; + + protected final Supplier articlesClient; + + protected final Supplier awayStatusReasonsClient; + + protected final Supplier exportClient; + + protected final Supplier helpCenterClient; + + protected final Supplier companiesClient; + + protected final Supplier contactsClient; + + protected final Supplier notesClient; + + protected final Supplier subscriptionTypesClient; + + protected final Supplier tagsClient; + + protected final Supplier conversationsClient; + + protected final Supplier customChannelEventsClient; + + protected final Supplier customObjectInstancesClient; + + protected final Supplier dataAttributesClient; + + protected final Supplier dataEventsClient; + + protected final Supplier dataExportClient; + + protected final Supplier jobsClient; + + protected final Supplier messagesClient; + + protected final Supplier newsClient; + + protected final Supplier segmentsClient; + + protected final Supplier switchClient; + + protected final Supplier teamsClient; + + protected final Supplier ticketStatesClient; + + protected final Supplier ticketTypeAttributesClient; + + protected final Supplier ticketTypesClient; + + protected final Supplier ticketsClient; + + protected final Supplier visitorsClient; + + public UnstableClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.adminsClient = Suppliers.memoize(() -> new AdminsClient(clientOptions)); + this.aiContentClient = Suppliers.memoize(() -> new AiContentClient(clientOptions)); + this.articlesClient = Suppliers.memoize(() -> new ArticlesClient(clientOptions)); + this.awayStatusReasonsClient = Suppliers.memoize(() -> new AwayStatusReasonsClient(clientOptions)); + this.exportClient = Suppliers.memoize(() -> new ExportClient(clientOptions)); + this.helpCenterClient = Suppliers.memoize(() -> new HelpCenterClient(clientOptions)); + this.companiesClient = Suppliers.memoize(() -> new CompaniesClient(clientOptions)); + this.contactsClient = Suppliers.memoize(() -> new ContactsClient(clientOptions)); + this.notesClient = Suppliers.memoize(() -> new NotesClient(clientOptions)); + this.subscriptionTypesClient = Suppliers.memoize(() -> new SubscriptionTypesClient(clientOptions)); + this.tagsClient = Suppliers.memoize(() -> new TagsClient(clientOptions)); + this.conversationsClient = Suppliers.memoize(() -> new ConversationsClient(clientOptions)); + this.customChannelEventsClient = Suppliers.memoize(() -> new CustomChannelEventsClient(clientOptions)); + this.customObjectInstancesClient = Suppliers.memoize(() -> new CustomObjectInstancesClient(clientOptions)); + this.dataAttributesClient = Suppliers.memoize(() -> new DataAttributesClient(clientOptions)); + this.dataEventsClient = Suppliers.memoize(() -> new DataEventsClient(clientOptions)); + this.dataExportClient = Suppliers.memoize(() -> new DataExportClient(clientOptions)); + this.jobsClient = Suppliers.memoize(() -> new JobsClient(clientOptions)); + this.messagesClient = Suppliers.memoize(() -> new MessagesClient(clientOptions)); + this.newsClient = Suppliers.memoize(() -> new NewsClient(clientOptions)); + this.segmentsClient = Suppliers.memoize(() -> new SegmentsClient(clientOptions)); + this.switchClient = Suppliers.memoize(() -> new SwitchClient(clientOptions)); + this.teamsClient = Suppliers.memoize(() -> new TeamsClient(clientOptions)); + this.ticketStatesClient = Suppliers.memoize(() -> new TicketStatesClient(clientOptions)); + this.ticketTypeAttributesClient = Suppliers.memoize(() -> new TicketTypeAttributesClient(clientOptions)); + this.ticketTypesClient = Suppliers.memoize(() -> new TicketTypesClient(clientOptions)); + this.ticketsClient = Suppliers.memoize(() -> new TicketsClient(clientOptions)); + this.visitorsClient = Suppliers.memoize(() -> new VisitorsClient(clientOptions)); + } + + public AdminsClient admins() { + return this.adminsClient.get(); + } + + public AiContentClient aiContent() { + return this.aiContentClient.get(); + } + + public ArticlesClient articles() { + return this.articlesClient.get(); + } + + public AwayStatusReasonsClient awayStatusReasons() { + return this.awayStatusReasonsClient.get(); + } + + public ExportClient export() { + return this.exportClient.get(); + } + + public HelpCenterClient helpCenter() { + return this.helpCenterClient.get(); + } + + public CompaniesClient companies() { + return this.companiesClient.get(); + } + + public ContactsClient contacts() { + return this.contactsClient.get(); + } + + public NotesClient notes() { + return this.notesClient.get(); + } + + public SubscriptionTypesClient subscriptionTypes() { + return this.subscriptionTypesClient.get(); + } + + public TagsClient tags() { + return this.tagsClient.get(); + } + + public ConversationsClient conversations() { + return this.conversationsClient.get(); + } + + public CustomChannelEventsClient customChannelEvents() { + return this.customChannelEventsClient.get(); + } + + public CustomObjectInstancesClient customObjectInstances() { + return this.customObjectInstancesClient.get(); + } + + public DataAttributesClient dataAttributes() { + return this.dataAttributesClient.get(); + } + + public DataEventsClient dataEvents() { + return this.dataEventsClient.get(); + } + + public DataExportClient dataExport() { + return this.dataExportClient.get(); + } + + public JobsClient jobs() { + return this.jobsClient.get(); + } + + public MessagesClient messages() { + return this.messagesClient.get(); + } + + public NewsClient news() { + return this.newsClient.get(); + } + + public SegmentsClient segments() { + return this.segmentsClient.get(); + } + + public SwitchClient switch_() { + return this.switchClient.get(); + } + + public TeamsClient teams() { + return this.teamsClient.get(); + } + + public TicketStatesClient ticketStates() { + return this.ticketStatesClient.get(); + } + + public TicketTypeAttributesClient ticketTypeAttributes() { + return this.ticketTypeAttributesClient.get(); + } + + public TicketTypesClient ticketTypes() { + return this.ticketTypesClient.get(); + } + + public TicketsClient tickets() { + return this.ticketsClient.get(); + } + + public VisitorsClient visitors() { + return this.visitorsClient.get(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/AdminsClient.java b/src/main/java/com/intercom/api/resources/unstable/admins/AdminsClient.java new file mode 100644 index 0000000..3f6662a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/AdminsClient.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.admins.requests.ListActivityLogsRequest; +import com.intercom.api.resources.unstable.admins.requests.RetrieveAdminRequest; +import com.intercom.api.resources.unstable.admins.requests.SetAwayAdminRequest; +import com.intercom.api.resources.unstable.admins.types.Admin; +import com.intercom.api.resources.unstable.types.ActivityLogList; +import com.intercom.api.resources.unstable.types.AdminList; +import com.intercom.api.resources.unstable.types.AdminWithApp; +import java.util.Optional; + +public class AdminsClient { + protected final ClientOptions clientOptions; + + private final RawAdminsClient rawClient; + + public AdminsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAdminsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAdminsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public Optional identifyAdmin() { + return this.rawClient.identifyAdmin().body(); + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public Optional identifyAdmin(RequestOptions requestOptions) { + return this.rawClient.identifyAdmin(requestOptions).body(); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public Optional setAwayAdmin(SetAwayAdminRequest request) { + return this.rawClient.setAwayAdmin(request).body(); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public Optional setAwayAdmin(SetAwayAdminRequest request, RequestOptions requestOptions) { + return this.rawClient.setAwayAdmin(request, requestOptions).body(); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public ActivityLogList listActivityLogs(ListActivityLogsRequest request) { + return this.rawClient.listActivityLogs(request).body(); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public ActivityLogList listActivityLogs(ListActivityLogsRequest request, RequestOptions requestOptions) { + return this.rawClient.listActivityLogs(request, requestOptions).body(); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public AdminList listAdmins() { + return this.rawClient.listAdmins().body(); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public AdminList listAdmins(RequestOptions requestOptions) { + return this.rawClient.listAdmins(requestOptions).body(); + } + + /** + * You can retrieve the details of a single admin. + */ + public Optional retrieveAdmin(RetrieveAdminRequest request) { + return this.rawClient.retrieveAdmin(request).body(); + } + + /** + * You can retrieve the details of a single admin. + */ + public Optional retrieveAdmin(RetrieveAdminRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveAdmin(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/AsyncAdminsClient.java b/src/main/java/com/intercom/api/resources/unstable/admins/AsyncAdminsClient.java new file mode 100644 index 0000000..dfaefcf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/AsyncAdminsClient.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.admins.requests.ListActivityLogsRequest; +import com.intercom.api.resources.unstable.admins.requests.RetrieveAdminRequest; +import com.intercom.api.resources.unstable.admins.requests.SetAwayAdminRequest; +import com.intercom.api.resources.unstable.admins.types.Admin; +import com.intercom.api.resources.unstable.types.ActivityLogList; +import com.intercom.api.resources.unstable.types.AdminList; +import com.intercom.api.resources.unstable.types.AdminWithApp; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncAdminsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAdminsClient rawClient; + + public AsyncAdminsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAdminsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAdminsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public CompletableFuture> identifyAdmin() { + return this.rawClient.identifyAdmin().thenApply(response -> response.body()); + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public CompletableFuture> identifyAdmin(RequestOptions requestOptions) { + return this.rawClient.identifyAdmin(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public CompletableFuture> setAwayAdmin(SetAwayAdminRequest request) { + return this.rawClient.setAwayAdmin(request).thenApply(response -> response.body()); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public CompletableFuture> setAwayAdmin(SetAwayAdminRequest request, RequestOptions requestOptions) { + return this.rawClient.setAwayAdmin(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public CompletableFuture listActivityLogs(ListActivityLogsRequest request) { + return this.rawClient.listActivityLogs(request).thenApply(response -> response.body()); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public CompletableFuture listActivityLogs( + ListActivityLogsRequest request, RequestOptions requestOptions) { + return this.rawClient.listActivityLogs(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public CompletableFuture listAdmins() { + return this.rawClient.listAdmins().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public CompletableFuture listAdmins(RequestOptions requestOptions) { + return this.rawClient.listAdmins(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can retrieve the details of a single admin. + */ + public CompletableFuture> retrieveAdmin(RetrieveAdminRequest request) { + return this.rawClient.retrieveAdmin(request).thenApply(response -> response.body()); + } + + /** + * You can retrieve the details of a single admin. + */ + public CompletableFuture> retrieveAdmin( + RetrieveAdminRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveAdmin(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/AsyncRawAdminsClient.java b/src/main/java/com/intercom/api/resources/unstable/admins/AsyncRawAdminsClient.java new file mode 100644 index 0000000..80ef46e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/AsyncRawAdminsClient.java @@ -0,0 +1,415 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.admins.requests.ListActivityLogsRequest; +import com.intercom.api.resources.unstable.admins.requests.RetrieveAdminRequest; +import com.intercom.api.resources.unstable.admins.requests.SetAwayAdminRequest; +import com.intercom.api.resources.unstable.admins.types.Admin; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.ActivityLogList; +import com.intercom.api.resources.unstable.types.AdminList; +import com.intercom.api.resources.unstable.types.AdminWithApp; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAdminsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAdminsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public CompletableFuture>> identifyAdmin() { + return identifyAdmin(null); + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public CompletableFuture>> identifyAdmin( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("me") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can set an Admin as away for the Inbox. + */ + public CompletableFuture>> setAwayAdmin(SetAwayAdminRequest request) { + return setAwayAdmin(request, null); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public CompletableFuture>> setAwayAdmin( + SetAwayAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("away") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can get a log of activities by all admins in an app. + */ + public CompletableFuture> listActivityLogs(ListActivityLogsRequest request) { + return listActivityLogs(request, null); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public CompletableFuture> listActivityLogs( + ListActivityLogsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins/activity_logs"); + QueryStringMapper.addQueryParameter(httpUrl, "created_at_after", request.getCreatedAtAfter(), false); + if (request.getCreatedAtBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_at_before", request.getCreatedAtBefore().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ActivityLogList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public CompletableFuture> listAdmins() { + return listAdmins(null); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public CompletableFuture> listAdmins(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), AdminList.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can retrieve the details of a single admin. + */ + public CompletableFuture>> retrieveAdmin(RetrieveAdminRequest request) { + return retrieveAdmin(request, null); + } + + /** + * You can retrieve the details of a single admin. + */ + public CompletableFuture>> retrieveAdmin( + RetrieveAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/RawAdminsClient.java b/src/main/java/com/intercom/api/resources/unstable/admins/RawAdminsClient.java new file mode 100644 index 0000000..8b37bac --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/RawAdminsClient.java @@ -0,0 +1,332 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.admins.requests.ListActivityLogsRequest; +import com.intercom.api.resources.unstable.admins.requests.RetrieveAdminRequest; +import com.intercom.api.resources.unstable.admins.requests.SetAwayAdminRequest; +import com.intercom.api.resources.unstable.admins.types.Admin; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.ActivityLogList; +import com.intercom.api.resources.unstable.types.AdminList; +import com.intercom.api.resources.unstable.types.AdminWithApp; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAdminsClient { + protected final ClientOptions clientOptions; + + public RawAdminsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public IntercomHttpResponse> identifyAdmin() { + return identifyAdmin(null); + } + + /** + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + *
+ *

🚧 Single Sign On

+ *

If you are building a custom "Log in with Intercom" flow for your site, and you call the /me endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk.

+ *
+ */ + public IntercomHttpResponse> identifyAdmin(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("me") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can set an Admin as away for the Inbox. + */ + public IntercomHttpResponse> setAwayAdmin(SetAwayAdminRequest request) { + return setAwayAdmin(request, null); + } + + /** + * You can set an Admin as away for the Inbox. + */ + public IntercomHttpResponse> setAwayAdmin( + SetAwayAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("away") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can get a log of activities by all admins in an app. + */ + public IntercomHttpResponse listActivityLogs(ListActivityLogsRequest request) { + return listActivityLogs(request, null); + } + + /** + * You can get a log of activities by all admins in an app. + */ + public IntercomHttpResponse listActivityLogs( + ListActivityLogsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins/activity_logs"); + QueryStringMapper.addQueryParameter(httpUrl, "created_at_after", request.getCreatedAtAfter(), false); + if (request.getCreatedAtBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_at_before", request.getCreatedAtBefore().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityLogList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public IntercomHttpResponse listAdmins() { + return listAdmins(null); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + public IntercomHttpResponse listAdmins(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can retrieve the details of a single admin. + */ + public IntercomHttpResponse> retrieveAdmin(RetrieveAdminRequest request) { + return retrieveAdmin(request, null); + } + + /** + * You can retrieve the details of a single admin. + */ + public IntercomHttpResponse> retrieveAdmin( + RetrieveAdminRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("admins") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/requests/ListActivityLogsRequest.java b/src/main/java/com/intercom/api/resources/unstable/admins/requests/ListActivityLogsRequest.java new file mode 100644 index 0000000..a9877a2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/requests/ListActivityLogsRequest.java @@ -0,0 +1,156 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListActivityLogsRequest.Builder.class) +public final class ListActivityLogsRequest { + private final String createdAtAfter; + + private final Optional createdAtBefore; + + private final Map additionalProperties; + + private ListActivityLogsRequest( + String createdAtAfter, Optional createdAtBefore, Map additionalProperties) { + this.createdAtAfter = createdAtAfter; + this.createdAtBefore = createdAtBefore; + this.additionalProperties = additionalProperties; + } + + /** + * @return The start date that you request data for. It must be formatted as a UNIX timestamp. + */ + @JsonProperty("created_at_after") + public String getCreatedAtAfter() { + return createdAtAfter; + } + + /** + * @return The end date that you request data for. It must be formatted as a UNIX timestamp. + */ + @JsonProperty("created_at_before") + public Optional getCreatedAtBefore() { + return createdAtBefore; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListActivityLogsRequest && equalTo((ListActivityLogsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListActivityLogsRequest other) { + return createdAtAfter.equals(other.createdAtAfter) && createdAtBefore.equals(other.createdAtBefore); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.createdAtAfter, this.createdAtBefore); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtAfterStage builder() { + return new Builder(); + } + + public interface CreatedAtAfterStage { + /** + * The start date that you request data for. It must be formatted as a UNIX timestamp. + */ + _FinalStage createdAtAfter(@NotNull String createdAtAfter); + + Builder from(ListActivityLogsRequest other); + } + + public interface _FinalStage { + ListActivityLogsRequest build(); + + /** + *

The end date that you request data for. It must be formatted as a UNIX timestamp.

+ */ + _FinalStage createdAtBefore(Optional createdAtBefore); + + _FinalStage createdAtBefore(String createdAtBefore); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CreatedAtAfterStage, _FinalStage { + private String createdAtAfter; + + private Optional createdAtBefore = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListActivityLogsRequest other) { + createdAtAfter(other.getCreatedAtAfter()); + createdAtBefore(other.getCreatedAtBefore()); + return this; + } + + /** + * The start date that you request data for. It must be formatted as a UNIX timestamp.

The start date that you request data for. It must be formatted as a UNIX timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at_after") + public _FinalStage createdAtAfter(@NotNull String createdAtAfter) { + this.createdAtAfter = Objects.requireNonNull(createdAtAfter, "createdAtAfter must not be null"); + return this; + } + + /** + *

The end date that you request data for. It must be formatted as a UNIX timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAtBefore(String createdAtBefore) { + this.createdAtBefore = Optional.ofNullable(createdAtBefore); + return this; + } + + /** + *

The end date that you request data for. It must be formatted as a UNIX timestamp.

+ */ + @java.lang.Override + @JsonSetter(value = "created_at_before", nulls = Nulls.SKIP) + public _FinalStage createdAtBefore(Optional createdAtBefore) { + this.createdAtBefore = createdAtBefore; + return this; + } + + @java.lang.Override + public ListActivityLogsRequest build() { + return new ListActivityLogsRequest(createdAtAfter, createdAtBefore, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/requests/RetrieveAdminRequest.java b/src/main/java/com/intercom/api/resources/unstable/admins/requests/RetrieveAdminRequest.java new file mode 100644 index 0000000..c8351e2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/requests/RetrieveAdminRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveAdminRequest.Builder.class) +public final class RetrieveAdminRequest { + private final int id; + + private final Map additionalProperties; + + private RetrieveAdminRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given admin + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveAdminRequest && equalTo((RetrieveAdminRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveAdminRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a given admin + */ + _FinalStage id(int id); + + Builder from(RetrieveAdminRequest other); + } + + public interface _FinalStage { + RetrieveAdminRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveAdminRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier of a given admin

The unique identifier of a given admin

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public RetrieveAdminRequest build() { + return new RetrieveAdminRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/requests/SetAwayAdminRequest.java b/src/main/java/com/intercom/api/resources/unstable/admins/requests/SetAwayAdminRequest.java new file mode 100644 index 0000000..478e99c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/requests/SetAwayAdminRequest.java @@ -0,0 +1,227 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SetAwayAdminRequest.Builder.class) +public final class SetAwayAdminRequest { + private final int id; + + private final boolean awayModeEnabled; + + private final boolean awayModeReassign; + + private final Optional awayStatusReasonId; + + private final Map additionalProperties; + + private SetAwayAdminRequest( + int id, + boolean awayModeEnabled, + boolean awayModeReassign, + Optional awayStatusReasonId, + Map additionalProperties) { + this.id = id; + this.awayModeEnabled = awayModeEnabled; + this.awayModeReassign = awayModeReassign; + this.awayStatusReasonId = awayStatusReasonId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given admin + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return Set to "true" to change the status of the admin to away. + */ + @JsonProperty("away_mode_enabled") + public boolean getAwayModeEnabled() { + return awayModeEnabled; + } + + /** + * @return Set to "true" to assign any new conversation replies to your default inbox. + */ + @JsonProperty("away_mode_reassign") + public boolean getAwayModeReassign() { + return awayModeReassign; + } + + /** + * @return The unique identifier of the away status reason + */ + @JsonProperty("away_status_reason_id") + public Optional getAwayStatusReasonId() { + return awayStatusReasonId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SetAwayAdminRequest && equalTo((SetAwayAdminRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SetAwayAdminRequest other) { + return id == other.id + && awayModeEnabled == other.awayModeEnabled + && awayModeReassign == other.awayModeReassign + && awayStatusReasonId.equals(other.awayStatusReasonId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.awayModeEnabled, this.awayModeReassign, this.awayStatusReasonId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a given admin + */ + AwayModeEnabledStage id(int id); + + Builder from(SetAwayAdminRequest other); + } + + public interface AwayModeEnabledStage { + /** + * Set to "true" to change the status of the admin to away. + */ + AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled); + } + + public interface AwayModeReassignStage { + /** + * Set to "true" to assign any new conversation replies to your default inbox. + */ + _FinalStage awayModeReassign(boolean awayModeReassign); + } + + public interface _FinalStage { + SetAwayAdminRequest build(); + + /** + *

The unique identifier of the away status reason

+ */ + _FinalStage awayStatusReasonId(Optional awayStatusReasonId); + + _FinalStage awayStatusReasonId(Integer awayStatusReasonId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, AwayModeEnabledStage, AwayModeReassignStage, _FinalStage { + private int id; + + private boolean awayModeEnabled; + + private boolean awayModeReassign; + + private Optional awayStatusReasonId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(SetAwayAdminRequest other) { + id(other.getId()); + awayModeEnabled(other.getAwayModeEnabled()); + awayModeReassign(other.getAwayModeReassign()); + awayStatusReasonId(other.getAwayStatusReasonId()); + return this; + } + + /** + * The unique identifier of a given admin

The unique identifier of a given admin

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public AwayModeEnabledStage id(int id) { + this.id = id; + return this; + } + + /** + * Set to "true" to change the status of the admin to away.

Set to "true" to change the status of the admin to away.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_enabled") + public AwayModeReassignStage awayModeEnabled(boolean awayModeEnabled) { + this.awayModeEnabled = awayModeEnabled; + return this; + } + + /** + * Set to "true" to assign any new conversation replies to your default inbox.

Set to "true" to assign any new conversation replies to your default inbox.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("away_mode_reassign") + public _FinalStage awayModeReassign(boolean awayModeReassign) { + this.awayModeReassign = awayModeReassign; + return this; + } + + /** + *

The unique identifier of the away status reason

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage awayStatusReasonId(Integer awayStatusReasonId) { + this.awayStatusReasonId = Optional.ofNullable(awayStatusReasonId); + return this; + } + + /** + *

The unique identifier of the away status reason

+ */ + @java.lang.Override + @JsonSetter(value = "away_status_reason_id", nulls = Nulls.SKIP) + public _FinalStage awayStatusReasonId(Optional awayStatusReasonId) { + this.awayStatusReasonId = awayStatusReasonId; + return this; + } + + @java.lang.Override + public SetAwayAdminRequest build() { + return new SetAwayAdminRequest( + id, awayModeEnabled, awayModeReassign, awayStatusReasonId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/admins/types/Admin.java b/src/main/java/com/intercom/api/resources/unstable/admins/types/Admin.java new file mode 100644 index 0000000..1224ee1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/admins/types/Admin.java @@ -0,0 +1,454 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.admins.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.TeamPriorityLevel; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Admin.Builder.class) +public final class Admin { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Optional email; + + private final Optional jobTitle; + + private final Optional awayModeEnabled; + + private final Optional awayModeReassign; + + private final Optional awayStatusReasonId; + + private final Optional hasInboxSeat; + + private final Optional> teamIds; + + private final Optional avatar; + + private final Optional teamPriorityLevel; + + private final Map additionalProperties; + + private Admin( + Optional type, + Optional id, + Optional name, + Optional email, + Optional jobTitle, + Optional awayModeEnabled, + Optional awayModeReassign, + Optional awayStatusReasonId, + Optional hasInboxSeat, + Optional> teamIds, + Optional avatar, + Optional teamPriorityLevel, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.email = email; + this.jobTitle = jobTitle; + this.awayModeEnabled = awayModeEnabled; + this.awayModeReassign = awayModeReassign; + this.awayStatusReasonId = awayStatusReasonId; + this.hasInboxSeat = hasInboxSeat; + this.teamIds = teamIds; + this.avatar = avatar; + this.teamPriorityLevel = teamPriorityLevel; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value admin. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id representing the admin. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the admin. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The email of the admin. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The job title of the admin. + */ + @JsonProperty("job_title") + public Optional getJobTitle() { + return jobTitle; + } + + /** + * @return Identifies if this admin is currently set in away mode. + */ + @JsonProperty("away_mode_enabled") + public Optional getAwayModeEnabled() { + return awayModeEnabled; + } + + /** + * @return Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. + */ + @JsonProperty("away_mode_reassign") + public Optional getAwayModeReassign() { + return awayModeReassign; + } + + /** + * @return The unique identifier of the away status reason + */ + @JsonProperty("away_status_reason_id") + public Optional getAwayStatusReasonId() { + return awayStatusReasonId; + } + + /** + * @return Identifies if this admin has a paid inbox seat to restrict/allow features that require them. + */ + @JsonProperty("has_inbox_seat") + public Optional getHasInboxSeat() { + return hasInboxSeat; + } + + /** + * @return This object represents the avatar associated with the admin. + */ + @JsonProperty("team_ids") + public Optional> getTeamIds() { + return teamIds; + } + + /** + * @return Image for the associated team or teammate + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("team_priority_level") + public Optional getTeamPriorityLevel() { + return teamPriorityLevel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Admin && equalTo((Admin) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Admin other) { + return type.equals(other.type) + && id.equals(other.id) + && name.equals(other.name) + && email.equals(other.email) + && jobTitle.equals(other.jobTitle) + && awayModeEnabled.equals(other.awayModeEnabled) + && awayModeReassign.equals(other.awayModeReassign) + && awayStatusReasonId.equals(other.awayStatusReasonId) + && hasInboxSeat.equals(other.hasInboxSeat) + && teamIds.equals(other.teamIds) + && avatar.equals(other.avatar) + && teamPriorityLevel.equals(other.teamPriorityLevel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.name, + this.email, + this.jobTitle, + this.awayModeEnabled, + this.awayModeReassign, + this.awayStatusReasonId, + this.hasInboxSeat, + this.teamIds, + this.avatar, + this.teamPriorityLevel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional jobTitle = Optional.empty(); + + private Optional awayModeEnabled = Optional.empty(); + + private Optional awayModeReassign = Optional.empty(); + + private Optional awayStatusReasonId = Optional.empty(); + + private Optional hasInboxSeat = Optional.empty(); + + private Optional> teamIds = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional teamPriorityLevel = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Admin other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + email(other.getEmail()); + jobTitle(other.getJobTitle()); + awayModeEnabled(other.getAwayModeEnabled()); + awayModeReassign(other.getAwayModeReassign()); + awayStatusReasonId(other.getAwayStatusReasonId()); + hasInboxSeat(other.getHasInboxSeat()); + teamIds(other.getTeamIds()); + avatar(other.getAvatar()); + teamPriorityLevel(other.getTeamPriorityLevel()); + return this; + } + + /** + *

String representing the object's type. Always has the value admin.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id representing the admin.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the admin.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The email of the admin.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The job title of the admin.

+ */ + @JsonSetter(value = "job_title", nulls = Nulls.SKIP) + public Builder jobTitle(Optional jobTitle) { + this.jobTitle = jobTitle; + return this; + } + + public Builder jobTitle(String jobTitle) { + this.jobTitle = Optional.ofNullable(jobTitle); + return this; + } + + /** + *

Identifies if this admin is currently set in away mode.

+ */ + @JsonSetter(value = "away_mode_enabled", nulls = Nulls.SKIP) + public Builder awayModeEnabled(Optional awayModeEnabled) { + this.awayModeEnabled = awayModeEnabled; + return this; + } + + public Builder awayModeEnabled(Boolean awayModeEnabled) { + this.awayModeEnabled = Optional.ofNullable(awayModeEnabled); + return this; + } + + /** + *

Identifies if this admin is set to automatically reassign new conversations to the apps default inbox.

+ */ + @JsonSetter(value = "away_mode_reassign", nulls = Nulls.SKIP) + public Builder awayModeReassign(Optional awayModeReassign) { + this.awayModeReassign = awayModeReassign; + return this; + } + + public Builder awayModeReassign(Boolean awayModeReassign) { + this.awayModeReassign = Optional.ofNullable(awayModeReassign); + return this; + } + + /** + *

The unique identifier of the away status reason

+ */ + @JsonSetter(value = "away_status_reason_id", nulls = Nulls.SKIP) + public Builder awayStatusReasonId(Optional awayStatusReasonId) { + this.awayStatusReasonId = awayStatusReasonId; + return this; + } + + public Builder awayStatusReasonId(Integer awayStatusReasonId) { + this.awayStatusReasonId = Optional.ofNullable(awayStatusReasonId); + return this; + } + + /** + *

Identifies if this admin has a paid inbox seat to restrict/allow features that require them.

+ */ + @JsonSetter(value = "has_inbox_seat", nulls = Nulls.SKIP) + public Builder hasInboxSeat(Optional hasInboxSeat) { + this.hasInboxSeat = hasInboxSeat; + return this; + } + + public Builder hasInboxSeat(Boolean hasInboxSeat) { + this.hasInboxSeat = Optional.ofNullable(hasInboxSeat); + return this; + } + + /** + *

This object represents the avatar associated with the admin.

+ */ + @JsonSetter(value = "team_ids", nulls = Nulls.SKIP) + public Builder teamIds(Optional> teamIds) { + this.teamIds = teamIds; + return this; + } + + public Builder teamIds(List teamIds) { + this.teamIds = Optional.ofNullable(teamIds); + return this; + } + + /** + *

Image for the associated team or teammate

+ */ + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "team_priority_level", nulls = Nulls.SKIP) + public Builder teamPriorityLevel(Optional teamPriorityLevel) { + this.teamPriorityLevel = teamPriorityLevel; + return this; + } + + public Builder teamPriorityLevel(TeamPriorityLevel teamPriorityLevel) { + this.teamPriorityLevel = Optional.ofNullable(teamPriorityLevel); + return this; + } + + public Admin build() { + return new Admin( + type, + id, + name, + email, + jobTitle, + awayModeEnabled, + awayModeReassign, + awayStatusReasonId, + hasInboxSeat, + teamIds, + avatar, + teamPriorityLevel, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aiagent/types/AiAgent.java b/src/main/java/com/intercom/api/resources/unstable/aiagent/types/AiAgent.java new file mode 100644 index 0000000..fd9d9fa --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aiagent/types/AiAgent.java @@ -0,0 +1,401 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aiagent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContentSourcesList; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AiAgent.Builder.class) +public final class AiAgent { + private final Optional sourceType; + + private final Optional sourceTitle; + + private final Optional lastAnswerType; + + private final Optional resolutionState; + + private final Optional rating; + + private final Optional ratingRemark; + + private final Optional contentSources; + + private final Map additionalProperties; + + private AiAgent( + Optional sourceType, + Optional sourceTitle, + Optional lastAnswerType, + Optional resolutionState, + Optional rating, + Optional ratingRemark, + Optional contentSources, + Map additionalProperties) { + this.sourceType = sourceType; + this.sourceTitle = sourceTitle; + this.lastAnswerType = lastAnswerType; + this.resolutionState = resolutionState; + this.rating = rating; + this.ratingRemark = ratingRemark; + this.contentSources = contentSources; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the source that triggered AI Agent involvement in the conversation. + */ + @JsonProperty("source_type") + public Optional getSourceType() { + return sourceType; + } + + /** + * @return The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null. + */ + @JsonProperty("source_title") + public Optional getSourceTitle() { + return sourceTitle; + } + + /** + * @return The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null + */ + @JsonProperty("last_answer_type") + public Optional getLastAnswerType() { + return lastAnswerType; + } + + /** + * @return The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null. + */ + @JsonProperty("resolution_state") + public Optional getResolutionState() { + return resolutionState; + } + + /** + * @return The customer satisfaction rating given to AI Agent, from 1-5. + */ + @JsonProperty("rating") + public Optional getRating() { + return rating; + } + + /** + * @return The customer satisfaction rating remark given to AI Agent. + */ + @JsonProperty("rating_remark") + public Optional getRatingRemark() { + return ratingRemark; + } + + @JsonProperty("content_sources") + public Optional getContentSources() { + return contentSources; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AiAgent && equalTo((AiAgent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AiAgent other) { + return sourceType.equals(other.sourceType) + && sourceTitle.equals(other.sourceTitle) + && lastAnswerType.equals(other.lastAnswerType) + && resolutionState.equals(other.resolutionState) + && rating.equals(other.rating) + && ratingRemark.equals(other.ratingRemark) + && contentSources.equals(other.contentSources); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.sourceType, + this.sourceTitle, + this.lastAnswerType, + this.resolutionState, + this.rating, + this.ratingRemark, + this.contentSources); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional sourceType = Optional.empty(); + + private Optional sourceTitle = Optional.empty(); + + private Optional lastAnswerType = Optional.empty(); + + private Optional resolutionState = Optional.empty(); + + private Optional rating = Optional.empty(); + + private Optional ratingRemark = Optional.empty(); + + private Optional contentSources = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AiAgent other) { + sourceType(other.getSourceType()); + sourceTitle(other.getSourceTitle()); + lastAnswerType(other.getLastAnswerType()); + resolutionState(other.getResolutionState()); + rating(other.getRating()); + ratingRemark(other.getRatingRemark()); + contentSources(other.getContentSources()); + return this; + } + + /** + *

The type of the source that triggered AI Agent involvement in the conversation.

+ */ + @JsonSetter(value = "source_type", nulls = Nulls.SKIP) + public Builder sourceType(Optional sourceType) { + this.sourceType = sourceType; + return this; + } + + public Builder sourceType(SourceType sourceType) { + this.sourceType = Optional.ofNullable(sourceType); + return this; + } + + /** + *

The title of the source that triggered AI Agent involvement in the conversation. If this is essentials_plan_setup then it will return null.

+ */ + @JsonSetter(value = "source_title", nulls = Nulls.SKIP) + public Builder sourceTitle(Optional sourceTitle) { + this.sourceTitle = sourceTitle; + return this; + } + + public Builder sourceTitle(String sourceTitle) { + this.sourceTitle = Optional.ofNullable(sourceTitle); + return this; + } + + /** + *

The type of the last answer delivered by AI Agent. If no answer was delivered then this will return null

+ */ + @JsonSetter(value = "last_answer_type", nulls = Nulls.SKIP) + public Builder lastAnswerType(Optional lastAnswerType) { + this.lastAnswerType = lastAnswerType; + return this; + } + + public Builder lastAnswerType(String lastAnswerType) { + this.lastAnswerType = Optional.ofNullable(lastAnswerType); + return this; + } + + /** + *

The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return null.

+ */ + @JsonSetter(value = "resolution_state", nulls = Nulls.SKIP) + public Builder resolutionState(Optional resolutionState) { + this.resolutionState = resolutionState; + return this; + } + + public Builder resolutionState(String resolutionState) { + this.resolutionState = Optional.ofNullable(resolutionState); + return this; + } + + /** + *

The customer satisfaction rating given to AI Agent, from 1-5.

+ */ + @JsonSetter(value = "rating", nulls = Nulls.SKIP) + public Builder rating(Optional rating) { + this.rating = rating; + return this; + } + + public Builder rating(Integer rating) { + this.rating = Optional.ofNullable(rating); + return this; + } + + /** + *

The customer satisfaction rating remark given to AI Agent.

+ */ + @JsonSetter(value = "rating_remark", nulls = Nulls.SKIP) + public Builder ratingRemark(Optional ratingRemark) { + this.ratingRemark = ratingRemark; + return this; + } + + public Builder ratingRemark(String ratingRemark) { + this.ratingRemark = Optional.ofNullable(ratingRemark); + return this; + } + + @JsonSetter(value = "content_sources", nulls = Nulls.SKIP) + public Builder contentSources(Optional contentSources) { + this.contentSources = contentSources; + return this; + } + + public Builder contentSources(ContentSourcesList contentSources) { + this.contentSources = Optional.ofNullable(contentSources); + return this; + } + + public AiAgent build() { + return new AiAgent( + sourceType, + sourceTitle, + lastAnswerType, + resolutionState, + rating, + ratingRemark, + contentSources, + additionalProperties); + } + } + + public static final class SourceType { + public static final SourceType WORKFLOW = new SourceType(Value.WORKFLOW, "workflow"); + + public static final SourceType WORKFLOW_PREVIEW = new SourceType(Value.WORKFLOW_PREVIEW, "workflow_preview"); + + public static final SourceType FIN_PREVIEW = new SourceType(Value.FIN_PREVIEW, "fin_preview"); + + public static final SourceType ESSENTIALS_PLAN_SETUP = + new SourceType(Value.ESSENTIALS_PLAN_SETUP, "essentials_plan_setup"); + + public static final SourceType PROFILE = new SourceType(Value.PROFILE, "profile"); + + private final Value value; + + private final String string; + + SourceType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof SourceType && this.string.equals(((SourceType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case WORKFLOW: + return visitor.visitWorkflow(); + case WORKFLOW_PREVIEW: + return visitor.visitWorkflowPreview(); + case FIN_PREVIEW: + return visitor.visitFinPreview(); + case ESSENTIALS_PLAN_SETUP: + return visitor.visitEssentialsPlanSetup(); + case PROFILE: + return visitor.visitProfile(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SourceType valueOf(String value) { + switch (value) { + case "workflow": + return WORKFLOW; + case "workflow_preview": + return WORKFLOW_PREVIEW; + case "fin_preview": + return FIN_PREVIEW; + case "essentials_plan_setup": + return ESSENTIALS_PLAN_SETUP; + case "profile": + return PROFILE; + default: + return new SourceType(Value.UNKNOWN, value); + } + } + + public enum Value { + ESSENTIALS_PLAN_SETUP, + + PROFILE, + + WORKFLOW, + + WORKFLOW_PREVIEW, + + FIN_PREVIEW, + + UNKNOWN + } + + public interface Visitor { + T visitEssentialsPlanSetup(); + + T visitProfile(); + + T visitWorkflow(); + + T visitWorkflowPreview(); + + T visitFinPreview(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/AiContentClient.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/AiContentClient.java new file mode 100644 index 0000000..fa26d97 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/AiContentClient.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSource; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPage; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPagesList; + +public class AiContentClient { + protected final ClientOptions clientOptions; + + private final RawAiContentClient rawClient; + + public AiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAiContentClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAiContentClient withRawResponse() { + return this.rawClient; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public ContentImportSourcesList listContentImportSources() { + return this.rawClient.listContentImportSources().body(); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public ContentImportSourcesList listContentImportSources(RequestOptions requestOptions) { + return this.rawClient.listContentImportSources(requestOptions).body(); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public ContentImportSource createContentImportSource(CreateContentImportSourceRequest request) { + return this.rawClient.createContentImportSource(request).body(); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public ContentImportSource createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.createContentImportSource(request, requestOptions).body(); + } + + public ContentImportSource getContentImportSource(GetContentImportSourceRequest request) { + return this.rawClient.getContentImportSource(request).body(); + } + + public ContentImportSource getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.getContentImportSource(request, requestOptions).body(); + } + + /** + * You can update an existing content import source. + */ + public ContentImportSource updateContentImportSource(UpdateContentImportSourceRequest request) { + return this.rawClient.updateContentImportSource(request).body(); + } + + /** + * You can update an existing content import source. + */ + public ContentImportSource updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.updateContentImportSource(request, requestOptions).body(); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public void deleteContentImportSource(DeleteContentImportSourceRequest request) { + this.rawClient.deleteContentImportSource(request).body(); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public void deleteContentImportSource(DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + this.rawClient.deleteContentImportSource(request, requestOptions).body(); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public ExternalPagesList listExternalPages() { + return this.rawClient.listExternalPages().body(); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public ExternalPagesList listExternalPages(RequestOptions requestOptions) { + return this.rawClient.listExternalPages(requestOptions).body(); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public ExternalPage createExternalPage(CreateExternalPageRequest request) { + return this.rawClient.createExternalPage(request).body(); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public ExternalPage createExternalPage(CreateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.createExternalPage(request, requestOptions).body(); + } + + /** + * You can retrieve an external page. + */ + public ExternalPage getExternalPage(GetExternalPageRequest request) { + return this.rawClient.getExternalPage(request).body(); + } + + /** + * You can retrieve an external page. + */ + public ExternalPage getExternalPage(GetExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.getExternalPage(request, requestOptions).body(); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public ExternalPage updateExternalPage(UpdateExternalPageRequest request) { + return this.rawClient.updateExternalPage(request).body(); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public ExternalPage updateExternalPage(UpdateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.updateExternalPage(request, requestOptions).body(); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public ExternalPage deleteExternalPage(DeleteExternalPageRequest request) { + return this.rawClient.deleteExternalPage(request).body(); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public ExternalPage deleteExternalPage(DeleteExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteExternalPage(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/AsyncAiContentClient.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/AsyncAiContentClient.java new file mode 100644 index 0000000..1bdc4b4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/AsyncAiContentClient.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSource; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPage; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPagesList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAiContentClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAiContentClient rawClient; + + public AsyncAiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAiContentClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAiContentClient withRawResponse() { + return this.rawClient; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture listContentImportSources() { + return this.rawClient.listContentImportSources().thenApply(response -> response.body()); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture listContentImportSources(RequestOptions requestOptions) { + return this.rawClient.listContentImportSources(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture createContentImportSource(CreateContentImportSourceRequest request) { + return this.rawClient.createContentImportSource(request).thenApply(response -> response.body()); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.createContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getContentImportSource(GetContentImportSourceRequest request) { + return this.rawClient.getContentImportSource(request).thenApply(response -> response.body()); + } + + public CompletableFuture getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.getContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture updateContentImportSource(UpdateContentImportSourceRequest request) { + return this.rawClient.updateContentImportSource(request).thenApply(response -> response.body()); + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.updateContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public CompletableFuture deleteContentImportSource(DeleteContentImportSourceRequest request) { + return this.rawClient.deleteContentImportSource(request).thenApply(response -> response.body()); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public CompletableFuture deleteContentImportSource( + DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteContentImportSource(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture listExternalPages() { + return this.rawClient.listExternalPages().thenApply(response -> response.body()); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture listExternalPages(RequestOptions requestOptions) { + return this.rawClient.listExternalPages(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public CompletableFuture createExternalPage(CreateExternalPageRequest request) { + return this.rawClient.createExternalPage(request).thenApply(response -> response.body()); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public CompletableFuture createExternalPage( + CreateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.createExternalPage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture getExternalPage(GetExternalPageRequest request) { + return this.rawClient.getExternalPage(request).thenApply(response -> response.body()); + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture getExternalPage( + GetExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.getExternalPage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture updateExternalPage(UpdateExternalPageRequest request) { + return this.rawClient.updateExternalPage(request).thenApply(response -> response.body()); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture updateExternalPage( + UpdateExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.updateExternalPage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture deleteExternalPage(DeleteExternalPageRequest request) { + return this.rawClient.deleteExternalPage(request).thenApply(response -> response.body()); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture deleteExternalPage( + DeleteExternalPageRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteExternalPage(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/AsyncRawAiContentClient.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/AsyncRawAiContentClient.java new file mode 100644 index 0000000..fa51a30 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/AsyncRawAiContentClient.java @@ -0,0 +1,746 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSource; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPage; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPagesList; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAiContentClient { + protected final ClientOptions clientOptions; + + public AsyncRawAiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture> listContentImportSources() { + return listContentImportSources(null); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public CompletableFuture> listContentImportSources( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContentImportSourcesList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture> createContentImportSource( + CreateContentImportSourceRequest request) { + return createContentImportSource(request, null); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public CompletableFuture> createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContentImportSource.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getContentImportSource( + GetContentImportSourceRequest request) { + return getContentImportSource(request, null); + } + + public CompletableFuture> getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContentImportSource.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture> updateContentImportSource( + UpdateContentImportSourceRequest request) { + return updateContentImportSource(request, null); + } + + /** + * You can update an existing content import source. + */ + public CompletableFuture> updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContentImportSource.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public CompletableFuture> deleteContentImportSource( + DeleteContentImportSourceRequest request) { + return deleteContentImportSource(request, null); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public CompletableFuture> deleteContentImportSource( + DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture> listExternalPages() { + return listExternalPages(null); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public CompletableFuture> listExternalPages(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ExternalPagesList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public CompletableFuture> createExternalPage(CreateExternalPageRequest request) { + return createExternalPage(request, null); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public CompletableFuture> createExternalPage( + CreateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture> getExternalPage(GetExternalPageRequest request) { + return getExternalPage(request, null); + } + + /** + * You can retrieve an external page. + */ + public CompletableFuture> getExternalPage( + GetExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture> updateExternalPage(UpdateExternalPageRequest request) { + return updateExternalPage(request, null); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public CompletableFuture> updateExternalPage( + UpdateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture> deleteExternalPage(DeleteExternalPageRequest request) { + return deleteExternalPage(request, null); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public CompletableFuture> deleteExternalPage( + DeleteExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ExternalPage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/RawAiContentClient.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/RawAiContentClient.java new file mode 100644 index 0000000..926a429 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/RawAiContentClient.java @@ -0,0 +1,593 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.unstable.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSource; +import com.intercom.api.resources.unstable.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPage; +import com.intercom.api.resources.unstable.aicontent.types.ExternalPagesList; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAiContentClient { + protected final ClientOptions clientOptions; + + public RawAiContentClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public IntercomHttpResponse listContentImportSources() { + return listContentImportSources(null); + } + + /** + * You can retrieve a list of all content import sources for a workspace. + */ + public IntercomHttpResponse listContentImportSources(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSourcesList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public IntercomHttpResponse createContentImportSource( + CreateContentImportSourceRequest request) { + return createContentImportSource(request, null); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + */ + public IntercomHttpResponse createContentImportSource( + CreateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public IntercomHttpResponse getContentImportSource(GetContentImportSourceRequest request) { + return getContentImportSource(request, null); + } + + public IntercomHttpResponse getContentImportSource( + GetContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing content import source. + */ + public IntercomHttpResponse updateContentImportSource( + UpdateContentImportSourceRequest request) { + return updateContentImportSource(request, null); + } + + /** + * You can update an existing content import source. + */ + public IntercomHttpResponse updateContentImportSource( + UpdateContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContentImportSource.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public IntercomHttpResponse deleteContentImportSource(DeleteContentImportSourceRequest request) { + return deleteContentImportSource(request, null); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + */ + public IntercomHttpResponse deleteContentImportSource( + DeleteContentImportSourceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/content_import_sources") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public IntercomHttpResponse listExternalPages() { + return listExternalPages(null); + } + + /** + * You can retrieve a list of all external pages for a workspace. + */ + public IntercomHttpResponse listExternalPages(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPagesList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public IntercomHttpResponse createExternalPage(CreateExternalPageRequest request) { + return createExternalPage(request, null); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + */ + public IntercomHttpResponse createExternalPage( + CreateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can retrieve an external page. + */ + public IntercomHttpResponse getExternalPage(GetExternalPageRequest request) { + return getExternalPage(request, null); + } + + /** + * You can retrieve an external page. + */ + public IntercomHttpResponse getExternalPage( + GetExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public IntercomHttpResponse updateExternalPage(UpdateExternalPageRequest request) { + return updateExternalPage(request, null); + } + + /** + * You can update an existing external page (if it was created via the API). + */ + public IntercomHttpResponse updateExternalPage( + UpdateExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public IntercomHttpResponse deleteExternalPage(DeleteExternalPageRequest request) { + return deleteExternalPage(request, null); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + */ + public IntercomHttpResponse deleteExternalPage( + DeleteExternalPageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ai/external_pages") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalPage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/CreateContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/CreateContentImportSourceRequest.java new file mode 100644 index 0000000..335f5ed --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/CreateContentImportSourceRequest.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateContentImportSourceRequest.Builder.class) +public final class CreateContentImportSourceRequest { + private final Optional status; + + private final String url; + + private final Map additionalProperties; + + private CreateContentImportSourceRequest( + Optional status, String url, Map additionalProperties) { + this.status = status; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return If you intend to create or update External Pages via the API, this should be set to api. + */ + @JsonProperty("sync_behavior") + public String getSyncBehavior() { + return "api"; + } + + /** + * @return The status of the content import source. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The URL of the content import source. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateContentImportSourceRequest && equalTo((CreateContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateContentImportSourceRequest other) { + return status.equals(other.status) && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.status, this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UrlStage builder() { + return new Builder(); + } + + public interface UrlStage { + /** + * The URL of the content import source. + */ + _FinalStage url(@NotNull String url); + + Builder from(CreateContentImportSourceRequest other); + } + + public interface _FinalStage { + CreateContentImportSourceRequest build(); + + /** + *

The status of the content import source.

+ */ + _FinalStage status(Optional status); + + _FinalStage status(Status status); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UrlStage, _FinalStage { + private String url; + + private Optional status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateContentImportSourceRequest other) { + status(other.getStatus()); + url(other.getUrl()); + return this; + } + + /** + * The URL of the content import source.

The URL of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public _FinalStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + *

The status of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

The status of the content import source.

+ */ + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public CreateContentImportSourceRequest build() { + return new CreateContentImportSourceRequest(status, url, additionalProperties); + } + } + + public static final class Status { + public static final Status DEACTIVATED = new Status(Value.DEACTIVATED, "deactivated"); + + public static final Status ACTIVE = new Status(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEACTIVATED: + return visitor.visitDeactivated(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "deactivated": + return DEACTIVATED; + case "active": + return ACTIVE; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + DEACTIVATED, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitDeactivated(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/CreateExternalPageRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/CreateExternalPageRequest.java new file mode 100644 index 0000000..b686f5a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/CreateExternalPageRequest.java @@ -0,0 +1,370 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateExternalPageRequest.Builder.class) +public final class CreateExternalPageRequest { + private final String title; + + private final String html; + + private final Optional url; + + private final Optional aiAgentAvailability; + + private final Optional aiCopilotAvailability; + + private final int sourceId; + + private final String externalId; + + private final Map additionalProperties; + + private CreateExternalPageRequest( + String title, + String html, + Optional url, + Optional aiAgentAvailability, + Optional aiCopilotAvailability, + int sourceId, + String externalId, + Map additionalProperties) { + this.title = title; + this.html = html; + this.url = url; + this.aiAgentAvailability = aiAgentAvailability; + this.aiCopilotAvailability = aiCopilotAvailability; + this.sourceId = sourceId; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The title of the external page. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The body of the external page in HTML. + */ + @JsonProperty("html") + public String getHtml() { + return html; + } + + /** + * @return The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page. + */ + @JsonProperty("ai_agent_availability") + public Optional getAiAgentAvailability() { + return aiAgentAvailability; + } + + /** + * @return Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. + */ + @JsonProperty("ai_copilot_availability") + public Optional getAiCopilotAvailability() { + return aiCopilotAvailability; + } + + /** + * @return Always en + */ + @JsonProperty("locale") + public String getLocale() { + return "en"; + } + + /** + * @return The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + */ + @JsonProperty("source_id") + public int getSourceId() { + return sourceId; + } + + /** + * @return The identifier for the external page which was given by the source. Must be unique for the source. + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateExternalPageRequest && equalTo((CreateExternalPageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateExternalPageRequest other) { + return title.equals(other.title) + && html.equals(other.html) + && url.equals(other.url) + && aiAgentAvailability.equals(other.aiAgentAvailability) + && aiCopilotAvailability.equals(other.aiCopilotAvailability) + && sourceId == other.sourceId + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.title, + this.html, + this.url, + this.aiAgentAvailability, + this.aiCopilotAvailability, + this.sourceId, + this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TitleStage builder() { + return new Builder(); + } + + public interface TitleStage { + /** + * The title of the external page. + */ + HtmlStage title(@NotNull String title); + + Builder from(CreateExternalPageRequest other); + } + + public interface HtmlStage { + /** + * The body of the external page in HTML. + */ + SourceIdStage html(@NotNull String html); + } + + public interface SourceIdStage { + /** + * The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + */ + ExternalIdStage sourceId(int sourceId); + } + + public interface ExternalIdStage { + /** + * The identifier for the external page which was given by the source. Must be unique for the source. + */ + _FinalStage externalId(@NotNull String externalId); + } + + public interface _FinalStage { + CreateExternalPageRequest build(); + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source.

+ */ + _FinalStage url(Optional url); + + _FinalStage url(String url); + + /** + *

Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page.

+ */ + _FinalStage aiAgentAvailability(Optional aiAgentAvailability); + + _FinalStage aiAgentAvailability(Boolean aiAgentAvailability); + + /** + *

Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page.

+ */ + _FinalStage aiCopilotAvailability(Optional aiCopilotAvailability); + + _FinalStage aiCopilotAvailability(Boolean aiCopilotAvailability); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TitleStage, HtmlStage, SourceIdStage, ExternalIdStage, _FinalStage { + private String title; + + private String html; + + private int sourceId; + + private String externalId; + + private Optional aiCopilotAvailability = Optional.empty(); + + private Optional aiAgentAvailability = Optional.empty(); + + private Optional url = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateExternalPageRequest other) { + title(other.getTitle()); + html(other.getHtml()); + url(other.getUrl()); + aiAgentAvailability(other.getAiAgentAvailability()); + aiCopilotAvailability(other.getAiCopilotAvailability()); + sourceId(other.getSourceId()); + externalId(other.getExternalId()); + return this; + } + + /** + * The title of the external page.

The title of the external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("title") + public HtmlStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + /** + * The body of the external page in HTML.

The body of the external page in HTML.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("html") + public SourceIdStage html(@NotNull String html) { + this.html = Objects.requireNonNull(html, "html must not be null"); + return this; + } + + /** + * The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response.

The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public ExternalIdStage sourceId(int sourceId) { + this.sourceId = sourceId; + return this; + } + + /** + * The identifier for the external page which was given by the source. Must be unique for the source.

The identifier for the external page which was given by the source. Must be unique for the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aiCopilotAvailability(Boolean aiCopilotAvailability) { + this.aiCopilotAvailability = Optional.ofNullable(aiCopilotAvailability); + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page.

+ */ + @java.lang.Override + @JsonSetter(value = "ai_copilot_availability", nulls = Nulls.SKIP) + public _FinalStage aiCopilotAvailability(Optional aiCopilotAvailability) { + this.aiCopilotAvailability = aiCopilotAvailability; + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage aiAgentAvailability(Boolean aiAgentAvailability) { + this.aiAgentAvailability = Optional.ofNullable(aiAgentAvailability); + return this; + } + + /** + *

Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page.

+ */ + @java.lang.Override + @JsonSetter(value = "ai_agent_availability", nulls = Nulls.SKIP) + public _FinalStage aiAgentAvailability(Optional aiAgentAvailability) { + this.aiAgentAvailability = aiAgentAvailability; + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source.

+ */ + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + @java.lang.Override + public CreateExternalPageRequest build() { + return new CreateExternalPageRequest( + title, + html, + url, + aiAgentAvailability, + aiCopilotAvailability, + sourceId, + externalId, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/DeleteContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/DeleteContentImportSourceRequest.java new file mode 100644 index 0000000..43fa332 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/DeleteContentImportSourceRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteContentImportSourceRequest.Builder.class) +public final class DeleteContentImportSourceRequest { + private final String id; + + private final Map additionalProperties; + + private DeleteContentImportSourceRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteContentImportSourceRequest && equalTo((DeleteContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteContentImportSourceRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(DeleteContentImportSourceRequest other); + } + + public interface _FinalStage { + DeleteContentImportSourceRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteContentImportSourceRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DeleteContentImportSourceRequest build() { + return new DeleteContentImportSourceRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/DeleteExternalPageRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/DeleteExternalPageRequest.java new file mode 100644 index 0000000..dfe9923 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/DeleteExternalPageRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteExternalPageRequest.Builder.class) +public final class DeleteExternalPageRequest { + private final String id; + + private final Map additionalProperties; + + private DeleteExternalPageRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteExternalPageRequest && equalTo((DeleteExternalPageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteExternalPageRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the external page which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(DeleteExternalPageRequest other); + } + + public interface _FinalStage { + DeleteExternalPageRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteExternalPageRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DeleteExternalPageRequest build() { + return new DeleteExternalPageRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/GetContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/GetContentImportSourceRequest.java new file mode 100644 index 0000000..d5317e1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/GetContentImportSourceRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetContentImportSourceRequest.Builder.class) +public final class GetContentImportSourceRequest { + private final String id; + + private final Map additionalProperties; + + private GetContentImportSourceRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetContentImportSourceRequest && equalTo((GetContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetContentImportSourceRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(GetContentImportSourceRequest other); + } + + public interface _FinalStage { + GetContentImportSourceRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetContentImportSourceRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public GetContentImportSourceRequest build() { + return new GetContentImportSourceRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/GetExternalPageRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/GetExternalPageRequest.java new file mode 100644 index 0000000..697e549 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/GetExternalPageRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetExternalPageRequest.Builder.class) +public final class GetExternalPageRequest { + private final String id; + + private final Map additionalProperties; + + private GetExternalPageRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetExternalPageRequest && equalTo((GetExternalPageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetExternalPageRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the external page which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(GetExternalPageRequest other); + } + + public interface _FinalStage { + GetExternalPageRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetExternalPageRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public GetExternalPageRequest build() { + return new GetExternalPageRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/UpdateContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/UpdateContentImportSourceRequest.java new file mode 100644 index 0000000..18290d1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/UpdateContentImportSourceRequest.java @@ -0,0 +1,390 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateContentImportSourceRequest.Builder.class) +public final class UpdateContentImportSourceRequest { + private final String id; + + private final SyncBehavior syncBehavior; + + private final Optional status; + + private final String url; + + private final Map additionalProperties; + + private UpdateContentImportSourceRequest( + String id, + SyncBehavior syncBehavior, + Optional status, + String url, + Map additionalProperties) { + this.id = id; + this.syncBehavior = syncBehavior; + this.status = status; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return If you intend to create or update External Pages via the API, this should be set to api. You can not change the value to or from api. + */ + @JsonProperty("sync_behavior") + public SyncBehavior getSyncBehavior() { + return syncBehavior; + } + + /** + * @return The status of the content import source. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateContentImportSourceRequest && equalTo((UpdateContentImportSourceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateContentImportSourceRequest other) { + return id.equals(other.id) + && syncBehavior.equals(other.syncBehavior) + && status.equals(other.status) + && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.syncBehavior, this.status, this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + SyncBehaviorStage id(@NotNull String id); + + Builder from(UpdateContentImportSourceRequest other); + } + + public interface SyncBehaviorStage { + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. + */ + UrlStage syncBehavior(@NotNull SyncBehavior syncBehavior); + } + + public interface UrlStage { + /** + * The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + */ + _FinalStage url(@NotNull String url); + } + + public interface _FinalStage { + UpdateContentImportSourceRequest build(); + + /** + *

The status of the content import source.

+ */ + _FinalStage status(Optional status); + + _FinalStage status(Status status); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, SyncBehaviorStage, UrlStage, _FinalStage { + private String id; + + private SyncBehavior syncBehavior; + + private String url; + + private Optional status = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateContentImportSourceRequest other) { + id(other.getId()); + syncBehavior(other.getSyncBehavior()); + status(other.getStatus()); + url(other.getUrl()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public SyncBehaviorStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api.

If you intend to create or update External Pages via the API, this should be set to api. You can not change the value to or from api.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("sync_behavior") + public UrlStage syncBehavior(@NotNull SyncBehavior syncBehavior) { + this.syncBehavior = Objects.requireNonNull(syncBehavior, "syncBehavior must not be null"); + return this; + } + + /** + * The URL of the content import source. This may only be different from the existing value if the sync behavior is API.

The URL of the content import source. This may only be different from the existing value if the sync behavior is API.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public _FinalStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + *

The status of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

The status of the content import source.

+ */ + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + @java.lang.Override + public UpdateContentImportSourceRequest build() { + return new UpdateContentImportSourceRequest(id, syncBehavior, status, url, additionalProperties); + } + } + + public static final class Status { + public static final Status DEACTIVATED = new Status(Value.DEACTIVATED, "deactivated"); + + public static final Status ACTIVE = new Status(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEACTIVATED: + return visitor.visitDeactivated(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "deactivated": + return DEACTIVATED; + case "active": + return ACTIVE; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + DEACTIVATED, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitDeactivated(); + + T visitUnknown(String unknownType); + } + } + + public static final class SyncBehavior { + public static final SyncBehavior AUTOMATED = new SyncBehavior(Value.AUTOMATED, "automated"); + + public static final SyncBehavior MANUAL = new SyncBehavior(Value.MANUAL, "manual"); + + public static final SyncBehavior API = new SyncBehavior(Value.API, "api"); + + private final Value value; + + private final String string; + + SyncBehavior(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SyncBehavior && this.string.equals(((SyncBehavior) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case AUTOMATED: + return visitor.visitAutomated(); + case MANUAL: + return visitor.visitManual(); + case API: + return visitor.visitApi(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SyncBehavior valueOf(String value) { + switch (value) { + case "automated": + return AUTOMATED; + case "manual": + return MANUAL; + case "api": + return API; + default: + return new SyncBehavior(Value.UNKNOWN, value); + } + } + + public enum Value { + API, + + AUTOMATED, + + MANUAL, + + UNKNOWN + } + + public interface Visitor { + T visitApi(); + + T visitAutomated(); + + T visitManual(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/UpdateExternalPageRequest.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/UpdateExternalPageRequest.java new file mode 100644 index 0000000..5ab6a1c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/requests/UpdateExternalPageRequest.java @@ -0,0 +1,348 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateExternalPageRequest.Builder.class) +public final class UpdateExternalPageRequest { + private final String id; + + private final String title; + + private final String html; + + private final String url; + + private final Optional finAvailability; + + private final int sourceId; + + private final Optional externalId; + + private final Map additionalProperties; + + private UpdateExternalPageRequest( + String id, + String title, + String html, + String url, + Optional finAvailability, + int sourceId, + Optional externalId, + Map additionalProperties) { + this.id = id; + this.title = title; + this.html = html; + this.url = url; + this.finAvailability = finAvailability; + this.sourceId = sourceId; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The title of the external page. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The body of the external page in HTML. + */ + @JsonProperty("html") + public String getHtml() { + return html; + } + + /** + * @return The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + /** + * @return Whether the external page should be used to answer questions by Fin. + */ + @JsonProperty("fin_availability") + public Optional getFinAvailability() { + return finAvailability; + } + + /** + * @return Always en + */ + @JsonProperty("locale") + public String getLocale() { + return "en"; + } + + /** + * @return The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + */ + @JsonProperty("source_id") + public int getSourceId() { + return sourceId; + } + + /** + * @return The identifier for the external page which was given by the source. Must be unique for the source. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateExternalPageRequest && equalTo((UpdateExternalPageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateExternalPageRequest other) { + return id.equals(other.id) + && title.equals(other.title) + && html.equals(other.html) + && url.equals(other.url) + && finAvailability.equals(other.finAvailability) + && sourceId == other.sourceId + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, this.title, this.html, this.url, this.finAvailability, this.sourceId, this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the external page which is given by Intercom. + */ + TitleStage id(@NotNull String id); + + Builder from(UpdateExternalPageRequest other); + } + + public interface TitleStage { + /** + * The title of the external page. + */ + HtmlStage title(@NotNull String title); + } + + public interface HtmlStage { + /** + * The body of the external page in HTML. + */ + UrlStage html(@NotNull String html); + } + + public interface UrlStage { + /** + * The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + */ + SourceIdStage url(@NotNull String url); + } + + public interface SourceIdStage { + /** + * The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + */ + _FinalStage sourceId(int sourceId); + } + + public interface _FinalStage { + UpdateExternalPageRequest build(); + + /** + *

Whether the external page should be used to answer questions by Fin.

+ */ + _FinalStage finAvailability(Optional finAvailability); + + _FinalStage finAvailability(Boolean finAvailability); + + /** + *

The identifier for the external page which was given by the source. Must be unique for the source.

+ */ + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, TitleStage, HtmlStage, UrlStage, SourceIdStage, _FinalStage { + private String id; + + private String title; + + private String html; + + private String url; + + private int sourceId; + + private Optional externalId = Optional.empty(); + + private Optional finAvailability = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateExternalPageRequest other) { + id(other.getId()); + title(other.getTitle()); + html(other.getHtml()); + url(other.getUrl()); + finAvailability(other.getFinAvailability()); + sourceId(other.getSourceId()); + externalId(other.getExternalId()); + return this; + } + + /** + * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public TitleStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The title of the external page.

The title of the external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("title") + public HtmlStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + /** + * The body of the external page in HTML.

The body of the external page in HTML.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("html") + public UrlStage html(@NotNull String html) { + this.html = Objects.requireNonNull(html, "html must not be null"); + return this; + } + + /** + * The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public SourceIdStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + * The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response.

The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public _FinalStage sourceId(int sourceId) { + this.sourceId = sourceId; + return this; + } + + /** + *

The identifier for the external page which was given by the source. Must be unique for the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The identifier for the external page which was given by the source. Must be unique for the source.

+ */ + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + /** + *

Whether the external page should be used to answer questions by Fin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage finAvailability(Boolean finAvailability) { + this.finAvailability = Optional.ofNullable(finAvailability); + return this; + } + + /** + *

Whether the external page should be used to answer questions by Fin.

+ */ + @java.lang.Override + @JsonSetter(value = "fin_availability", nulls = Nulls.SKIP) + public _FinalStage finAvailability(Optional finAvailability) { + this.finAvailability = finAvailability; + return this; + } + + @java.lang.Override + public UpdateExternalPageRequest build() { + return new UpdateExternalPageRequest( + id, title, html, url, finAvailability, sourceId, externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ContentImportSource.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ContentImportSource.java new file mode 100644 index 0000000..d581e30 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ContentImportSource.java @@ -0,0 +1,499 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContentImportSource.Builder.class) +public final class ContentImportSource { + private final int id; + + private final int lastSyncedAt; + + private final SyncBehavior syncBehavior; + + private final Status status; + + private final String url; + + private final int createdAt; + + private final int updatedAt; + + private final Map additionalProperties; + + private ContentImportSource( + int id, + int lastSyncedAt, + SyncBehavior syncBehavior, + Status status, + String url, + int createdAt, + int updatedAt, + Map additionalProperties) { + this.id = id; + this.lastSyncedAt = lastSyncedAt; + this.syncBehavior = syncBehavior; + this.status = status; + this.url = url; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always external_page + */ + @JsonProperty("type") + public String getType() { + return "content_import_source"; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return The time when the content import source was last synced. + */ + @JsonProperty("last_synced_at") + public int getLastSyncedAt() { + return lastSyncedAt; + } + + /** + * @return If you intend to create or update External Pages via the API, this should be set to api. + */ + @JsonProperty("sync_behavior") + public SyncBehavior getSyncBehavior() { + return syncBehavior; + } + + /** + * @return The status of the content import source. + */ + @JsonProperty("status") + public Status getStatus() { + return status; + } + + /** + * @return The URL of the root of the external source. + */ + @JsonProperty("url") + public String getUrl() { + return url; + } + + /** + * @return The time when the content import source was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the content import source was last updated. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContentImportSource && equalTo((ContentImportSource) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContentImportSource other) { + return id == other.id + && lastSyncedAt == other.lastSyncedAt + && syncBehavior.equals(other.syncBehavior) + && status.equals(other.status) + && url.equals(other.url) + && createdAt == other.createdAt + && updatedAt == other.updatedAt; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, this.lastSyncedAt, this.syncBehavior, this.status, this.url, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + LastSyncedAtStage id(int id); + + Builder from(ContentImportSource other); + } + + public interface LastSyncedAtStage { + /** + * The time when the content import source was last synced. + */ + SyncBehaviorStage lastSyncedAt(int lastSyncedAt); + } + + public interface SyncBehaviorStage { + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. + */ + StatusStage syncBehavior(@NotNull SyncBehavior syncBehavior); + } + + public interface StatusStage { + /** + * The status of the content import source. + */ + UrlStage status(@NotNull Status status); + } + + public interface UrlStage { + /** + * The URL of the root of the external source. + */ + CreatedAtStage url(@NotNull String url); + } + + public interface CreatedAtStage { + /** + * The time when the content import source was created. + */ + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + /** + * The time when the content import source was last updated. + */ + _FinalStage updatedAt(int updatedAt); + } + + public interface _FinalStage { + ContentImportSource build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + LastSyncedAtStage, + SyncBehaviorStage, + StatusStage, + UrlStage, + CreatedAtStage, + UpdatedAtStage, + _FinalStage { + private int id; + + private int lastSyncedAt; + + private SyncBehavior syncBehavior; + + private Status status; + + private String url; + + private int createdAt; + + private int updatedAt; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ContentImportSource other) { + id(other.getId()); + lastSyncedAt(other.getLastSyncedAt()); + syncBehavior(other.getSyncBehavior()); + status(other.getStatus()); + url(other.getUrl()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + * The unique identifier for the content import source which is given by Intercom.

The unique identifier for the content import source which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public LastSyncedAtStage id(int id) { + this.id = id; + return this; + } + + /** + * The time when the content import source was last synced.

The time when the content import source was last synced.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("last_synced_at") + public SyncBehaviorStage lastSyncedAt(int lastSyncedAt) { + this.lastSyncedAt = lastSyncedAt; + return this; + } + + /** + * If you intend to create or update External Pages via the API, this should be set to `api`.

If you intend to create or update External Pages via the API, this should be set to api.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("sync_behavior") + public StatusStage syncBehavior(@NotNull SyncBehavior syncBehavior) { + this.syncBehavior = Objects.requireNonNull(syncBehavior, "syncBehavior must not be null"); + return this; + } + + /** + * The status of the content import source.

The status of the content import source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("status") + public UrlStage status(@NotNull Status status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + /** + * The URL of the root of the external source.

The URL of the root of the external source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("url") + public CreatedAtStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + * The time when the content import source was created.

The time when the content import source was created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public UpdatedAtStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The time when the content import source was last updated.

The time when the content import source was last updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public _FinalStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + @java.lang.Override + public ContentImportSource build() { + return new ContentImportSource( + id, lastSyncedAt, syncBehavior, status, url, createdAt, updatedAt, additionalProperties); + } + } + + public static final class Status { + public static final Status DEACTIVATED = new Status(Value.DEACTIVATED, "deactivated"); + + public static final Status ACTIVE = new Status(Value.ACTIVE, "active"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case DEACTIVATED: + return visitor.visitDeactivated(); + case ACTIVE: + return visitor.visitActive(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "deactivated": + return DEACTIVATED; + case "active": + return ACTIVE; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + ACTIVE, + + DEACTIVATED, + + UNKNOWN + } + + public interface Visitor { + T visitActive(); + + T visitDeactivated(); + + T visitUnknown(String unknownType); + } + } + + public static final class SyncBehavior { + public static final SyncBehavior MANUAL = new SyncBehavior(Value.MANUAL, "manual"); + + public static final SyncBehavior API = new SyncBehavior(Value.API, "api"); + + public static final SyncBehavior AUTOMATIC = new SyncBehavior(Value.AUTOMATIC, "automatic"); + + private final Value value; + + private final String string; + + SyncBehavior(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SyncBehavior && this.string.equals(((SyncBehavior) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case MANUAL: + return visitor.visitManual(); + case API: + return visitor.visitApi(); + case AUTOMATIC: + return visitor.visitAutomatic(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SyncBehavior valueOf(String value) { + switch (value) { + case "manual": + return MANUAL; + case "api": + return API; + case "automatic": + return AUTOMATIC; + default: + return new SyncBehavior(Value.UNKNOWN, value); + } + } + + public enum Value { + API, + + AUTOMATIC, + + MANUAL, + + UNKNOWN + } + + public interface Visitor { + T visitApi(); + + T visitAutomatic(); + + T visitManual(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ContentImportSourcesList.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ContentImportSourcesList.java new file mode 100644 index 0000000..6fe9248 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ContentImportSourcesList.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.PagesLink; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContentImportSourcesList.Builder.class) +public final class ContentImportSourcesList { + private final Optional type; + + private final Optional pages; + + private final Optional totalCount; + + private final Optional> data; + + private final Map additionalProperties; + + private ContentImportSourcesList( + Optional type, + Optional pages, + Optional totalCount, + Optional> data, + Map additionalProperties) { + this.type = type; + this.pages = pages; + this.totalCount = totalCount; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + /** + * @return A count of the total number of content import sources. + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + /** + * @return An array of Content Import Source objects + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContentImportSourcesList && equalTo((ContentImportSourcesList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContentImportSourcesList other) { + return type.equals(other.type) + && pages.equals(other.pages) + && totalCount.equals(other.totalCount) + && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.pages, this.totalCount, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional pages = Optional.empty(); + + private Optional totalCount = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ContentImportSourcesList other) { + type(other.getType()); + pages(other.getPages()); + totalCount(other.getTotalCount()); + data(other.getData()); + return this; + } + + /** + *

The type of the object - list.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public Builder pages(Optional pages) { + this.pages = pages; + return this; + } + + public Builder pages(PagesLink pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + /** + *

A count of the total number of content import sources.

+ */ + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Integer totalCount) { + this.totalCount = Optional.ofNullable(totalCount); + return this; + } + + /** + *

An array of Content Import Source objects

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public ContentImportSourcesList build() { + return new ContentImportSourcesList(type, pages, totalCount, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ExternalPage.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ExternalPage.java new file mode 100644 index 0000000..b577fc1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ExternalPage.java @@ -0,0 +1,560 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ExternalPage.Builder.class) +public final class ExternalPage { + private final String id; + + private final String title; + + private final String html; + + private final Optional url; + + private final boolean aiAgentAvailability; + + private final boolean aiCopilotAvailability; + + private final Optional finAvailability; + + private final int sourceId; + + private final String externalId; + + private final int createdAt; + + private final int updatedAt; + + private final int lastIngestedAt; + + private final Map additionalProperties; + + private ExternalPage( + String id, + String title, + String html, + Optional url, + boolean aiAgentAvailability, + boolean aiCopilotAvailability, + Optional finAvailability, + int sourceId, + String externalId, + int createdAt, + int updatedAt, + int lastIngestedAt, + Map additionalProperties) { + this.id = id; + this.title = title; + this.html = html; + this.url = url; + this.aiAgentAvailability = aiAgentAvailability; + this.aiCopilotAvailability = aiCopilotAvailability; + this.finAvailability = finAvailability; + this.sourceId = sourceId; + this.externalId = externalId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.lastIngestedAt = lastIngestedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always external_page + */ + @JsonProperty("type") + public String getType() { + return "external_page"; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The title of the external page. + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * @return The body of the external page in HTML. + */ + @JsonProperty("html") + public String getHtml() { + return html; + } + + /** + * @return The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return Whether the external page should be used to answer questions by AI Agent. + */ + @JsonProperty("ai_agent_availability") + public boolean getAiAgentAvailability() { + return aiAgentAvailability; + } + + /** + * @return Whether the external page should be used to answer questions by AI Copilot. + */ + @JsonProperty("ai_copilot_availability") + public boolean getAiCopilotAvailability() { + return aiCopilotAvailability; + } + + /** + * @return Deprecated. Use ai_agent_availability and ai_copilot_availability instead. + */ + @JsonProperty("fin_availability") + public Optional getFinAvailability() { + return finAvailability; + } + + /** + * @return Always en + */ + @JsonProperty("locale") + public String getLocale() { + return "en"; + } + + /** + * @return The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + */ + @JsonProperty("source_id") + public int getSourceId() { + return sourceId; + } + + /** + * @return The identifier for the external page which was given by the source. Must be unique for the source. + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + /** + * @return The time when the external page was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the external page was last updated. + */ + @JsonProperty("updated_at") + public int getUpdatedAt() { + return updatedAt; + } + + /** + * @return The time when the external page was last ingested. + */ + @JsonProperty("last_ingested_at") + public int getLastIngestedAt() { + return lastIngestedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExternalPage && equalTo((ExternalPage) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExternalPage other) { + return id.equals(other.id) + && title.equals(other.title) + && html.equals(other.html) + && url.equals(other.url) + && aiAgentAvailability == other.aiAgentAvailability + && aiCopilotAvailability == other.aiCopilotAvailability + && finAvailability.equals(other.finAvailability) + && sourceId == other.sourceId + && externalId.equals(other.externalId) + && createdAt == other.createdAt + && updatedAt == other.updatedAt + && lastIngestedAt == other.lastIngestedAt; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.title, + this.html, + this.url, + this.aiAgentAvailability, + this.aiCopilotAvailability, + this.finAvailability, + this.sourceId, + this.externalId, + this.createdAt, + this.updatedAt, + this.lastIngestedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the external page which is given by Intercom. + */ + TitleStage id(@NotNull String id); + + Builder from(ExternalPage other); + } + + public interface TitleStage { + /** + * The title of the external page. + */ + HtmlStage title(@NotNull String title); + } + + public interface HtmlStage { + /** + * The body of the external page in HTML. + */ + AiAgentAvailabilityStage html(@NotNull String html); + } + + public interface AiAgentAvailabilityStage { + /** + * Whether the external page should be used to answer questions by AI Agent. + */ + AiCopilotAvailabilityStage aiAgentAvailability(boolean aiAgentAvailability); + } + + public interface AiCopilotAvailabilityStage { + /** + * Whether the external page should be used to answer questions by AI Copilot. + */ + SourceIdStage aiCopilotAvailability(boolean aiCopilotAvailability); + } + + public interface SourceIdStage { + /** + * The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. + */ + ExternalIdStage sourceId(int sourceId); + } + + public interface ExternalIdStage { + /** + * The identifier for the external page which was given by the source. Must be unique for the source. + */ + CreatedAtStage externalId(@NotNull String externalId); + } + + public interface CreatedAtStage { + /** + * The time when the external page was created. + */ + UpdatedAtStage createdAt(int createdAt); + } + + public interface UpdatedAtStage { + /** + * The time when the external page was last updated. + */ + LastIngestedAtStage updatedAt(int updatedAt); + } + + public interface LastIngestedAtStage { + /** + * The time when the external page was last ingested. + */ + _FinalStage lastIngestedAt(int lastIngestedAt); + } + + public interface _FinalStage { + ExternalPage build(); + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ */ + _FinalStage url(Optional url); + + _FinalStage url(String url); + + /** + *

Deprecated. Use ai_agent_availability and ai_copilot_availability instead.

+ */ + _FinalStage finAvailability(Optional finAvailability); + + _FinalStage finAvailability(Boolean finAvailability); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, + TitleStage, + HtmlStage, + AiAgentAvailabilityStage, + AiCopilotAvailabilityStage, + SourceIdStage, + ExternalIdStage, + CreatedAtStage, + UpdatedAtStage, + LastIngestedAtStage, + _FinalStage { + private String id; + + private String title; + + private String html; + + private boolean aiAgentAvailability; + + private boolean aiCopilotAvailability; + + private int sourceId; + + private String externalId; + + private int createdAt; + + private int updatedAt; + + private int lastIngestedAt; + + private Optional finAvailability = Optional.empty(); + + private Optional url = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExternalPage other) { + id(other.getId()); + title(other.getTitle()); + html(other.getHtml()); + url(other.getUrl()); + aiAgentAvailability(other.getAiAgentAvailability()); + aiCopilotAvailability(other.getAiCopilotAvailability()); + finAvailability(other.getFinAvailability()); + sourceId(other.getSourceId()); + externalId(other.getExternalId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + lastIngestedAt(other.getLastIngestedAt()); + return this; + } + + /** + * The unique identifier for the external page which is given by Intercom.

The unique identifier for the external page which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public TitleStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The title of the external page.

The title of the external page.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("title") + public HtmlStage title(@NotNull String title) { + this.title = Objects.requireNonNull(title, "title must not be null"); + return this; + } + + /** + * The body of the external page in HTML.

The body of the external page in HTML.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("html") + public AiAgentAvailabilityStage html(@NotNull String html) { + this.html = Objects.requireNonNull(html, "html must not be null"); + return this; + } + + /** + * Whether the external page should be used to answer questions by AI Agent.

Whether the external page should be used to answer questions by AI Agent.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ai_agent_availability") + public AiCopilotAvailabilityStage aiAgentAvailability(boolean aiAgentAvailability) { + this.aiAgentAvailability = aiAgentAvailability; + return this; + } + + /** + * Whether the external page should be used to answer questions by AI Copilot.

Whether the external page should be used to answer questions by AI Copilot.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ai_copilot_availability") + public SourceIdStage aiCopilotAvailability(boolean aiCopilotAvailability) { + this.aiCopilotAvailability = aiCopilotAvailability; + return this; + } + + /** + * The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response.

The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("source_id") + public ExternalIdStage sourceId(int sourceId) { + this.sourceId = sourceId; + return this; + } + + /** + * The identifier for the external page which was given by the source. Must be unique for the source.

The identifier for the external page which was given by the source. Must be unique for the source.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public CreatedAtStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + /** + * The time when the external page was created.

The time when the external page was created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public UpdatedAtStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The time when the external page was last updated.

The time when the external page was last updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("updated_at") + public LastIngestedAtStage updatedAt(int updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * The time when the external page was last ingested.

The time when the external page was last ingested.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("last_ingested_at") + public _FinalStage lastIngestedAt(int lastIngestedAt) { + this.lastIngestedAt = lastIngestedAt; + return this; + } + + /** + *

Deprecated. Use ai_agent_availability and ai_copilot_availability instead.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage finAvailability(Boolean finAvailability) { + this.finAvailability = Optional.ofNullable(finAvailability); + return this; + } + + /** + *

Deprecated. Use ai_agent_availability and ai_copilot_availability instead.

+ */ + @java.lang.Override + @JsonSetter(value = "fin_availability", nulls = Nulls.SKIP) + public _FinalStage finAvailability(Optional finAvailability) { + this.finAvailability = finAvailability; + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The URL of the external page. This will be used by Fin to link end users to the page it based its answer on.

+ */ + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + @java.lang.Override + public ExternalPage build() { + return new ExternalPage( + id, + title, + html, + url, + aiAgentAvailability, + aiCopilotAvailability, + finAvailability, + sourceId, + externalId, + createdAt, + updatedAt, + lastIngestedAt, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ExternalPagesList.java b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ExternalPagesList.java new file mode 100644 index 0000000..cbbc7d3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontent/types/ExternalPagesList.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontent.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.PagesLink; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ExternalPagesList.Builder.class) +public final class ExternalPagesList { + private final Optional type; + + private final Optional pages; + + private final Optional totalCount; + + private final Optional> data; + + private final Map additionalProperties; + + private ExternalPagesList( + Optional type, + Optional pages, + Optional totalCount, + Optional> data, + Map additionalProperties) { + this.type = type; + this.pages = pages; + this.totalCount = totalCount; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + /** + * @return A count of the total number of external pages. + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + /** + * @return An array of External Page objects + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExternalPagesList && equalTo((ExternalPagesList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExternalPagesList other) { + return type.equals(other.type) + && pages.equals(other.pages) + && totalCount.equals(other.totalCount) + && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.pages, this.totalCount, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional pages = Optional.empty(); + + private Optional totalCount = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ExternalPagesList other) { + type(other.getType()); + pages(other.getPages()); + totalCount(other.getTotalCount()); + data(other.getData()); + return this; + } + + /** + *

The type of the object - list.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public Builder pages(Optional pages) { + this.pages = pages; + return this; + } + + public Builder pages(PagesLink pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + /** + *

A count of the total number of external pages.

+ */ + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Integer totalCount) { + this.totalCount = Optional.ofNullable(totalCount); + return this; + } + + /** + *

An array of External Page objects

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public ExternalPagesList build() { + return new ExternalPagesList(type, pages, totalCount, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/aicontentsource/types/ContentSource.java b/src/main/java/com/intercom/api/resources/unstable/aicontentsource/types/ContentSource.java new file mode 100644 index 0000000..f63f480 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/aicontentsource/types/ContentSource.java @@ -0,0 +1,302 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.aicontentsource.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ContentSource.Builder.class) +public final class ContentSource { + private final Optional contentType; + + private final Optional url; + + private final Optional title; + + private final Optional locale; + + private final Map additionalProperties; + + private ContentSource( + Optional contentType, + Optional url, + Optional title, + Optional locale, + Map additionalProperties) { + this.contentType = contentType; + this.url = url; + this.title = title; + this.locale = locale; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the content source. + */ + @JsonProperty("content_type") + public Optional getContentType() { + return contentType; + } + + /** + * @return The internal URL linking to the content source for teammates. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The title of the content source. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The ISO 639 language code of the content source. + */ + @JsonProperty("locale") + public Optional getLocale() { + return locale; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ContentSource && equalTo((ContentSource) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContentSource other) { + return contentType.equals(other.contentType) + && url.equals(other.url) + && title.equals(other.title) + && locale.equals(other.locale); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contentType, this.url, this.title, this.locale); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional contentType = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional locale = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ContentSource other) { + contentType(other.getContentType()); + url(other.getUrl()); + title(other.getTitle()); + locale(other.getLocale()); + return this; + } + + /** + *

The type of the content source.

+ */ + @JsonSetter(value = "content_type", nulls = Nulls.SKIP) + public Builder contentType(Optional contentType) { + this.contentType = contentType; + return this; + } + + public Builder contentType(ContentType contentType) { + this.contentType = Optional.ofNullable(contentType); + return this; + } + + /** + *

The internal URL linking to the content source for teammates.

+ */ + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public Builder url(Optional url) { + this.url = url; + return this; + } + + public Builder url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The title of the content source.

+ */ + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

The ISO 639 language code of the content source.

+ */ + @JsonSetter(value = "locale", nulls = Nulls.SKIP) + public Builder locale(Optional locale) { + this.locale = locale; + return this; + } + + public Builder locale(String locale) { + this.locale = Optional.ofNullable(locale); + return this; + } + + public ContentSource build() { + return new ContentSource(contentType, url, title, locale, additionalProperties); + } + } + + public static final class ContentType { + public static final ContentType ARTICLE = new ContentType(Value.ARTICLE, "article"); + + public static final ContentType WORKFLOW_CONNECTOR_ACTION = + new ContentType(Value.WORKFLOW_CONNECTOR_ACTION, "workflow_connector_action"); + + public static final ContentType EXTERNAL_CONTENT = new ContentType(Value.EXTERNAL_CONTENT, "external_content"); + + public static final ContentType FILE = new ContentType(Value.FILE, "file"); + + public static final ContentType CONTENT_SNIPPET = new ContentType(Value.CONTENT_SNIPPET, "content_snippet"); + + private final Value value; + + private final String string; + + ContentType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ContentType && this.string.equals(((ContentType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ARTICLE: + return visitor.visitArticle(); + case WORKFLOW_CONNECTOR_ACTION: + return visitor.visitWorkflowConnectorAction(); + case EXTERNAL_CONTENT: + return visitor.visitExternalContent(); + case FILE: + return visitor.visitFile(); + case CONTENT_SNIPPET: + return visitor.visitContentSnippet(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ContentType valueOf(String value) { + switch (value) { + case "article": + return ARTICLE; + case "workflow_connector_action": + return WORKFLOW_CONNECTOR_ACTION; + case "external_content": + return EXTERNAL_CONTENT; + case "file": + return FILE; + case "content_snippet": + return CONTENT_SNIPPET; + default: + return new ContentType(Value.UNKNOWN, value); + } + } + + public enum Value { + FILE, + + ARTICLE, + + EXTERNAL_CONTENT, + + CONTENT_SNIPPET, + + WORKFLOW_CONNECTOR_ACTION, + + UNKNOWN + } + + public interface Visitor { + T visitFile(); + + T visitArticle(); + + T visitExternalContent(); + + T visitContentSnippet(); + + T visitWorkflowConnectorAction(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/ArticlesClient.java b/src/main/java/com/intercom/api/resources/unstable/articles/ArticlesClient.java new file mode 100644 index 0000000..b88bfaf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/ArticlesClient.java @@ -0,0 +1,117 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.articles.requests.DeleteArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.RetrieveArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.SearchArticlesRequest; +import com.intercom.api.resources.unstable.articles.types.Article; +import com.intercom.api.resources.unstable.articles.types.ArticleSearchResponse; +import com.intercom.api.resources.unstable.types.ArticleList; +import com.intercom.api.resources.unstable.types.DeletedArticleObject; + +public class ArticlesClient { + protected final ClientOptions clientOptions; + + private final RawArticlesClient rawClient; + + public ArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawArticlesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawArticlesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public ArticleList listArticles() { + return this.rawClient.listArticles().body(); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public ArticleList listArticles(RequestOptions requestOptions) { + return this.rawClient.listArticles(requestOptions).body(); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public Article createArticle(Object request) { + return this.rawClient.createArticle(request).body(); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public Article createArticle(Object request, RequestOptions requestOptions) { + return this.rawClient.createArticle(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public Article retrieveArticle(RetrieveArticleRequest request) { + return this.rawClient.retrieveArticle(request).body(); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public Article retrieveArticle(RetrieveArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveArticle(request, requestOptions).body(); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public DeletedArticleObject deleteArticle(DeleteArticleRequest request) { + return this.rawClient.deleteArticle(request).body(); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public DeletedArticleObject deleteArticle(DeleteArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteArticle(request, requestOptions).body(); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public ArticleSearchResponse searchArticles() { + return this.rawClient.searchArticles().body(); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public ArticleSearchResponse searchArticles(SearchArticlesRequest request) { + return this.rawClient.searchArticles(request).body(); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public ArticleSearchResponse searchArticles(SearchArticlesRequest request, RequestOptions requestOptions) { + return this.rawClient.searchArticles(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/AsyncArticlesClient.java b/src/main/java/com/intercom/api/resources/unstable/articles/AsyncArticlesClient.java new file mode 100644 index 0000000..7fdf867 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/AsyncArticlesClient.java @@ -0,0 +1,120 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.articles.requests.DeleteArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.RetrieveArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.SearchArticlesRequest; +import com.intercom.api.resources.unstable.articles.types.Article; +import com.intercom.api.resources.unstable.articles.types.ArticleSearchResponse; +import com.intercom.api.resources.unstable.types.ArticleList; +import com.intercom.api.resources.unstable.types.DeletedArticleObject; +import java.util.concurrent.CompletableFuture; + +public class AsyncArticlesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawArticlesClient rawClient; + + public AsyncArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawArticlesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawArticlesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public CompletableFuture listArticles() { + return this.rawClient.listArticles().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public CompletableFuture listArticles(RequestOptions requestOptions) { + return this.rawClient.listArticles(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture
createArticle(Object request) { + return this.rawClient.createArticle(request).thenApply(response -> response.body()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture
createArticle(Object request, RequestOptions requestOptions) { + return this.rawClient.createArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture
retrieveArticle(RetrieveArticleRequest request) { + return this.rawClient.retrieveArticle(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture
retrieveArticle(RetrieveArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture deleteArticle(DeleteArticleRequest request) { + return this.rawClient.deleteArticle(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture deleteArticle( + DeleteArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public CompletableFuture searchArticles() { + return this.rawClient.searchArticles().thenApply(response -> response.body()); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public CompletableFuture searchArticles(SearchArticlesRequest request) { + return this.rawClient.searchArticles(request).thenApply(response -> response.body()); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public CompletableFuture searchArticles( + SearchArticlesRequest request, RequestOptions requestOptions) { + return this.rawClient.searchArticles(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/AsyncRawArticlesClient.java b/src/main/java/com/intercom/api/resources/unstable/articles/AsyncRawArticlesClient.java new file mode 100644 index 0000000..d6e3a13 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/AsyncRawArticlesClient.java @@ -0,0 +1,438 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.articles.requests.DeleteArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.RetrieveArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.SearchArticlesRequest; +import com.intercom.api.resources.unstable.articles.types.Article; +import com.intercom.api.resources.unstable.articles.types.ArticleSearchResponse; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.ArticleList; +import com.intercom.api.resources.unstable.types.DeletedArticleObject; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawArticlesClient { + protected final ClientOptions clientOptions; + + public AsyncRawArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public CompletableFuture> listArticles() { + return listArticles(null); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public CompletableFuture> listArticles(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ArticleList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture> createArticle(Object request) { + return createArticle(request, null); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture> createArticle( + Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Article.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture> retrieveArticle(RetrieveArticleRequest request) { + return retrieveArticle(request, null); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture> retrieveArticle( + RetrieveArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Article.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture> deleteArticle(DeleteArticleRequest request) { + return deleteArticle(request, null); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public CompletableFuture> deleteArticle( + DeleteArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DeletedArticleObject.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public CompletableFuture> searchArticles() { + return searchArticles(SearchArticlesRequest.builder().build()); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public CompletableFuture> searchArticles( + SearchArticlesRequest request) { + return searchArticles(request, null); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public CompletableFuture> searchArticles( + SearchArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles/search"); + if (request.getPhrase().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phrase", request.getPhrase().get(), false); + } + if (request.getState().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "state", request.getState().get(), false); + } + if (request.getHelpCenterId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "help_center_id", request.getHelpCenterId().get().toString(), false); + } + if (request.getHighlight().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "highlight", request.getHighlight().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ArticleSearchResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/RawArticlesClient.java b/src/main/java/com/intercom/api/resources/unstable/articles/RawArticlesClient.java new file mode 100644 index 0000000..be06cc6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/RawArticlesClient.java @@ -0,0 +1,352 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.articles.requests.DeleteArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.RetrieveArticleRequest; +import com.intercom.api.resources.unstable.articles.requests.SearchArticlesRequest; +import com.intercom.api.resources.unstable.articles.types.Article; +import com.intercom.api.resources.unstable.articles.types.ArticleSearchResponse; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.ArticleList; +import com.intercom.api.resources.unstable.types.DeletedArticleObject; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawArticlesClient { + protected final ClientOptions clientOptions; + + public RawArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public IntercomHttpResponse listArticles() { + return listArticles(null); + } + + /** + * You can fetch a list of all articles by making a GET request to https://api.intercom.io/articles. + *
+ *

📘 How are the articles sorted and ordered?

+ *

Articles will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated articles first.

+ *
+ */ + public IntercomHttpResponse listArticles(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ArticleList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public IntercomHttpResponse
createArticle(Object request) { + return createArticle(request, null); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public IntercomHttpResponse
createArticle(Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public IntercomHttpResponse
retrieveArticle(RetrieveArticleRequest request) { + return retrieveArticle(request, null); + } + + /** + * You can fetch the details of a single article by making a GET request to https://api.intercom.io/articles/<id>. + */ + public IntercomHttpResponse
retrieveArticle( + RetrieveArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public IntercomHttpResponse deleteArticle(DeleteArticleRequest request) { + return deleteArticle(request, null); + } + + /** + * You can delete a single article by making a DELETE request to https://api.intercom.io/articles/<id>. + */ + public IntercomHttpResponse deleteArticle( + DeleteArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedArticleObject.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public IntercomHttpResponse searchArticles() { + return searchArticles(SearchArticlesRequest.builder().build()); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public IntercomHttpResponse searchArticles(SearchArticlesRequest request) { + return searchArticles(request, null); + } + + /** + * You can search for articles by making a GET request to https://api.intercom.io/articles/search. + */ + public IntercomHttpResponse searchArticles( + SearchArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("articles/search"); + if (request.getPhrase().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phrase", request.getPhrase().get(), false); + } + if (request.getState().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "state", request.getState().get(), false); + } + if (request.getHelpCenterId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "help_center_id", request.getHelpCenterId().get().toString(), false); + } + if (request.getHighlight().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "highlight", request.getHighlight().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ArticleSearchResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/requests/DeleteArticleRequest.java b/src/main/java/com/intercom/api/resources/unstable/articles/requests/DeleteArticleRequest.java new file mode 100644 index 0000000..ce2fd8d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/requests/DeleteArticleRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteArticleRequest.Builder.class) +public final class DeleteArticleRequest { + private final int id; + + private final Map additionalProperties; + + private DeleteArticleRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteArticleRequest && equalTo((DeleteArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteArticleRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(DeleteArticleRequest other); + } + + public interface _FinalStage { + DeleteArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteArticleRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the article which is given by Intercom.

The unique identifier for the article which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public DeleteArticleRequest build() { + return new DeleteArticleRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/requests/RetrieveArticleRequest.java b/src/main/java/com/intercom/api/resources/unstable/articles/requests/RetrieveArticleRequest.java new file mode 100644 index 0000000..a8b12f6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/requests/RetrieveArticleRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveArticleRequest.Builder.class) +public final class RetrieveArticleRequest { + private final int id; + + private final Map additionalProperties; + + private RetrieveArticleRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveArticleRequest && equalTo((RetrieveArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveArticleRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the article which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(RetrieveArticleRequest other); + } + + public interface _FinalStage { + RetrieveArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveArticleRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the article which is given by Intercom.

The unique identifier for the article which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public RetrieveArticleRequest build() { + return new RetrieveArticleRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/requests/SearchArticlesRequest.java b/src/main/java/com/intercom/api/resources/unstable/articles/requests/SearchArticlesRequest.java new file mode 100644 index 0000000..b4fe56f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/requests/SearchArticlesRequest.java @@ -0,0 +1,193 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SearchArticlesRequest.Builder.class) +public final class SearchArticlesRequest { + private final Optional phrase; + + private final Optional state; + + private final Optional helpCenterId; + + private final Optional highlight; + + private final Map additionalProperties; + + private SearchArticlesRequest( + Optional phrase, + Optional state, + Optional helpCenterId, + Optional highlight, + Map additionalProperties) { + this.phrase = phrase; + this.state = state; + this.helpCenterId = helpCenterId; + this.highlight = highlight; + this.additionalProperties = additionalProperties; + } + + /** + * @return The phrase within your articles to search for. + */ + @JsonProperty("phrase") + public Optional getPhrase() { + return phrase; + } + + /** + * @return The state of the Articles returned. One of published, draft or all. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return The ID of the Help Center to search in. + */ + @JsonProperty("help_center_id") + public Optional getHelpCenterId() { + return helpCenterId; + } + + /** + * @return Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. + */ + @JsonProperty("highlight") + public Optional getHighlight() { + return highlight; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SearchArticlesRequest && equalTo((SearchArticlesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SearchArticlesRequest other) { + return phrase.equals(other.phrase) + && state.equals(other.state) + && helpCenterId.equals(other.helpCenterId) + && highlight.equals(other.highlight); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.phrase, this.state, this.helpCenterId, this.highlight); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional phrase = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional helpCenterId = Optional.empty(); + + private Optional highlight = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SearchArticlesRequest other) { + phrase(other.getPhrase()); + state(other.getState()); + helpCenterId(other.getHelpCenterId()); + highlight(other.getHighlight()); + return this; + } + + /** + *

The phrase within your articles to search for.

+ */ + @JsonSetter(value = "phrase", nulls = Nulls.SKIP) + public Builder phrase(Optional phrase) { + this.phrase = phrase; + return this; + } + + public Builder phrase(String phrase) { + this.phrase = Optional.ofNullable(phrase); + return this; + } + + /** + *

The state of the Articles returned. One of published, draft or all.

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(String state) { + this.state = Optional.ofNullable(state); + return this; + } + + /** + *

The ID of the Help Center to search in.

+ */ + @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) + public Builder helpCenterId(Optional helpCenterId) { + this.helpCenterId = helpCenterId; + return this; + } + + public Builder helpCenterId(Integer helpCenterId) { + this.helpCenterId = Optional.ofNullable(helpCenterId); + return this; + } + + /** + *

Return a highlighted version of the matching content within your articles. Refer to the response schema for more details.

+ */ + @JsonSetter(value = "highlight", nulls = Nulls.SKIP) + public Builder highlight(Optional highlight) { + this.highlight = highlight; + return this; + } + + public Builder highlight(Boolean highlight) { + this.highlight = Optional.ofNullable(highlight); + return this; + } + + public SearchArticlesRequest build() { + return new SearchArticlesRequest(phrase, state, helpCenterId, highlight, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/types/Article.java b/src/main/java/com/intercom/api/resources/unstable/articles/types/Article.java new file mode 100644 index 0000000..af073f5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/types/Article.java @@ -0,0 +1,686 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ArticleStatistics; +import com.intercom.api.resources.unstable.types.ArticleTranslatedContent; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Article.Builder.class) +public final class Article implements IArticleListItem { + private final Optional type; + + private final Optional id; + + private final Optional workspaceId; + + private final Optional title; + + private final Optional description; + + private final Optional body; + + private final Optional authorId; + + private final Optional state; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional url; + + private final Optional parentId; + + private final Optional> parentIds; + + private final Optional parentType; + + private final Optional defaultLocale; + + private final Optional translatedContent; + + private final Optional statistics; + + private final Map additionalProperties; + + private Article( + Optional type, + Optional id, + Optional workspaceId, + Optional title, + Optional description, + Optional body, + Optional authorId, + Optional state, + Optional createdAt, + Optional updatedAt, + Optional url, + Optional parentId, + Optional> parentIds, + Optional parentType, + Optional defaultLocale, + Optional translatedContent, + Optional statistics, + Map additionalProperties) { + this.type = type; + this.id = id; + this.workspaceId = workspaceId; + this.title = title; + this.description = description; + this.body = body; + this.authorId = authorId; + this.state = state; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.url = url; + this.parentId = parentId; + this.parentIds = parentIds; + this.parentType = parentType; + this.defaultLocale = defaultLocale; + this.translatedContent = translatedContent; + this.statistics = statistics; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - article. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the workspace which the article belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The title of the article. For multilingual articles, this will be the title of the default language's content. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The description of the article. For multilingual articles, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ + @JsonProperty("author_id") + public Optional getAuthorId() { + return authorId; + } + + /** + * @return Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The URL of the article. For multilingual articles, this will be the URL of the default language's content. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The id of the article's parent collection or section. An article without this field stands alone. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The ids of the article's parent collections or sections. An article without this field stands alone. + */ + @JsonProperty("parent_ids") + public Optional> getParentIds() { + return parentIds; + } + + /** + * @return The type of parent, which can either be a collection or section. + */ + @JsonProperty("parent_type") + public Optional getParentType() { + return parentType; + } + + /** + * @return The default locale of the help center. This field is only returned for multilingual help centers. + */ + @JsonProperty("default_locale") + public Optional getDefaultLocale() { + return defaultLocale; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + @JsonProperty("statistics") + public Optional getStatistics() { + return statistics; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Article && equalTo((Article) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Article other) { + return type.equals(other.type) + && id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && title.equals(other.title) + && description.equals(other.description) + && body.equals(other.body) + && authorId.equals(other.authorId) + && state.equals(other.state) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && url.equals(other.url) + && parentId.equals(other.parentId) + && parentIds.equals(other.parentIds) + && parentType.equals(other.parentType) + && defaultLocale.equals(other.defaultLocale) + && translatedContent.equals(other.translatedContent) + && statistics.equals(other.statistics); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.workspaceId, + this.title, + this.description, + this.body, + this.authorId, + this.state, + this.createdAt, + this.updatedAt, + this.url, + this.parentId, + this.parentIds, + this.parentType, + this.defaultLocale, + this.translatedContent, + this.statistics); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional authorId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional> parentIds = Optional.empty(); + + private Optional parentType = Optional.empty(); + + private Optional defaultLocale = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + private Optional statistics = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Article other) { + type(other.getType()); + id(other.getId()); + workspaceId(other.getWorkspaceId()); + title(other.getTitle()); + description(other.getDescription()); + body(other.getBody()); + authorId(other.getAuthorId()); + state(other.getState()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + url(other.getUrl()); + parentId(other.getParentId()); + parentIds(other.getParentIds()); + parentType(other.getParentType()); + defaultLocale(other.getDefaultLocale()); + translatedContent(other.getTranslatedContent()); + statistics(other.getStatistics()); + return this; + } + + /** + *

The type of object - article.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the article which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id of the workspace which the article belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The title of the article. For multilingual articles, this will be the title of the default language's content.

+ */ + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ */ + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + /** + *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ */ + @JsonSetter(value = "author_id", nulls = Nulls.SKIP) + public Builder authorId(Optional authorId) { + this.authorId = authorId; + return this; + } + + public Builder authorId(Integer authorId) { + this.authorId = Optional.ofNullable(authorId); + return this; + } + + /** + *

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(State state) { + this.state = Optional.ofNullable(state); + return this; + } + + /** + *

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ */ + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public Builder url(Optional url) { + this.url = url; + return this; + } + + public Builder url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public Builder parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + public Builder parentId(Integer parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ */ + @JsonSetter(value = "parent_ids", nulls = Nulls.SKIP) + public Builder parentIds(Optional> parentIds) { + this.parentIds = parentIds; + return this; + } + + public Builder parentIds(List parentIds) { + this.parentIds = Optional.ofNullable(parentIds); + return this; + } + + /** + *

The type of parent, which can either be a collection or section.

+ */ + @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) + public Builder parentType(Optional parentType) { + this.parentType = parentType; + return this; + } + + public Builder parentType(String parentType) { + this.parentType = Optional.ofNullable(parentType); + return this; + } + + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ */ + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public Builder defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; + return this; + } + + public Builder defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); + return this; + } + + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public Builder translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + + public Builder translatedContent(ArticleTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); + return this; + } + + @JsonSetter(value = "statistics", nulls = Nulls.SKIP) + public Builder statistics(Optional statistics) { + this.statistics = statistics; + return this; + } + + public Builder statistics(ArticleStatistics statistics) { + this.statistics = Optional.ofNullable(statistics); + return this; + } + + public Article build() { + return new Article( + type, + id, + workspaceId, + title, + description, + body, + authorId, + state, + createdAt, + updatedAt, + url, + parentId, + parentIds, + parentType, + defaultLocale, + translatedContent, + statistics, + additionalProperties); + } + } + + public static final class State { + public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + private final Value value; + + private final String string; + + State(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof State && this.string.equals(((State) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PUBLISHED: + return visitor.visitPublished(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "published": + return PUBLISHED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + PUBLISHED, + + DRAFT, + + UNKNOWN + } + + public interface Visitor { + T visitPublished(); + + T visitDraft(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleListItem.java b/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleListItem.java new file mode 100644 index 0000000..a8b9d44 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleListItem.java @@ -0,0 +1,659 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ArticleTranslatedContent; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ArticleListItem.Builder.class) +public final class ArticleListItem implements IArticleListItem { + private final Optional type; + + private final Optional id; + + private final Optional workspaceId; + + private final Optional title; + + private final Optional description; + + private final Optional body; + + private final Optional authorId; + + private final Optional state; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional url; + + private final Optional parentId; + + private final Optional> parentIds; + + private final Optional parentType; + + private final Optional defaultLocale; + + private final Optional translatedContent; + + private final Map additionalProperties; + + private ArticleListItem( + Optional type, + Optional id, + Optional workspaceId, + Optional title, + Optional description, + Optional body, + Optional authorId, + Optional state, + Optional createdAt, + Optional updatedAt, + Optional url, + Optional parentId, + Optional> parentIds, + Optional parentType, + Optional defaultLocale, + Optional translatedContent, + Map additionalProperties) { + this.type = type; + this.id = id; + this.workspaceId = workspaceId; + this.title = title; + this.description = description; + this.body = body; + this.authorId = authorId; + this.state = state; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.url = url; + this.parentId = parentId; + this.parentIds = parentIds; + this.parentType = parentType; + this.defaultLocale = defaultLocale; + this.translatedContent = translatedContent; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - article. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the workspace which the article belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The title of the article. For multilingual articles, this will be the title of the default language's content. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The description of the article. For multilingual articles, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + */ + @JsonProperty("author_id") + public Optional getAuthorId() { + return authorId; + } + + /** + * @return Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The URL of the article. For multilingual articles, this will be the URL of the default language's content. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The id of the article's parent collection or section. An article without this field stands alone. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The ids of the article's parent collections or sections. An article without this field stands alone. + */ + @JsonProperty("parent_ids") + public Optional> getParentIds() { + return parentIds; + } + + /** + * @return The type of parent, which can either be a collection or section. + */ + @JsonProperty("parent_type") + public Optional getParentType() { + return parentType; + } + + /** + * @return The default locale of the help center. This field is only returned for multilingual help centers. + */ + @JsonProperty("default_locale") + public Optional getDefaultLocale() { + return defaultLocale; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleListItem && equalTo((ArticleListItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleListItem other) { + return type.equals(other.type) + && id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && title.equals(other.title) + && description.equals(other.description) + && body.equals(other.body) + && authorId.equals(other.authorId) + && state.equals(other.state) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && url.equals(other.url) + && parentId.equals(other.parentId) + && parentIds.equals(other.parentIds) + && parentType.equals(other.parentType) + && defaultLocale.equals(other.defaultLocale) + && translatedContent.equals(other.translatedContent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.workspaceId, + this.title, + this.description, + this.body, + this.authorId, + this.state, + this.createdAt, + this.updatedAt, + this.url, + this.parentId, + this.parentIds, + this.parentType, + this.defaultLocale, + this.translatedContent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional authorId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional> parentIds = Optional.empty(); + + private Optional parentType = Optional.empty(); + + private Optional defaultLocale = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ArticleListItem other) { + type(other.getType()); + id(other.getId()); + workspaceId(other.getWorkspaceId()); + title(other.getTitle()); + description(other.getDescription()); + body(other.getBody()); + authorId(other.getAuthorId()); + state(other.getState()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + url(other.getUrl()); + parentId(other.getParentId()); + parentIds(other.getParentIds()); + parentType(other.getParentType()); + defaultLocale(other.getDefaultLocale()); + translatedContent(other.getTranslatedContent()); + return this; + } + + /** + *

The type of object - article.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the article which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id of the workspace which the article belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The title of the article. For multilingual articles, this will be the title of the default language's content.

+ */ + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

The description of the article. For multilingual articles, this will be the description of the default language's content.

+ */ + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The body of the article in HTML. For multilingual articles, this will be the body of the default language's content.

+ */ + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + /** + *

The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace.

+ */ + @JsonSetter(value = "author_id", nulls = Nulls.SKIP) + public Builder authorId(Optional authorId) { + this.authorId = authorId; + return this; + } + + public Builder authorId(Integer authorId) { + this.authorId = Optional.ofNullable(authorId); + return this; + } + + /** + *

Whether the article is published or is a draft. For multilingual articles, this will be the state of the default language's content.

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(State state) { + this.state = Optional.ofNullable(state); + return this; + } + + /** + *

The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The URL of the article. For multilingual articles, this will be the URL of the default language's content.

+ */ + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public Builder url(Optional url) { + this.url = url; + return this; + } + + public Builder url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The id of the article's parent collection or section. An article without this field stands alone.

+ */ + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public Builder parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + public Builder parentId(Integer parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + /** + *

The ids of the article's parent collections or sections. An article without this field stands alone.

+ */ + @JsonSetter(value = "parent_ids", nulls = Nulls.SKIP) + public Builder parentIds(Optional> parentIds) { + this.parentIds = parentIds; + return this; + } + + public Builder parentIds(List parentIds) { + this.parentIds = Optional.ofNullable(parentIds); + return this; + } + + /** + *

The type of parent, which can either be a collection or section.

+ */ + @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) + public Builder parentType(Optional parentType) { + this.parentType = parentType; + return this; + } + + public Builder parentType(String parentType) { + this.parentType = Optional.ofNullable(parentType); + return this; + } + + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ */ + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public Builder defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; + return this; + } + + public Builder defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); + return this; + } + + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public Builder translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + + public Builder translatedContent(ArticleTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); + return this; + } + + public ArticleListItem build() { + return new ArticleListItem( + type, + id, + workspaceId, + title, + description, + body, + authorId, + state, + createdAt, + updatedAt, + url, + parentId, + parentIds, + parentType, + defaultLocale, + translatedContent, + additionalProperties); + } + } + + public static final class State { + public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + private final Value value; + + private final String string; + + State(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof State && this.string.equals(((State) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PUBLISHED: + return visitor.visitPublished(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "published": + return PUBLISHED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + PUBLISHED, + + DRAFT, + + UNKNOWN + } + + public interface Visitor { + T visitPublished(); + + T visitDraft(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleSearchHighlights.java b/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleSearchHighlights.java new file mode 100644 index 0000000..f1636fb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleSearchHighlights.java @@ -0,0 +1,540 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ArticleSearchHighlights.Builder.class) +public final class ArticleSearchHighlights { + private final Optional articleId; + + private final Optional> highlightedTitle; + + private final Optional>> highlightedSummary; + + private final Map additionalProperties; + + private ArticleSearchHighlights( + Optional articleId, + Optional> highlightedTitle, + Optional>> highlightedSummary, + Map additionalProperties) { + this.articleId = articleId; + this.highlightedTitle = highlightedTitle; + this.highlightedSummary = highlightedSummary; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the corresponding article. + */ + @JsonProperty("article_id") + public Optional getArticleId() { + return articleId; + } + + /** + * @return An Article title highlighted. + */ + @JsonProperty("highlighted_title") + public Optional> getHighlightedTitle() { + return highlightedTitle; + } + + /** + * @return An Article description and body text highlighted. + */ + @JsonProperty("highlighted_summary") + public Optional>> getHighlightedSummary() { + return highlightedSummary; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleSearchHighlights && equalTo((ArticleSearchHighlights) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleSearchHighlights other) { + return articleId.equals(other.articleId) + && highlightedTitle.equals(other.highlightedTitle) + && highlightedSummary.equals(other.highlightedSummary); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.articleId, this.highlightedTitle, this.highlightedSummary); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional articleId = Optional.empty(); + + private Optional> highlightedTitle = Optional.empty(); + + private Optional>> highlightedSummary = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ArticleSearchHighlights other) { + articleId(other.getArticleId()); + highlightedTitle(other.getHighlightedTitle()); + highlightedSummary(other.getHighlightedSummary()); + return this; + } + + /** + *

The ID of the corresponding article.

+ */ + @JsonSetter(value = "article_id", nulls = Nulls.SKIP) + public Builder articleId(Optional articleId) { + this.articleId = articleId; + return this; + } + + public Builder articleId(String articleId) { + this.articleId = Optional.ofNullable(articleId); + return this; + } + + /** + *

An Article title highlighted.

+ */ + @JsonSetter(value = "highlighted_title", nulls = Nulls.SKIP) + public Builder highlightedTitle(Optional> highlightedTitle) { + this.highlightedTitle = highlightedTitle; + return this; + } + + public Builder highlightedTitle(List highlightedTitle) { + this.highlightedTitle = Optional.ofNullable(highlightedTitle); + return this; + } + + /** + *

An Article description and body text highlighted.

+ */ + @JsonSetter(value = "highlighted_summary", nulls = Nulls.SKIP) + public Builder highlightedSummary(Optional>> highlightedSummary) { + this.highlightedSummary = highlightedSummary; + return this; + } + + public Builder highlightedSummary(List> highlightedSummary) { + this.highlightedSummary = Optional.ofNullable(highlightedSummary); + return this; + } + + public ArticleSearchHighlights build() { + return new ArticleSearchHighlights(articleId, highlightedTitle, highlightedSummary, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = HighlightedTitleItem.Builder.class) + public static final class HighlightedTitleItem { + private final Optional type; + + private final Optional text; + + private final Map additionalProperties; + + private HighlightedTitleItem( + Optional type, Optional text, Map additionalProperties) { + this.type = type; + this.text = text; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of text - highlight or plain. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The text of the title. + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HighlightedTitleItem && equalTo((HighlightedTitleItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HighlightedTitleItem other) { + return type.equals(other.type) && text.equals(other.text); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.text); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional text = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(HighlightedTitleItem other) { + type(other.getType()); + text(other.getText()); + return this; + } + + /** + *

The type of text - highlight or plain.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(Type type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The text of the title.

+ */ + @JsonSetter(value = "text", nulls = Nulls.SKIP) + public Builder text(Optional text) { + this.text = text; + return this; + } + + public Builder text(String text) { + this.text = Optional.ofNullable(text); + return this; + } + + public HighlightedTitleItem build() { + return new HighlightedTitleItem(type, text, additionalProperties); + } + } + + public static final class Type { + public static final Type PLAIN = new Type(Value.PLAIN, "plain"); + + public static final Type HIGHLIGHT = new Type(Value.HIGHLIGHT, "highlight"); + + private final Value value; + + private final String string; + + Type(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Type && this.string.equals(((Type) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAIN: + return visitor.visitPlain(); + case HIGHLIGHT: + return visitor.visitHighlight(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Type valueOf(String value) { + switch (value) { + case "plain": + return PLAIN; + case "highlight": + return HIGHLIGHT; + default: + return new Type(Value.UNKNOWN, value); + } + } + + public enum Value { + HIGHLIGHT, + + PLAIN, + + UNKNOWN + } + + public interface Visitor { + T visitHighlight(); + + T visitPlain(); + + T visitUnknown(String unknownType); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = HighlightedSummaryItemItem.Builder.class) + public static final class HighlightedSummaryItemItem { + private final Optional type; + + private final Optional text; + + private final Map additionalProperties; + + private HighlightedSummaryItemItem( + Optional type, Optional text, Map additionalProperties) { + this.type = type; + this.text = text; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of text - highlight or plain. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The text of the title. + */ + @JsonProperty("text") + public Optional getText() { + return text; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HighlightedSummaryItemItem && equalTo((HighlightedSummaryItemItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HighlightedSummaryItemItem other) { + return type.equals(other.type) && text.equals(other.text); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.text); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional text = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(HighlightedSummaryItemItem other) { + type(other.getType()); + text(other.getText()); + return this; + } + + /** + *

The type of text - highlight or plain.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(Type type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The text of the title.

+ */ + @JsonSetter(value = "text", nulls = Nulls.SKIP) + public Builder text(Optional text) { + this.text = text; + return this; + } + + public Builder text(String text) { + this.text = Optional.ofNullable(text); + return this; + } + + public HighlightedSummaryItemItem build() { + return new HighlightedSummaryItemItem(type, text, additionalProperties); + } + } + + public static final class Type { + public static final Type PLAIN = new Type(Value.PLAIN, "plain"); + + public static final Type HIGHLIGHT = new Type(Value.HIGHLIGHT, "highlight"); + + private final Value value; + + private final String string; + + Type(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Type && this.string.equals(((Type) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PLAIN: + return visitor.visitPlain(); + case HIGHLIGHT: + return visitor.visitHighlight(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Type valueOf(String value) { + switch (value) { + case "plain": + return PLAIN; + case "highlight": + return HIGHLIGHT; + default: + return new Type(Value.UNKNOWN, value); + } + } + + public enum Value { + HIGHLIGHT, + + PLAIN, + + UNKNOWN + } + + public interface Visitor { + T visitHighlight(); + + T visitPlain(); + + T visitUnknown(String unknownType); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleSearchResponse.java b/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleSearchResponse.java new file mode 100644 index 0000000..4485f2d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/types/ArticleSearchResponse.java @@ -0,0 +1,303 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.CursorPages; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ArticleSearchResponse.Builder.class) +public final class ArticleSearchResponse { + private final Optional type; + + private final Optional totalCount; + + private final Optional data; + + private final Optional pages; + + private final Map additionalProperties; + + private ArticleSearchResponse( + Optional type, + Optional totalCount, + Optional data, + Optional pages, + Map additionalProperties) { + this.type = type; + this.totalCount = totalCount; + this.data = data; + this.pages = pages; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The total number of Articles matching the search query + */ + @JsonProperty("total_count") + public Optional getTotalCount() { + return totalCount; + } + + /** + * @return An object containing the results of the search. + */ + @JsonProperty("data") + public Optional getData() { + return data; + } + + @JsonProperty("pages") + public Optional getPages() { + return pages; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArticleSearchResponse && equalTo((ArticleSearchResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArticleSearchResponse other) { + return type.equals(other.type) + && totalCount.equals(other.totalCount) + && data.equals(other.data) + && pages.equals(other.pages); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.totalCount, this.data, this.pages); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional totalCount = Optional.empty(); + + private Optional data = Optional.empty(); + + private Optional pages = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ArticleSearchResponse other) { + type(other.getType()); + totalCount(other.getTotalCount()); + data(other.getData()); + pages(other.getPages()); + return this; + } + + /** + *

The type of the object - list.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The total number of Articles matching the search query

+ */ + @JsonSetter(value = "total_count", nulls = Nulls.SKIP) + public Builder totalCount(Optional totalCount) { + this.totalCount = totalCount; + return this; + } + + public Builder totalCount(Integer totalCount) { + this.totalCount = Optional.ofNullable(totalCount); + return this; + } + + /** + *

An object containing the results of the search.

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; + return this; + } + + public Builder data(Data data) { + this.data = Optional.ofNullable(data); + return this; + } + + @JsonSetter(value = "pages", nulls = Nulls.SKIP) + public Builder pages(Optional pages) { + this.pages = pages; + return this; + } + + public Builder pages(CursorPages pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + public ArticleSearchResponse build() { + return new ArticleSearchResponse(type, totalCount, data, pages, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Data.Builder.class) + public static final class Data { + private final Optional> articles; + + private final Optional> highlights; + + private final Map additionalProperties; + + private Data( + Optional> articles, + Optional> highlights, + Map additionalProperties) { + this.articles = articles; + this.highlights = highlights; + this.additionalProperties = additionalProperties; + } + + /** + * @return An array of Article objects + */ + @JsonProperty("articles") + public Optional> getArticles() { + return articles; + } + + /** + * @return A corresponding array of highlighted Article content + */ + @JsonProperty("highlights") + public Optional> getHighlights() { + return highlights; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Data && equalTo((Data) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Data other) { + return articles.equals(other.articles) && highlights.equals(other.highlights); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.articles, this.highlights); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> articles = Optional.empty(); + + private Optional> highlights = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Data other) { + articles(other.getArticles()); + highlights(other.getHighlights()); + return this; + } + + /** + *

An array of Article objects

+ */ + @JsonSetter(value = "articles", nulls = Nulls.SKIP) + public Builder articles(Optional> articles) { + this.articles = articles; + return this; + } + + public Builder articles(List
articles) { + this.articles = Optional.ofNullable(articles); + return this; + } + + /** + *

A corresponding array of highlighted Article content

+ */ + @JsonSetter(value = "highlights", nulls = Nulls.SKIP) + public Builder highlights(Optional> highlights) { + this.highlights = highlights; + return this; + } + + public Builder highlights(List highlights) { + this.highlights = Optional.ofNullable(highlights); + return this; + } + + public Data build() { + return new Data(articles, highlights, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/articles/types/IArticleListItem.java b/src/main/java/com/intercom/api/resources/unstable/articles/types/IArticleListItem.java new file mode 100644 index 0000000..9e6c21f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/articles/types/IArticleListItem.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.articles.types; + +import com.intercom.api.resources.unstable.types.ArticleTranslatedContent; +import java.util.List; +import java.util.Optional; + +public interface IArticleListItem { + Optional getType(); + + Optional getId(); + + Optional getWorkspaceId(); + + Optional getTitle(); + + Optional getDescription(); + + Optional getBody(); + + Optional getAuthorId(); + + Optional getCreatedAt(); + + Optional getUpdatedAt(); + + Optional getUrl(); + + Optional getParentId(); + + Optional> getParentIds(); + + Optional getParentType(); + + Optional getDefaultLocale(); + + Optional getTranslatedContent(); +} diff --git a/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AsyncAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AsyncAwayStatusReasonsClient.java new file mode 100644 index 0000000..07a9c4d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AsyncAwayStatusReasonsClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.awaystatusreasons; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.types.AwayStatusReason; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncAwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAwayStatusReasonsClient rawClient; + + public AsyncAwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAwayStatusReasonsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAwayStatusReasonsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture> listAwayStatusReasons() { + return this.rawClient.listAwayStatusReasons().thenApply(response -> response.body()); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture> listAwayStatusReasons(RequestOptions requestOptions) { + return this.rawClient.listAwayStatusReasons(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java new file mode 100644 index 0000000..cdb87fa --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.awaystatusreasons; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.AwayStatusReason; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture>> listAwayStatusReasons() { + return listAwayStatusReasons(null); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public CompletableFuture>> listAwayStatusReasons( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("away_status_reasons") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AwayStatusReasonsClient.java new file mode 100644 index 0000000..8800316 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/AwayStatusReasonsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.awaystatusreasons; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.types.AwayStatusReason; +import java.util.List; + +public class AwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + private final RawAwayStatusReasonsClient rawClient; + + public AwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawAwayStatusReasonsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAwayStatusReasonsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public List listAwayStatusReasons() { + return this.rawClient.listAwayStatusReasons().body(); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public List listAwayStatusReasons(RequestOptions requestOptions) { + return this.rawClient.listAwayStatusReasons(requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/RawAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/RawAwayStatusReasonsClient.java new file mode 100644 index 0000000..3a5d5db --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/awaystatusreasons/RawAwayStatusReasonsClient.java @@ -0,0 +1,85 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.awaystatusreasons; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.AwayStatusReason; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAwayStatusReasonsClient { + protected final ClientOptions clientOptions; + + public RawAwayStatusReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public IntercomHttpResponse> listAwayStatusReasons() { + return listAwayStatusReasons(null); + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + */ + public IntercomHttpResponse> listAwayStatusReasons(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("away_status_reasons") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/AsyncCompaniesClient.java b/src/main/java/com/intercom/api/resources/unstable/companies/AsyncCompaniesClient.java new file mode 100644 index 0000000..bb30f89 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/AsyncCompaniesClient.java @@ -0,0 +1,321 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.companies.requests.AttachContactToACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DeleteCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DetachContactFromACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedContactsRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedSegmentsForCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveACompanyByIdRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ScrollOverAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.unstable.companies.types.Company; +import com.intercom.api.resources.unstable.types.CompanyAttachedContacts; +import com.intercom.api.resources.unstable.types.CompanyAttachedSegments; +import com.intercom.api.resources.unstable.types.CompanyList; +import com.intercom.api.resources.unstable.types.CompanyScroll; +import com.intercom.api.resources.unstable.types.DeletedCompanyObject; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncCompaniesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCompaniesClient rawClient; + + public AsyncCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCompaniesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCompaniesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompletableFuture retrieveCompany() { + return this.rawClient.retrieveCompany().thenApply(response -> response.body()); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompletableFuture retrieveCompany(RetrieveCompanyRequest request) { + return this.rawClient.retrieveCompany(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompletableFuture retrieveCompany( + RetrieveCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveCompany(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture createOrUpdateCompany(Object request) { + return this.rawClient.createOrUpdateCompany(request).thenApply(response -> response.body()); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture createOrUpdateCompany(Object request, RequestOptions requestOptions) { + return this.rawClient.createOrUpdateCompany(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a single company. + */ + public CompletableFuture retrieveACompanyById(RetrieveACompanyByIdRequest request) { + return this.rawClient.retrieveACompanyById(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a single company. + */ + public CompletableFuture retrieveACompanyById( + RetrieveACompanyByIdRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveACompanyById(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture updateCompany(UpdateCompanyRequest request) { + return this.rawClient.updateCompany(request).thenApply(response -> response.body()); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture updateCompany(UpdateCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.updateCompany(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single company. + */ + public CompletableFuture deleteCompany(DeleteCompanyRequest request) { + return this.rawClient.deleteCompany(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single company. + */ + public CompletableFuture deleteCompany( + DeleteCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteCompany(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompletableFuture listAttachedContacts(ListAttachedContactsRequest request) { + return this.rawClient.listAttachedContacts(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompletableFuture listAttachedContacts( + ListAttachedContactsRequest request, RequestOptions requestOptions) { + return this.rawClient.listAttachedContacts(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompletableFuture listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest request) { + return this.rawClient.listAttachedSegmentsForCompanies(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompletableFuture listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listAttachedSegmentsForCompanies(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture listAllCompanies() { + return this.rawClient.listAllCompanies().thenApply(response -> response.body()); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture listAllCompanies(ListAllCompaniesRequest request) { + return this.rawClient.listAllCompanies(request).thenApply(response -> response.body()); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture listAllCompanies( + ListAllCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.listAllCompanies(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture> scrollOverAllCompanies() { + return this.rawClient.scrollOverAllCompanies().thenApply(response -> response.body()); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture> scrollOverAllCompanies(ScrollOverAllCompaniesRequest request) { + return this.rawClient.scrollOverAllCompanies(request).thenApply(response -> response.body()); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture> scrollOverAllCompanies( + ScrollOverAllCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.scrollOverAllCompanies(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can attach a company to a single contact. + */ + public CompletableFuture attachContactToACompany(AttachContactToACompanyRequest request) { + return this.rawClient.attachContactToACompany(request).thenApply(response -> response.body()); + } + + /** + * You can attach a company to a single contact. + */ + public CompletableFuture attachContactToACompany( + AttachContactToACompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.attachContactToACompany(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can detach a company from a single contact. + */ + public CompletableFuture detachContactFromACompany(DetachContactFromACompanyRequest request) { + return this.rawClient.detachContactFromACompany(request).thenApply(response -> response.body()); + } + + /** + * You can detach a company from a single contact. + */ + public CompletableFuture detachContactFromACompany( + DetachContactFromACompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.detachContactFromACompany(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/AsyncRawCompaniesClient.java b/src/main/java/com/intercom/api/resources/unstable/companies/AsyncRawCompaniesClient.java new file mode 100644 index 0000000..db3bc1c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/AsyncRawCompaniesClient.java @@ -0,0 +1,1039 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.companies.requests.AttachContactToACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DeleteCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DetachContactFromACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedContactsRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedSegmentsForCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveACompanyByIdRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ScrollOverAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.unstable.companies.types.Company; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.CompanyAttachedContacts; +import com.intercom.api.resources.unstable.types.CompanyAttachedSegments; +import com.intercom.api.resources.unstable.types.CompanyList; +import com.intercom.api.resources.unstable.types.CompanyScroll; +import com.intercom.api.resources.unstable.types.DeletedCompanyObject; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCompaniesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompletableFuture> retrieveCompany() { + return retrieveCompany(RetrieveCompanyRequest.builder().build()); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompletableFuture> retrieveCompany(RetrieveCompanyRequest request) { + return retrieveCompany(request, null); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompletableFuture> retrieveCompany( + RetrieveCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getTagId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tag_id", request.getTagId().get(), false); + } + if (request.getSegmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "segment_id", request.getSegmentId().get(), false); + } + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture> createOrUpdateCompany(Object request) { + return createOrUpdateCompany(request, null); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture> createOrUpdateCompany( + Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Company.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a single company. + */ + public CompletableFuture> retrieveACompanyById(RetrieveACompanyByIdRequest request) { + return retrieveACompanyById(request, null); + } + + /** + * You can fetch a single company. + */ + public CompletableFuture> retrieveACompanyById( + RetrieveACompanyByIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Company.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture> updateCompany(UpdateCompanyRequest request) { + return updateCompany(request, null); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public CompletableFuture> updateCompany( + UpdateCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("PUT", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Company.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a single company. + */ + public CompletableFuture> deleteCompany(DeleteCompanyRequest request) { + return deleteCompany(request, null); + } + + /** + * You can delete a single company. + */ + public CompletableFuture> deleteCompany( + DeleteCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DeletedCompanyObject.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompletableFuture> listAttachedContacts( + ListAttachedContactsRequest request) { + return listAttachedContacts(request, null); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompletableFuture> listAttachedContacts( + ListAttachedContactsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .addPathSegments("contacts") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CompanyAttachedContacts.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompletableFuture> listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest request) { + return listAttachedSegmentsForCompanies(request, null); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompletableFuture> listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .addPathSegments("segments") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CompanyAttachedSegments.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> listAllCompanies() { + return listAllCompanies(ListAllCompaniesRequest.builder().build()); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> listAllCompanies(ListAllCompaniesRequest request) { + return listAllCompanies(request, null); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> listAllCompanies( + ListAllCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/list"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getOrder().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order", request.getOrder().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture>> scrollOverAllCompanies() { + return scrollOverAllCompanies(ScrollOverAllCompaniesRequest.builder().build()); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture>> scrollOverAllCompanies( + ScrollOverAllCompaniesRequest request) { + return scrollOverAllCompanies(request, null); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public CompletableFuture>> scrollOverAllCompanies( + ScrollOverAllCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/scroll"); + if (request.getScrollParam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scroll_param", request.getScrollParam().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can attach a company to a single contact. + */ + public CompletableFuture> attachContactToACompany( + AttachContactToACompanyRequest request) { + return attachContactToACompany(request, null); + } + + /** + * You can attach a company to a single contact. + */ + public CompletableFuture> attachContactToACompany( + AttachContactToACompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("companies") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Company.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can detach a company from a single contact. + */ + public CompletableFuture> detachContactFromACompany( + DetachContactFromACompanyRequest request) { + return detachContactFromACompany(request, null); + } + + /** + * You can detach a company from a single contact. + */ + public CompletableFuture> detachContactFromACompany( + DetachContactFromACompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Company.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/CompaniesClient.java b/src/main/java/com/intercom/api/resources/unstable/companies/CompaniesClient.java new file mode 100644 index 0000000..c3d31ae --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/CompaniesClient.java @@ -0,0 +1,313 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.companies.requests.AttachContactToACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DeleteCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DetachContactFromACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedContactsRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedSegmentsForCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveACompanyByIdRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ScrollOverAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.unstable.companies.types.Company; +import com.intercom.api.resources.unstable.types.CompanyAttachedContacts; +import com.intercom.api.resources.unstable.types.CompanyAttachedSegments; +import com.intercom.api.resources.unstable.types.CompanyList; +import com.intercom.api.resources.unstable.types.CompanyScroll; +import com.intercom.api.resources.unstable.types.DeletedCompanyObject; +import java.util.Optional; + +public class CompaniesClient { + protected final ClientOptions clientOptions; + + private final RawCompaniesClient rawClient; + + public CompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCompaniesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCompaniesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompanyList retrieveCompany() { + return this.rawClient.retrieveCompany().body(); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompanyList retrieveCompany(RetrieveCompanyRequest request) { + return this.rawClient.retrieveCompany(request).body(); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public CompanyList retrieveCompany(RetrieveCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveCompany(request, requestOptions).body(); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public Company createOrUpdateCompany(Object request) { + return this.rawClient.createOrUpdateCompany(request).body(); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public Company createOrUpdateCompany(Object request, RequestOptions requestOptions) { + return this.rawClient.createOrUpdateCompany(request, requestOptions).body(); + } + + /** + * You can fetch a single company. + */ + public Company retrieveACompanyById(RetrieveACompanyByIdRequest request) { + return this.rawClient.retrieveACompanyById(request).body(); + } + + /** + * You can fetch a single company. + */ + public Company retrieveACompanyById(RetrieveACompanyByIdRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveACompanyById(request, requestOptions).body(); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public Company updateCompany(UpdateCompanyRequest request) { + return this.rawClient.updateCompany(request).body(); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public Company updateCompany(UpdateCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.updateCompany(request, requestOptions).body(); + } + + /** + * You can delete a single company. + */ + public DeletedCompanyObject deleteCompany(DeleteCompanyRequest request) { + return this.rawClient.deleteCompany(request).body(); + } + + /** + * You can delete a single company. + */ + public DeletedCompanyObject deleteCompany(DeleteCompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteCompany(request, requestOptions).body(); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompanyAttachedContacts listAttachedContacts(ListAttachedContactsRequest request) { + return this.rawClient.listAttachedContacts(request).body(); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public CompanyAttachedContacts listAttachedContacts( + ListAttachedContactsRequest request, RequestOptions requestOptions) { + return this.rawClient.listAttachedContacts(request, requestOptions).body(); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompanyAttachedSegments listAttachedSegmentsForCompanies(ListAttachedSegmentsForCompaniesRequest request) { + return this.rawClient.listAttachedSegmentsForCompanies(request).body(); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public CompanyAttachedSegments listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient + .listAttachedSegmentsForCompanies(request, requestOptions) + .body(); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompanyList listAllCompanies() { + return this.rawClient.listAllCompanies().body(); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompanyList listAllCompanies(ListAllCompaniesRequest request) { + return this.rawClient.listAllCompanies(request).body(); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompanyList listAllCompanies(ListAllCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.listAllCompanies(request, requestOptions).body(); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public Optional scrollOverAllCompanies() { + return this.rawClient.scrollOverAllCompanies().body(); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public Optional scrollOverAllCompanies(ScrollOverAllCompaniesRequest request) { + return this.rawClient.scrollOverAllCompanies(request).body(); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public Optional scrollOverAllCompanies( + ScrollOverAllCompaniesRequest request, RequestOptions requestOptions) { + return this.rawClient.scrollOverAllCompanies(request, requestOptions).body(); + } + + /** + * You can attach a company to a single contact. + */ + public Company attachContactToACompany(AttachContactToACompanyRequest request) { + return this.rawClient.attachContactToACompany(request).body(); + } + + /** + * You can attach a company to a single contact. + */ + public Company attachContactToACompany(AttachContactToACompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.attachContactToACompany(request, requestOptions).body(); + } + + /** + * You can detach a company from a single contact. + */ + public Company detachContactFromACompany(DetachContactFromACompanyRequest request) { + return this.rawClient.detachContactFromACompany(request).body(); + } + + /** + * You can detach a company from a single contact. + */ + public Company detachContactFromACompany(DetachContactFromACompanyRequest request, RequestOptions requestOptions) { + return this.rawClient.detachContactFromACompany(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/RawCompaniesClient.java b/src/main/java/com/intercom/api/resources/unstable/companies/RawCompaniesClient.java new file mode 100644 index 0000000..39d36d4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/RawCompaniesClient.java @@ -0,0 +1,842 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.companies.requests.AttachContactToACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DeleteCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.DetachContactFromACompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedContactsRequest; +import com.intercom.api.resources.unstable.companies.requests.ListAttachedSegmentsForCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveACompanyByIdRequest; +import com.intercom.api.resources.unstable.companies.requests.RetrieveCompanyRequest; +import com.intercom.api.resources.unstable.companies.requests.ScrollOverAllCompaniesRequest; +import com.intercom.api.resources.unstable.companies.requests.UpdateCompanyRequest; +import com.intercom.api.resources.unstable.companies.types.Company; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.CompanyAttachedContacts; +import com.intercom.api.resources.unstable.types.CompanyAttachedSegments; +import com.intercom.api.resources.unstable.types.CompanyList; +import com.intercom.api.resources.unstable.types.CompanyScroll; +import com.intercom.api.resources.unstable.types.DeletedCompanyObject; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCompaniesClient { + protected final ClientOptions clientOptions; + + public RawCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public IntercomHttpResponse retrieveCompany() { + return retrieveCompany(RetrieveCompanyRequest.builder().build()); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public IntercomHttpResponse retrieveCompany(RetrieveCompanyRequest request) { + return retrieveCompany(request, null); + } + + /** + * You can fetch a single company by passing in company_id or name. + *

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

+ *

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

+ *

You can fetch all companies and filter by segment_id or tag_id as a query parameter.

+ *

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

+ *

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

+ */ + public IntercomHttpResponse retrieveCompany( + RetrieveCompanyRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies"); + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getTagId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tag_id", request.getTagId().get(), false); + } + if (request.getSegmentId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "segment_id", request.getSegmentId().get(), false); + } + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public IntercomHttpResponse createOrUpdateCompany(Object request) { + return createOrUpdateCompany(request, null); + } + + /** + * You can create or update a company. + *

Companies will be only visible in Intercom when there is at least one associated user.

+ *

Companies are looked up via company_id in a POST request, if not found via company_id, the new company will be created, if found, that company will be updated.

+ *

{% admonition type="warning" name="Using company_id" %} + * You can set a unique company_id value when creating a company. However, it is not possible to update company_id. Be sure to set a unique value once upon creation of the company. + * {% /admonition %}

+ */ + public IntercomHttpResponse createOrUpdateCompany(Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a single company. + */ + public IntercomHttpResponse retrieveACompanyById(RetrieveACompanyByIdRequest request) { + return retrieveACompanyById(request, null); + } + + /** + * You can fetch a single company. + */ + public IntercomHttpResponse retrieveACompanyById( + RetrieveACompanyByIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public IntercomHttpResponse updateCompany(UpdateCompanyRequest request) { + return updateCompany(request, null); + } + + /** + * You can update a single company using the Intercom provisioned id. + *

{% admonition type="warning" name="Using company_id" %} + * When updating a company it is not possible to update company_id. This can only be set once upon creation of the company. + * {% /admonition %}

+ */ + public IntercomHttpResponse updateCompany(UpdateCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("PUT", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single company. + */ + public IntercomHttpResponse deleteCompany(DeleteCompanyRequest request) { + return deleteCompany(request, null); + } + + /** + * You can delete a single company. + */ + public IntercomHttpResponse deleteCompany( + DeleteCompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCompanyObject.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public IntercomHttpResponse listAttachedContacts(ListAttachedContactsRequest request) { + return listAttachedContacts(request, null); + } + + /** + * You can fetch a list of all contacts that belong to a company. + */ + public IntercomHttpResponse listAttachedContacts( + ListAttachedContactsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .addPathSegments("contacts") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyAttachedContacts.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public IntercomHttpResponse listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest request) { + return listAttachedSegmentsForCompanies(request, null); + } + + /** + * You can fetch a list of all segments that belong to a company. + */ + public IntercomHttpResponse listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies") + .addPathSegment(request.getId()) + .addPathSegments("segments") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyAttachedSegments.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public IntercomHttpResponse listAllCompanies() { + return listAllCompanies(ListAllCompaniesRequest.builder().build()); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public IntercomHttpResponse listAllCompanies(ListAllCompaniesRequest request) { + return listAllCompanies(request, null); + } + + /** + * You can list companies. The company list is sorted by the last_request_at field and by default is ordered descending, most recently requested first. + *

Note that the API does not include companies who have no associated users in list responses.

+ *

When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the Scroll API. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public IntercomHttpResponse listAllCompanies( + ListAllCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/list"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get().toString(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getOrder().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order", request.getOrder().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public IntercomHttpResponse> scrollOverAllCompanies() { + return scrollOverAllCompanies(ScrollOverAllCompaniesRequest.builder().build()); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public IntercomHttpResponse> scrollOverAllCompanies(ScrollOverAllCompaniesRequest request) { + return scrollOverAllCompanies(request, null); + } + + /** + * The list all companies functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + *
    + *
  • Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
  • + *
  • If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
  • + *
  • If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
  • + *
+ *

{% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. + * {% /admonition %}

+ */ + public IntercomHttpResponse> scrollOverAllCompanies( + ScrollOverAllCompaniesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("companies/scroll"); + if (request.getScrollParam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "scroll_param", request.getScrollParam().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can attach a company to a single contact. + */ + public IntercomHttpResponse attachContactToACompany(AttachContactToACompanyRequest request) { + return attachContactToACompany(request, null); + } + + /** + * You can attach a company to a single contact. + */ + public IntercomHttpResponse attachContactToACompany( + AttachContactToACompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("companies") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can detach a company from a single contact. + */ + public IntercomHttpResponse detachContactFromACompany(DetachContactFromACompanyRequest request) { + return detachContactFromACompany(request, null); + } + + /** + * You can detach a company from a single contact. + */ + public IntercomHttpResponse detachContactFromACompany( + DetachContactFromACompanyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("companies") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/AttachContactToACompanyRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/AttachContactToACompanyRequest.java new file mode 100644 index 0000000..502f8e7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/AttachContactToACompanyRequest.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AttachContactToACompanyRequest.Builder.class) +public final class AttachContactToACompanyRequest { + private final String id; + + private final String companyId; + + private final Map additionalProperties; + + private AttachContactToACompanyRequest(String id, String companyId, Map additionalProperties) { + this.id = id; + this.companyId = companyId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public String getCompanyId() { + return companyId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachContactToACompanyRequest && equalTo((AttachContactToACompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachContactToACompanyRequest other) { + return id.equals(other.id) && companyId.equals(other.companyId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.companyId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + CompanyIdStage id(@NotNull String id); + + Builder from(AttachContactToACompanyRequest other); + } + + public interface CompanyIdStage { + /** + * The unique identifier for the company which is given by Intercom + */ + _FinalStage companyId(@NotNull String companyId); + } + + public interface _FinalStage { + AttachContactToACompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, CompanyIdStage, _FinalStage { + private String id; + + private String companyId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachContactToACompanyRequest other) { + id(other.getId()); + companyId(other.getCompanyId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public CompanyIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("company_id") + public _FinalStage companyId(@NotNull String companyId) { + this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); + return this; + } + + @java.lang.Override + public AttachContactToACompanyRequest build() { + return new AttachContactToACompanyRequest(id, companyId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/DeleteCompanyRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/DeleteCompanyRequest.java new file mode 100644 index 0000000..6eff3bd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/DeleteCompanyRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteCompanyRequest.Builder.class) +public final class DeleteCompanyRequest { + private final String id; + + private final Map additionalProperties; + + private DeleteCompanyRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCompanyRequest && equalTo((DeleteCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCompanyRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the company which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(DeleteCompanyRequest other); + } + + public interface _FinalStage { + DeleteCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCompanyRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DeleteCompanyRequest build() { + return new DeleteCompanyRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/DetachContactFromACompanyRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/DetachContactFromACompanyRequest.java new file mode 100644 index 0000000..16cf89c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/DetachContactFromACompanyRequest.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetachContactFromACompanyRequest.Builder.class) +public final class DetachContactFromACompanyRequest { + private final String contactId; + + private final String id; + + private final Map additionalProperties; + + private DetachContactFromACompanyRequest(String contactId, String id, Map additionalProperties) { + this.contactId = contactId; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachContactFromACompanyRequest && equalTo((DetachContactFromACompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachContactFromACompanyRequest other) { + return contactId.equals(other.contactId) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + IdStage contactId(@NotNull String contactId); + + Builder from(DetachContactFromACompanyRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the company which is given by Intercom + */ + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + DetachContactFromACompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, IdStage, _FinalStage { + private String contactId; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachContactFromACompanyRequest other) { + contactId(other.getContactId()); + id(other.getId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public IdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DetachContactFromACompanyRequest build() { + return new DetachContactFromACompanyRequest(contactId, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAllCompaniesRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAllCompaniesRequest.java new file mode 100644 index 0000000..da617cd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAllCompaniesRequest.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListAllCompaniesRequest.Builder.class) +public final class ListAllCompaniesRequest { + private final Optional page; + + private final Optional perPage; + + private final Optional order; + + private final Map additionalProperties; + + private ListAllCompaniesRequest( + Optional page, + Optional perPage, + Optional order, + Map additionalProperties) { + this.page = page; + this.perPage = perPage; + this.order = order; + this.additionalProperties = additionalProperties; + } + + /** + * @return The page of results to fetch. Defaults to first page + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return How many results to return per page. Defaults to 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + /** + * @return asc or desc. Return the companies in ascending or descending order. Defaults to desc + */ + @JsonProperty("order") + public Optional getOrder() { + return order; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListAllCompaniesRequest && equalTo((ListAllCompaniesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListAllCompaniesRequest other) { + return page.equals(other.page) && perPage.equals(other.perPage) && order.equals(other.order); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.page, this.perPage, this.order); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional page = Optional.empty(); + + private Optional perPage = Optional.empty(); + + private Optional order = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListAllCompaniesRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + order(other.getOrder()); + return this; + } + + /** + *

The page of results to fetch. Defaults to first page

+ */ + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + /** + *

How many results to return per page. Defaults to 15

+ */ + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public Builder perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + public Builder perPage(Integer perPage) { + this.perPage = Optional.ofNullable(perPage); + return this; + } + + /** + *

asc or desc. Return the companies in ascending or descending order. Defaults to desc

+ */ + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public Builder order(Optional order) { + this.order = order; + return this; + } + + public Builder order(String order) { + this.order = Optional.ofNullable(order); + return this; + } + + public ListAllCompaniesRequest build() { + return new ListAllCompaniesRequest(page, perPage, order, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAttachedContactsRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAttachedContactsRequest.java new file mode 100644 index 0000000..d52055a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAttachedContactsRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListAttachedContactsRequest.Builder.class) +public final class ListAttachedContactsRequest { + private final String id; + + private final Map additionalProperties; + + private ListAttachedContactsRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListAttachedContactsRequest && equalTo((ListAttachedContactsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListAttachedContactsRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the company which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(ListAttachedContactsRequest other); + } + + public interface _FinalStage { + ListAttachedContactsRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListAttachedContactsRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public ListAttachedContactsRequest build() { + return new ListAttachedContactsRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAttachedSegmentsForCompaniesRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAttachedSegmentsForCompaniesRequest.java new file mode 100644 index 0000000..5bc771f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ListAttachedSegmentsForCompaniesRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListAttachedSegmentsForCompaniesRequest.Builder.class) +public final class ListAttachedSegmentsForCompaniesRequest { + private final String id; + + private final Map additionalProperties; + + private ListAttachedSegmentsForCompaniesRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListAttachedSegmentsForCompaniesRequest + && equalTo((ListAttachedSegmentsForCompaniesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListAttachedSegmentsForCompaniesRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the company which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(ListAttachedSegmentsForCompaniesRequest other); + } + + public interface _FinalStage { + ListAttachedSegmentsForCompaniesRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListAttachedSegmentsForCompaniesRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public ListAttachedSegmentsForCompaniesRequest build() { + return new ListAttachedSegmentsForCompaniesRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/RetrieveACompanyByIdRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/RetrieveACompanyByIdRequest.java new file mode 100644 index 0000000..93e9240 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/RetrieveACompanyByIdRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveACompanyByIdRequest.Builder.class) +public final class RetrieveACompanyByIdRequest { + private final String id; + + private final Map additionalProperties; + + private RetrieveACompanyByIdRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveACompanyByIdRequest && equalTo((RetrieveACompanyByIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveACompanyByIdRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the company which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(RetrieveACompanyByIdRequest other); + } + + public interface _FinalStage { + RetrieveACompanyByIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveACompanyByIdRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public RetrieveACompanyByIdRequest build() { + return new RetrieveACompanyByIdRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/RetrieveCompanyRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/RetrieveCompanyRequest.java new file mode 100644 index 0000000..7783059 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/RetrieveCompanyRequest.java @@ -0,0 +1,253 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveCompanyRequest.Builder.class) +public final class RetrieveCompanyRequest { + private final Optional name; + + private final Optional companyId; + + private final Optional tagId; + + private final Optional segmentId; + + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private RetrieveCompanyRequest( + Optional name, + Optional companyId, + Optional tagId, + Optional segmentId, + Optional page, + Optional perPage, + Map additionalProperties) { + this.name = name; + this.companyId = companyId; + this.tagId = tagId; + this.segmentId = segmentId; + this.page = page; + this.perPage = perPage; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the company to filter by. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The company_id of the company to filter by. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return The tag_id of the company to filter by. + */ + @JsonProperty("tag_id") + public Optional getTagId() { + return tagId; + } + + /** + * @return The segment_id of the company to filter by. + */ + @JsonProperty("segment_id") + public Optional getSegmentId() { + return segmentId; + } + + /** + * @return The page of results to fetch. Defaults to first page + */ + @JsonProperty("page") + public Optional getPage() { + return page; + } + + /** + * @return How many results to display per page. Defaults to 15 + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveCompanyRequest && equalTo((RetrieveCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveCompanyRequest other) { + return name.equals(other.name) + && companyId.equals(other.companyId) + && tagId.equals(other.tagId) + && segmentId.equals(other.segmentId) + && page.equals(other.page) + && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.companyId, this.tagId, this.segmentId, this.page, this.perPage); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional name = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional tagId = Optional.empty(); + + private Optional segmentId = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional perPage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(RetrieveCompanyRequest other) { + name(other.getName()); + companyId(other.getCompanyId()); + tagId(other.getTagId()); + segmentId(other.getSegmentId()); + page(other.getPage()); + perPage(other.getPerPage()); + return this; + } + + /** + *

The name of the company to filter by.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The company_id of the company to filter by.

+ */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

The tag_id of the company to filter by.

+ */ + @JsonSetter(value = "tag_id", nulls = Nulls.SKIP) + public Builder tagId(Optional tagId) { + this.tagId = tagId; + return this; + } + + public Builder tagId(String tagId) { + this.tagId = Optional.ofNullable(tagId); + return this; + } + + /** + *

The segment_id of the company to filter by.

+ */ + @JsonSetter(value = "segment_id", nulls = Nulls.SKIP) + public Builder segmentId(Optional segmentId) { + this.segmentId = segmentId; + return this; + } + + public Builder segmentId(String segmentId) { + this.segmentId = Optional.ofNullable(segmentId); + return this; + } + + /** + *

The page of results to fetch. Defaults to first page

+ */ + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public Builder page(Optional page) { + this.page = page; + return this; + } + + public Builder page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + /** + *

How many results to display per page. Defaults to 15

+ */ + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public Builder perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + public Builder perPage(Integer perPage) { + this.perPage = Optional.ofNullable(perPage); + return this; + } + + public RetrieveCompanyRequest build() { + return new RetrieveCompanyRequest(name, companyId, tagId, segmentId, page, perPage, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/ScrollOverAllCompaniesRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ScrollOverAllCompaniesRequest.java new file mode 100644 index 0000000..28f4de9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/ScrollOverAllCompaniesRequest.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ScrollOverAllCompaniesRequest.Builder.class) +public final class ScrollOverAllCompaniesRequest { + private final Optional scrollParam; + + private final Map additionalProperties; + + private ScrollOverAllCompaniesRequest(Optional scrollParam, Map additionalProperties) { + this.scrollParam = scrollParam; + this.additionalProperties = additionalProperties; + } + + /** + * @return + */ + @JsonProperty("scroll_param") + public Optional getScrollParam() { + return scrollParam; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ScrollOverAllCompaniesRequest && equalTo((ScrollOverAllCompaniesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ScrollOverAllCompaniesRequest other) { + return scrollParam.equals(other.scrollParam); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.scrollParam); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional scrollParam = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ScrollOverAllCompaniesRequest other) { + scrollParam(other.getScrollParam()); + return this; + } + + @JsonSetter(value = "scroll_param", nulls = Nulls.SKIP) + public Builder scrollParam(Optional scrollParam) { + this.scrollParam = scrollParam; + return this; + } + + public Builder scrollParam(String scrollParam) { + this.scrollParam = Optional.ofNullable(scrollParam); + return this; + } + + public ScrollOverAllCompaniesRequest build() { + return new ScrollOverAllCompaniesRequest(scrollParam, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/requests/UpdateCompanyRequest.java b/src/main/java/com/intercom/api/resources/unstable/companies/requests/UpdateCompanyRequest.java new file mode 100644 index 0000000..8cc421b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/requests/UpdateCompanyRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateCompanyRequest.Builder.class) +public final class UpdateCompanyRequest { + private final String id; + + private final Map additionalProperties; + + private UpdateCompanyRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the company which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCompanyRequest && equalTo((UpdateCompanyRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCompanyRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the company which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(UpdateCompanyRequest other); + } + + public interface _FinalStage { + UpdateCompanyRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCompanyRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the company which is given by Intercom

The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public UpdateCompanyRequest build() { + return new UpdateCompanyRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/companies/types/Company.java b/src/main/java/com/intercom/api/resources/unstable/companies/types/Company.java new file mode 100644 index 0000000..64dce15 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/companies/types/Company.java @@ -0,0 +1,1032 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.companies.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.segments.types.Segment; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Company.Builder.class) +public final class Company { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Optional appId; + + private final Optional plan; + + private final Optional companyId; + + private final Optional remoteCreatedAt; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional lastRequestAt; + + private final Optional size; + + private final Optional website; + + private final Optional industry; + + private final Optional monthlySpend; + + private final Optional sessionCount; + + private final Optional userCount; + + private final Optional> customAttributes; + + private final Optional tags; + + private final Optional segments; + + private final Map additionalProperties; + + private Company( + Optional type, + Optional id, + Optional name, + Optional appId, + Optional plan, + Optional companyId, + Optional remoteCreatedAt, + Optional createdAt, + Optional updatedAt, + Optional lastRequestAt, + Optional size, + Optional website, + Optional industry, + Optional monthlySpend, + Optional sessionCount, + Optional userCount, + Optional> customAttributes, + Optional tags, + Optional segments, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.appId = appId; + this.plan = plan; + this.companyId = companyId; + this.remoteCreatedAt = remoteCreatedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.lastRequestAt = lastRequestAt; + this.size = size; + this.website = website; + this.industry = industry; + this.monthlySpend = monthlySpend; + this.sessionCount = sessionCount; + this.userCount = userCount; + this.customAttributes = customAttributes; + this.tags = tags; + this.segments = segments; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is company + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The Intercom defined id representing the company. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the company. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The Intercom defined code of the workspace the company is associated to. + */ + @JsonProperty("app_id") + public Optional getAppId() { + return appId; + } + + @JsonProperty("plan") + public Optional getPlan() { + return plan; + } + + /** + * @return The company id you have defined for the company. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return The time the company was created by you. + */ + @JsonProperty("remote_created_at") + public Optional getRemoteCreatedAt() { + return remoteCreatedAt; + } + + /** + * @return The time the company was added in Intercom. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the company was updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The time the company last recorded making a request. + */ + @JsonProperty("last_request_at") + public Optional getLastRequestAt() { + return lastRequestAt; + } + + /** + * @return The number of employees in the company. + */ + @JsonProperty("size") + public Optional getSize() { + return size; + } + + /** + * @return The URL for the company website. + */ + @JsonProperty("website") + public Optional getWebsite() { + return website; + } + + /** + * @return The industry that the company operates in. + */ + @JsonProperty("industry") + public Optional getIndustry() { + return industry; + } + + /** + * @return How much revenue the company generates for your business. + */ + @JsonProperty("monthly_spend") + public Optional getMonthlySpend() { + return monthlySpend; + } + + /** + * @return How many sessions the company has recorded. + */ + @JsonProperty("session_count") + public Optional getSessionCount() { + return sessionCount; + } + + /** + * @return The number of users in the company. + */ + @JsonProperty("user_count") + public Optional getUserCount() { + return userCount; + } + + /** + * @return The custom attributes you have set on the company. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + /** + * @return The list of tags associated with the company + */ + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + /** + * @return The list of segments associated with the company + */ + @JsonProperty("segments") + public Optional getSegments() { + return segments; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Company && equalTo((Company) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Company other) { + return type.equals(other.type) + && id.equals(other.id) + && name.equals(other.name) + && appId.equals(other.appId) + && plan.equals(other.plan) + && companyId.equals(other.companyId) + && remoteCreatedAt.equals(other.remoteCreatedAt) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && lastRequestAt.equals(other.lastRequestAt) + && size.equals(other.size) + && website.equals(other.website) + && industry.equals(other.industry) + && monthlySpend.equals(other.monthlySpend) + && sessionCount.equals(other.sessionCount) + && userCount.equals(other.userCount) + && customAttributes.equals(other.customAttributes) + && tags.equals(other.tags) + && segments.equals(other.segments); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.name, + this.appId, + this.plan, + this.companyId, + this.remoteCreatedAt, + this.createdAt, + this.updatedAt, + this.lastRequestAt, + this.size, + this.website, + this.industry, + this.monthlySpend, + this.sessionCount, + this.userCount, + this.customAttributes, + this.tags, + this.segments); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional appId = Optional.empty(); + + private Optional plan = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional remoteCreatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional lastRequestAt = Optional.empty(); + + private Optional size = Optional.empty(); + + private Optional website = Optional.empty(); + + private Optional industry = Optional.empty(); + + private Optional monthlySpend = Optional.empty(); + + private Optional sessionCount = Optional.empty(); + + private Optional userCount = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional segments = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Company other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + appId(other.getAppId()); + plan(other.getPlan()); + companyId(other.getCompanyId()); + remoteCreatedAt(other.getRemoteCreatedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + lastRequestAt(other.getLastRequestAt()); + size(other.getSize()); + website(other.getWebsite()); + industry(other.getIndustry()); + monthlySpend(other.getMonthlySpend()); + sessionCount(other.getSessionCount()); + userCount(other.getUserCount()); + customAttributes(other.getCustomAttributes()); + tags(other.getTags()); + segments(other.getSegments()); + return this; + } + + /** + *

Value is company

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The Intercom defined id representing the company.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the company.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The Intercom defined code of the workspace the company is associated to.

+ */ + @JsonSetter(value = "app_id", nulls = Nulls.SKIP) + public Builder appId(Optional appId) { + this.appId = appId; + return this; + } + + public Builder appId(String appId) { + this.appId = Optional.ofNullable(appId); + return this; + } + + @JsonSetter(value = "plan", nulls = Nulls.SKIP) + public Builder plan(Optional plan) { + this.plan = plan; + return this; + } + + public Builder plan(Plan plan) { + this.plan = Optional.ofNullable(plan); + return this; + } + + /** + *

The company id you have defined for the company.

+ */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

The time the company was created by you.

+ */ + @JsonSetter(value = "remote_created_at", nulls = Nulls.SKIP) + public Builder remoteCreatedAt(Optional remoteCreatedAt) { + this.remoteCreatedAt = remoteCreatedAt; + return this; + } + + public Builder remoteCreatedAt(Integer remoteCreatedAt) { + this.remoteCreatedAt = Optional.ofNullable(remoteCreatedAt); + return this; + } + + /** + *

The time the company was added in Intercom.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The last time the company was updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The time the company last recorded making a request.

+ */ + @JsonSetter(value = "last_request_at", nulls = Nulls.SKIP) + public Builder lastRequestAt(Optional lastRequestAt) { + this.lastRequestAt = lastRequestAt; + return this; + } + + public Builder lastRequestAt(Integer lastRequestAt) { + this.lastRequestAt = Optional.ofNullable(lastRequestAt); + return this; + } + + /** + *

The number of employees in the company.

+ */ + @JsonSetter(value = "size", nulls = Nulls.SKIP) + public Builder size(Optional size) { + this.size = size; + return this; + } + + public Builder size(Integer size) { + this.size = Optional.ofNullable(size); + return this; + } + + /** + *

The URL for the company website.

+ */ + @JsonSetter(value = "website", nulls = Nulls.SKIP) + public Builder website(Optional website) { + this.website = website; + return this; + } + + public Builder website(String website) { + this.website = Optional.ofNullable(website); + return this; + } + + /** + *

The industry that the company operates in.

+ */ + @JsonSetter(value = "industry", nulls = Nulls.SKIP) + public Builder industry(Optional industry) { + this.industry = industry; + return this; + } + + public Builder industry(String industry) { + this.industry = Optional.ofNullable(industry); + return this; + } + + /** + *

How much revenue the company generates for your business.

+ */ + @JsonSetter(value = "monthly_spend", nulls = Nulls.SKIP) + public Builder monthlySpend(Optional monthlySpend) { + this.monthlySpend = monthlySpend; + return this; + } + + public Builder monthlySpend(Integer monthlySpend) { + this.monthlySpend = Optional.ofNullable(monthlySpend); + return this; + } + + /** + *

How many sessions the company has recorded.

+ */ + @JsonSetter(value = "session_count", nulls = Nulls.SKIP) + public Builder sessionCount(Optional sessionCount) { + this.sessionCount = sessionCount; + return this; + } + + public Builder sessionCount(Integer sessionCount) { + this.sessionCount = Optional.ofNullable(sessionCount); + return this; + } + + /** + *

The number of users in the company.

+ */ + @JsonSetter(value = "user_count", nulls = Nulls.SKIP) + public Builder userCount(Optional userCount) { + this.userCount = userCount; + return this; + } + + public Builder userCount(Integer userCount) { + this.userCount = Optional.ofNullable(userCount); + return this; + } + + /** + *

The custom attributes you have set on the company.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

The list of tags associated with the company

+ */ + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(Tags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + /** + *

The list of segments associated with the company

+ */ + @JsonSetter(value = "segments", nulls = Nulls.SKIP) + public Builder segments(Optional segments) { + this.segments = segments; + return this; + } + + public Builder segments(Segments segments) { + this.segments = Optional.ofNullable(segments); + return this; + } + + public Company build() { + return new Company( + type, + id, + name, + appId, + plan, + companyId, + remoteCreatedAt, + createdAt, + updatedAt, + lastRequestAt, + size, + website, + industry, + monthlySpend, + sessionCount, + userCount, + customAttributes, + tags, + segments, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Plan.Builder.class) + public static final class Plan { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Map additionalProperties; + + private Plan( + Optional type, + Optional id, + Optional name, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is always "plan" + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the plan + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the plan + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Plan && equalTo((Plan) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Plan other) { + return type.equals(other.type) && id.equals(other.id) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Plan other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + return this; + } + + /** + *

Value is always "plan"

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the plan

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the plan

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + public Plan build() { + return new Plan(type, id, name, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Tags.Builder.class) + public static final class Tags { + private final Optional type; + + private final Optional> tags; + + private final Map additionalProperties; + + private Tags(Optional type, Optional> tags, Map additionalProperties) { + this.type = type; + this.tags = tags; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("tags") + public Optional> getTags() { + return tags; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Tags && equalTo((Tags) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Tags other) { + return type.equals(other.type) && tags.equals(other.tags); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.tags); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional> tags = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Tags other) { + type(other.getType()); + tags(other.getTags()); + return this; + } + + /** + *

The type of the object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional> tags) { + this.tags = tags; + return this; + } + + public Builder tags(List tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + public Tags build() { + return new Tags(type, tags, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Segments.Builder.class) + public static final class Segments { + private final Optional type; + + private final Optional> segments; + + private final Map additionalProperties; + + private Segments( + Optional type, Optional> segments, Map additionalProperties) { + this.type = type; + this.segments = segments; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("segments") + public Optional> getSegments() { + return segments; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Segments && equalTo((Segments) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Segments other) { + return type.equals(other.type) && segments.equals(other.segments); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.segments); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional> segments = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Segments other) { + type(other.getType()); + segments(other.getSegments()); + return this; + } + + /** + *

The type of the object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "segments", nulls = Nulls.SKIP) + public Builder segments(Optional> segments) { + this.segments = segments; + return this; + } + + public Builder segments(List segments) { + this.segments = Optional.ofNullable(segments); + return this; + } + + public Segments build() { + return new Segments(type, segments, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/AsyncContactsClient.java b/src/main/java/com/intercom/api/resources/unstable/contacts/AsyncContactsClient.java new file mode 100644 index 0000000..bdfa190 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/AsyncContactsClient.java @@ -0,0 +1,482 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.contacts.requests.ArchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.BlockContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.DeleteContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListCompaniesForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSegmentsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSubscriptionsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListTagsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactByExternalIdRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UnarchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UpdateContactRequest; +import com.intercom.api.resources.unstable.contacts.types.CreateContactResponse; +import com.intercom.api.resources.unstable.contacts.types.MergeContactResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactByExternalIdResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactResponse; +import com.intercom.api.resources.unstable.contacts.types.UpdateContactResponse; +import com.intercom.api.resources.unstable.types.ContactArchived; +import com.intercom.api.resources.unstable.types.ContactAttachedCompanies; +import com.intercom.api.resources.unstable.types.ContactBlocked; +import com.intercom.api.resources.unstable.types.ContactDeleted; +import com.intercom.api.resources.unstable.types.ContactList; +import com.intercom.api.resources.unstable.types.ContactSegments; +import com.intercom.api.resources.unstable.types.ContactUnarchived; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; +import com.intercom.api.resources.unstable.types.TagList; +import java.util.concurrent.CompletableFuture; + +public class AsyncContactsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawContactsClient rawClient; + + public AsyncContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawContactsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public CompletableFuture listCompaniesForAContact( + ListCompaniesForAContactRequest request) { + return this.rawClient.listCompaniesForAContact(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public CompletableFuture listCompaniesForAContact( + ListCompaniesForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient.listCompaniesForAContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public CompletableFuture listSegmentsForAContact(ListSegmentsForAContactRequest request) { + return this.rawClient.listSegmentsForAContact(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public CompletableFuture listSegmentsForAContact( + ListSegmentsForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient.listSegmentsForAContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public CompletableFuture listSubscriptionsForAContact( + ListSubscriptionsForAContactRequest request) { + return this.rawClient.listSubscriptionsForAContact(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public CompletableFuture listSubscriptionsForAContact( + ListSubscriptionsForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient + .listSubscriptionsForAContact(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public CompletableFuture listTagsForAContact(ListTagsForAContactRequest request) { + return this.rawClient.listTagsForAContact(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public CompletableFuture listTagsForAContact( + ListTagsForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient.listTagsForAContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single contact. + */ + public CompletableFuture showContact(ShowContactRequest request) { + return this.rawClient.showContact(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single contact. + */ + public CompletableFuture showContact( + ShowContactRequest request, RequestOptions requestOptions) { + return this.rawClient.showContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture updateContact(UpdateContactRequest request) { + return this.rawClient.updateContact(request).thenApply(response -> response.body()); + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture updateContact( + UpdateContactRequest request, RequestOptions requestOptions) { + return this.rawClient.updateContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single contact. + */ + public CompletableFuture deleteContact(DeleteContactRequest request) { + return this.rawClient.deleteContact(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single contact. + */ + public CompletableFuture deleteContact( + DeleteContactRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture mergeContact() { + return this.rawClient.mergeContact().thenApply(response -> response.body()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture mergeContact(MergeContactsRequest request) { + return this.rawClient.mergeContact(request).thenApply(response -> response.body()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture mergeContact( + MergeContactsRequest request, RequestOptions requestOptions) { + return this.rawClient.mergeContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture searchContacts(SearchRequest request) { + return this.rawClient.searchContacts(request).thenApply(response -> response.body()); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture searchContacts(SearchRequest request, RequestOptions requestOptions) { + return this.rawClient.searchContacts(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public CompletableFuture listContacts() { + return this.rawClient.listContacts().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public CompletableFuture listContacts(RequestOptions requestOptions) { + return this.rawClient.listContacts(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public CompletableFuture createContact(Object request) { + return this.rawClient.createContact(request).thenApply(response -> response.body()); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public CompletableFuture createContact(Object request, RequestOptions requestOptions) { + return this.rawClient.createContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture showContactByExternalId( + ShowContactByExternalIdRequest request) { + return this.rawClient.showContactByExternalId(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient.showContactByExternalId(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can archive a single contact. + */ + public CompletableFuture archiveContact(ArchiveContactRequest request) { + return this.rawClient.archiveContact(request).thenApply(response -> response.body()); + } + + /** + * You can archive a single contact. + */ + public CompletableFuture archiveContact( + ArchiveContactRequest request, RequestOptions requestOptions) { + return this.rawClient.archiveContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can unarchive a single contact. + */ + public CompletableFuture unarchiveContact(UnarchiveContactRequest request) { + return this.rawClient.unarchiveContact(request).thenApply(response -> response.body()); + } + + /** + * You can unarchive a single contact. + */ + public CompletableFuture unarchiveContact( + UnarchiveContactRequest request, RequestOptions requestOptions) { + return this.rawClient.unarchiveContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture blockContact(BlockContactRequest request) { + return this.rawClient.blockContact(request).thenApply(response -> response.body()); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture blockContact(BlockContactRequest request, RequestOptions requestOptions) { + return this.rawClient.blockContact(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/AsyncRawContactsClient.java b/src/main/java/com/intercom/api/resources/unstable/contacts/AsyncRawContactsClient.java new file mode 100644 index 0000000..dd84cc5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/AsyncRawContactsClient.java @@ -0,0 +1,1323 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.contacts.requests.ArchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.BlockContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.DeleteContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListCompaniesForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSegmentsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSubscriptionsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListTagsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactByExternalIdRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UnarchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UpdateContactRequest; +import com.intercom.api.resources.unstable.contacts.types.CreateContactResponse; +import com.intercom.api.resources.unstable.contacts.types.MergeContactResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactByExternalIdResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactResponse; +import com.intercom.api.resources.unstable.contacts.types.UpdateContactResponse; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.ContactArchived; +import com.intercom.api.resources.unstable.types.ContactAttachedCompanies; +import com.intercom.api.resources.unstable.types.ContactBlocked; +import com.intercom.api.resources.unstable.types.ContactDeleted; +import com.intercom.api.resources.unstable.types.ContactList; +import com.intercom.api.resources.unstable.types.ContactSegments; +import com.intercom.api.resources.unstable.types.ContactUnarchived; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; +import com.intercom.api.resources.unstable.types.TagList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawContactsClient { + protected final ClientOptions clientOptions; + + public AsyncRawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public CompletableFuture> listCompaniesForAContact( + ListCompaniesForAContactRequest request) { + return listCompaniesForAContact(request, null); + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public CompletableFuture> listCompaniesForAContact( + ListCompaniesForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("companies") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactAttachedCompanies.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public CompletableFuture> listSegmentsForAContact( + ListSegmentsForAContactRequest request) { + return listSegmentsForAContact(request, null); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public CompletableFuture> listSegmentsForAContact( + ListSegmentsForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("segments") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactSegments.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public CompletableFuture> listSubscriptionsForAContact( + ListSubscriptionsForAContactRequest request) { + return listSubscriptionsForAContact(request, null); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public CompletableFuture> listSubscriptionsForAContact( + ListSubscriptionsForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), SubscriptionTypeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public CompletableFuture> listTagsForAContact(ListTagsForAContactRequest request) { + return listTagsForAContact(request, null); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public CompletableFuture> listTagsForAContact( + ListTagsForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), TagList.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single contact. + */ + public CompletableFuture> showContact(ShowContactRequest request) { + return showContact(request, null); + } + + /** + * You can fetch the details of a single contact. + */ + public CompletableFuture> showContact( + ShowContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ShowContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture> updateContact(UpdateContactRequest request) { + return updateContact(request, null); + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture> updateContact( + UpdateContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), UpdateContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a single contact. + */ + public CompletableFuture> deleteContact(DeleteContactRequest request) { + return deleteContact(request, null); + } + + /** + * You can delete a single contact. + */ + public CompletableFuture> deleteContact( + DeleteContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactDeleted.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture> mergeContact() { + return mergeContact(MergeContactsRequest.builder().build()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture> mergeContact(MergeContactsRequest request) { + return mergeContact(request, null); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture> mergeContact( + MergeContactsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/merge") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), MergeContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> searchContacts(SearchRequest request) { + return searchContacts(request, null); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> searchContacts( + SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public CompletableFuture> listContacts() { + return listContacts(null); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public CompletableFuture> listContacts(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a new contact (ie. user or lead). + */ + public CompletableFuture> createContact(Object request) { + return createContact(request, null); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public CompletableFuture> createContact( + Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CreateContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture> showContactByExternalId( + ShowContactByExternalIdRequest request) { + return showContactByExternalId(request, null); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public CompletableFuture> showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/find_by_external_id") + .addPathSegment(request.getExternalId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ShowContactByExternalIdResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can archive a single contact. + */ + public CompletableFuture> archiveContact(ArchiveContactRequest request) { + return archiveContact(request, null); + } + + /** + * You can archive a single contact. + */ + public CompletableFuture> archiveContact( + ArchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("archive") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactArchived.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can unarchive a single contact. + */ + public CompletableFuture> unarchiveContact( + UnarchiveContactRequest request) { + return unarchiveContact(request, null); + } + + /** + * You can unarchive a single contact. + */ + public CompletableFuture> unarchiveContact( + UnarchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("unarchive") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactUnarchived.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture> blockContact(BlockContactRequest request) { + return blockContact(request, null); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public CompletableFuture> blockContact( + BlockContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("block") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ContactBlocked.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/ContactsClient.java b/src/main/java/com/intercom/api/resources/unstable/contacts/ContactsClient.java new file mode 100644 index 0000000..1b308ff --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/ContactsClient.java @@ -0,0 +1,471 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.contacts.requests.ArchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.BlockContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.DeleteContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListCompaniesForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSegmentsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSubscriptionsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListTagsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactByExternalIdRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UnarchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UpdateContactRequest; +import com.intercom.api.resources.unstable.contacts.types.CreateContactResponse; +import com.intercom.api.resources.unstable.contacts.types.MergeContactResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactByExternalIdResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactResponse; +import com.intercom.api.resources.unstable.contacts.types.UpdateContactResponse; +import com.intercom.api.resources.unstable.types.ContactArchived; +import com.intercom.api.resources.unstable.types.ContactAttachedCompanies; +import com.intercom.api.resources.unstable.types.ContactBlocked; +import com.intercom.api.resources.unstable.types.ContactDeleted; +import com.intercom.api.resources.unstable.types.ContactList; +import com.intercom.api.resources.unstable.types.ContactSegments; +import com.intercom.api.resources.unstable.types.ContactUnarchived; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; +import com.intercom.api.resources.unstable.types.TagList; + +public class ContactsClient { + protected final ClientOptions clientOptions; + + private final RawContactsClient rawClient; + + public ContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawContactsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public ContactAttachedCompanies listCompaniesForAContact(ListCompaniesForAContactRequest request) { + return this.rawClient.listCompaniesForAContact(request).body(); + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public ContactAttachedCompanies listCompaniesForAContact( + ListCompaniesForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient.listCompaniesForAContact(request, requestOptions).body(); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public ContactSegments listSegmentsForAContact(ListSegmentsForAContactRequest request) { + return this.rawClient.listSegmentsForAContact(request).body(); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public ContactSegments listSegmentsForAContact( + ListSegmentsForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient.listSegmentsForAContact(request, requestOptions).body(); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public SubscriptionTypeList listSubscriptionsForAContact(ListSubscriptionsForAContactRequest request) { + return this.rawClient.listSubscriptionsForAContact(request).body(); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public SubscriptionTypeList listSubscriptionsForAContact( + ListSubscriptionsForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient + .listSubscriptionsForAContact(request, requestOptions) + .body(); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public TagList listTagsForAContact(ListTagsForAContactRequest request) { + return this.rawClient.listTagsForAContact(request).body(); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public TagList listTagsForAContact(ListTagsForAContactRequest request, RequestOptions requestOptions) { + return this.rawClient.listTagsForAContact(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single contact. + */ + public ShowContactResponse showContact(ShowContactRequest request) { + return this.rawClient.showContact(request).body(); + } + + /** + * You can fetch the details of a single contact. + */ + public ShowContactResponse showContact(ShowContactRequest request, RequestOptions requestOptions) { + return this.rawClient.showContact(request, requestOptions).body(); + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public UpdateContactResponse updateContact(UpdateContactRequest request) { + return this.rawClient.updateContact(request).body(); + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public UpdateContactResponse updateContact(UpdateContactRequest request, RequestOptions requestOptions) { + return this.rawClient.updateContact(request, requestOptions).body(); + } + + /** + * You can delete a single contact. + */ + public ContactDeleted deleteContact(DeleteContactRequest request) { + return this.rawClient.deleteContact(request).body(); + } + + /** + * You can delete a single contact. + */ + public ContactDeleted deleteContact(DeleteContactRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteContact(request, requestOptions).body(); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public MergeContactResponse mergeContact() { + return this.rawClient.mergeContact().body(); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public MergeContactResponse mergeContact(MergeContactsRequest request) { + return this.rawClient.mergeContact(request).body(); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public MergeContactResponse mergeContact(MergeContactsRequest request, RequestOptions requestOptions) { + return this.rawClient.mergeContact(request, requestOptions).body(); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public ContactList searchContacts(SearchRequest request) { + return this.rawClient.searchContacts(request).body(); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public ContactList searchContacts(SearchRequest request, RequestOptions requestOptions) { + return this.rawClient.searchContacts(request, requestOptions).body(); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public ContactList listContacts() { + return this.rawClient.listContacts().body(); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public ContactList listContacts(RequestOptions requestOptions) { + return this.rawClient.listContacts(requestOptions).body(); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public CreateContactResponse createContact(Object request) { + return this.rawClient.createContact(request).body(); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public CreateContactResponse createContact(Object request, RequestOptions requestOptions) { + return this.rawClient.createContact(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public ShowContactByExternalIdResponse showContactByExternalId(ShowContactByExternalIdRequest request) { + return this.rawClient.showContactByExternalId(request).body(); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public ShowContactByExternalIdResponse showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient.showContactByExternalId(request, requestOptions).body(); + } + + /** + * You can archive a single contact. + */ + public ContactArchived archiveContact(ArchiveContactRequest request) { + return this.rawClient.archiveContact(request).body(); + } + + /** + * You can archive a single contact. + */ + public ContactArchived archiveContact(ArchiveContactRequest request, RequestOptions requestOptions) { + return this.rawClient.archiveContact(request, requestOptions).body(); + } + + /** + * You can unarchive a single contact. + */ + public ContactUnarchived unarchiveContact(UnarchiveContactRequest request) { + return this.rawClient.unarchiveContact(request).body(); + } + + /** + * You can unarchive a single contact. + */ + public ContactUnarchived unarchiveContact(UnarchiveContactRequest request, RequestOptions requestOptions) { + return this.rawClient.unarchiveContact(request, requestOptions).body(); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public ContactBlocked blockContact(BlockContactRequest request) { + return this.rawClient.blockContact(request).body(); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public ContactBlocked blockContact(BlockContactRequest request, RequestOptions requestOptions) { + return this.rawClient.blockContact(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/RawContactsClient.java b/src/main/java/com/intercom/api/resources/unstable/contacts/RawContactsClient.java new file mode 100644 index 0000000..616a959 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/RawContactsClient.java @@ -0,0 +1,1088 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.contacts.requests.ArchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.BlockContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.DeleteContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListCompaniesForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSegmentsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListSubscriptionsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.ListTagsForAContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactByExternalIdRequest; +import com.intercom.api.resources.unstable.contacts.requests.ShowContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UnarchiveContactRequest; +import com.intercom.api.resources.unstable.contacts.requests.UpdateContactRequest; +import com.intercom.api.resources.unstable.contacts.types.CreateContactResponse; +import com.intercom.api.resources.unstable.contacts.types.MergeContactResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactByExternalIdResponse; +import com.intercom.api.resources.unstable.contacts.types.ShowContactResponse; +import com.intercom.api.resources.unstable.contacts.types.UpdateContactResponse; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.ContactArchived; +import com.intercom.api.resources.unstable.types.ContactAttachedCompanies; +import com.intercom.api.resources.unstable.types.ContactBlocked; +import com.intercom.api.resources.unstable.types.ContactDeleted; +import com.intercom.api.resources.unstable.types.ContactList; +import com.intercom.api.resources.unstable.types.ContactSegments; +import com.intercom.api.resources.unstable.types.ContactUnarchived; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; +import com.intercom.api.resources.unstable.types.TagList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawContactsClient { + protected final ClientOptions clientOptions; + + public RawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public IntercomHttpResponse listCompaniesForAContact( + ListCompaniesForAContactRequest request) { + return listCompaniesForAContact(request, null); + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + public IntercomHttpResponse listCompaniesForAContact( + ListCompaniesForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("companies") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactAttachedCompanies.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public IntercomHttpResponse listSegmentsForAContact(ListSegmentsForAContactRequest request) { + return listSegmentsForAContact(request, null); + } + + /** + * You can fetch a list of segments that are associated to a contact. + */ + public IntercomHttpResponse listSegmentsForAContact( + ListSegmentsForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("segments") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactSegments.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public IntercomHttpResponse listSubscriptionsForAContact( + ListSubscriptionsForAContactRequest request) { + return listSubscriptionsForAContact(request, null); + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + *

The data property will show a combined list of:

+ *

1.Opt-out subscription types that the user has opted-out from. + * 2.Opt-in subscription types that the user has opted-in to receiving.

+ */ + public IntercomHttpResponse listSubscriptionsForAContact( + ListSubscriptionsForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public IntercomHttpResponse listTagsForAContact(ListTagsForAContactRequest request) { + return listTagsForAContact(request, null); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + public IntercomHttpResponse listTagsForAContact( + ListTagsForAContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single contact. + */ + public IntercomHttpResponse showContact(ShowContactRequest request) { + return showContact(request, null); + } + + /** + * You can fetch the details of a single contact. + */ + public IntercomHttpResponse showContact( + ShowContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ShowContactResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public IntercomHttpResponse updateContact(UpdateContactRequest request) { + return updateContact(request, null); + } + + /** + * You can update an existing contact (ie. user or lead). + *

{% admonition type="info" %} + * This endpoint handles both contact updates and custom object associations.

+ *

See update a contact with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public IntercomHttpResponse updateContact( + UpdateContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UpdateContactResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single contact. + */ + public IntercomHttpResponse deleteContact(DeleteContactRequest request) { + return deleteContact(request, null); + } + + /** + * You can delete a single contact. + */ + public IntercomHttpResponse deleteContact( + DeleteContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactDeleted.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public IntercomHttpResponse mergeContact() { + return mergeContact(MergeContactsRequest.builder().build()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public IntercomHttpResponse mergeContact(MergeContactsRequest request) { + return mergeContact(request, null); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public IntercomHttpResponse mergeContact( + MergeContactsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/merge") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MergeContactResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public IntercomHttpResponse searchContacts(SearchRequest request) { + return searchContacts(request, null); + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + *

To search for contacts, you need to send a POST request to https://api.intercom.io/contacts/search.

+ *

This will accept a query object in the body which will define your filters in order to search for contacts.

+ *

{% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Contact Creation Delay

+ *

If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Searching for Timestamp Fields

+ *

All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.

+ *

Accepted Fields

+ *

Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar").

+ *

| Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String<br>Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String |

+ *

Accepted Operators

+ *

{% admonition type="warning" name="Searching based on created_at" %} + * You cannot use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In<br>Shortcut for OR queries<br>Values must be in Array | + * | NIN | All | Not In<br>Shortcut for OR ! queries<br>Values must be in Array | + * | > | Integer<br>Date (UNIX Timestamp) | Greater than | + * | < | Integer<br>Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public IntercomHttpResponse searchContacts(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public IntercomHttpResponse listContacts() { + return listContacts(null); + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 50 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %} + */ + public IntercomHttpResponse listContacts(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new contact (ie. user or lead). + */ + public IntercomHttpResponse createContact(Object request) { + return createContact(request, null); + } + + /** + * You can create a new contact (ie. user or lead). + */ + public IntercomHttpResponse createContact(Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateContactResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public IntercomHttpResponse showContactByExternalId( + ShowContactByExternalIdRequest request) { + return showContactByExternalId(request, null); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + */ + public IntercomHttpResponse showContactByExternalId( + ShowContactByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts/find_by_external_id") + .addPathSegment(request.getExternalId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ShowContactByExternalIdResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can archive a single contact. + */ + public IntercomHttpResponse archiveContact(ArchiveContactRequest request) { + return archiveContact(request, null); + } + + /** + * You can archive a single contact. + */ + public IntercomHttpResponse archiveContact( + ArchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("archive") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactArchived.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can unarchive a single contact. + */ + public IntercomHttpResponse unarchiveContact(UnarchiveContactRequest request) { + return unarchiveContact(request, null); + } + + /** + * You can unarchive a single contact. + */ + public IntercomHttpResponse unarchiveContact( + UnarchiveContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("unarchive") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactUnarchived.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public IntercomHttpResponse blockContact(BlockContactRequest request) { + return blockContact(request, null); + } + + /** + * Block a single contact.<br>Note: conversations of the contact will also be archived during the process.<br>More details in FAQ How do I block Inbox spam? + */ + public IntercomHttpResponse blockContact( + BlockContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getId()) + .addPathSegments("block") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactBlocked.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ArchiveContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ArchiveContactRequest.java new file mode 100644 index 0000000..1275223 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ArchiveContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ArchiveContactRequest.Builder.class) +public final class ArchiveContactRequest { + private final String id; + + private final Map additionalProperties; + + private ArchiveContactRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ArchiveContactRequest && equalTo((ArchiveContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ArchiveContactRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * id + */ + _FinalStage id(@NotNull String id); + + Builder from(ArchiveContactRequest other); + } + + public interface _FinalStage { + ArchiveContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ArchiveContactRequest other) { + id(other.getId()); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public ArchiveContactRequest build() { + return new ArchiveContactRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/BlockContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/BlockContactRequest.java new file mode 100644 index 0000000..bdb0b1b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/BlockContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = BlockContactRequest.Builder.class) +public final class BlockContactRequest { + private final String id; + + private final Map additionalProperties; + + private BlockContactRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BlockContactRequest && equalTo((BlockContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(BlockContactRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * id + */ + _FinalStage id(@NotNull String id); + + Builder from(BlockContactRequest other); + } + + public interface _FinalStage { + BlockContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(BlockContactRequest other) { + id(other.getId()); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public BlockContactRequest build() { + return new BlockContactRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/DeleteContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/DeleteContactRequest.java new file mode 100644 index 0000000..0ce5a25 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/DeleteContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteContactRequest.Builder.class) +public final class DeleteContactRequest { + private final String id; + + private final Map additionalProperties; + + private DeleteContactRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteContactRequest && equalTo((DeleteContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteContactRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * id + */ + _FinalStage id(@NotNull String id); + + Builder from(DeleteContactRequest other); + } + + public interface _FinalStage { + DeleteContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteContactRequest other) { + id(other.getId()); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DeleteContactRequest build() { + return new DeleteContactRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListCompaniesForAContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListCompaniesForAContactRequest.java new file mode 100644 index 0000000..e699740 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListCompaniesForAContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCompaniesForAContactRequest.Builder.class) +public final class ListCompaniesForAContactRequest { + private final String id; + + private final Map additionalProperties; + + private ListCompaniesForAContactRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCompaniesForAContactRequest && equalTo((ListCompaniesForAContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCompaniesForAContactRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(ListCompaniesForAContactRequest other); + } + + public interface _FinalStage { + ListCompaniesForAContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListCompaniesForAContactRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public ListCompaniesForAContactRequest build() { + return new ListCompaniesForAContactRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListSegmentsForAContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListSegmentsForAContactRequest.java new file mode 100644 index 0000000..79cbd2d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListSegmentsForAContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListSegmentsForAContactRequest.Builder.class) +public final class ListSegmentsForAContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private ListSegmentsForAContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSegmentsForAContactRequest && equalTo((ListSegmentsForAContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSegmentsForAContactRequest other) { + return contactId.equals(other.contactId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListSegmentsForAContactRequest other); + } + + public interface _FinalStage { + ListSegmentsForAContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, _FinalStage { + private String contactId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListSegmentsForAContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + @java.lang.Override + public ListSegmentsForAContactRequest build() { + return new ListSegmentsForAContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListSubscriptionsForAContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListSubscriptionsForAContactRequest.java new file mode 100644 index 0000000..3923621 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListSubscriptionsForAContactRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListSubscriptionsForAContactRequest.Builder.class) +public final class ListSubscriptionsForAContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private ListSubscriptionsForAContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSubscriptionsForAContactRequest + && equalTo((ListSubscriptionsForAContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSubscriptionsForAContactRequest other) { + return contactId.equals(other.contactId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListSubscriptionsForAContactRequest other); + } + + public interface _FinalStage { + ListSubscriptionsForAContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, _FinalStage { + private String contactId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListSubscriptionsForAContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + @java.lang.Override + public ListSubscriptionsForAContactRequest build() { + return new ListSubscriptionsForAContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListTagsForAContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListTagsForAContactRequest.java new file mode 100644 index 0000000..6525a97 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ListTagsForAContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListTagsForAContactRequest.Builder.class) +public final class ListTagsForAContactRequest { + private final String contactId; + + private final Map additionalProperties; + + private ListTagsForAContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListTagsForAContactRequest && equalTo((ListTagsForAContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListTagsForAContactRequest other) { + return contactId.equals(other.contactId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + _FinalStage contactId(@NotNull String contactId); + + Builder from(ListTagsForAContactRequest other); + } + + public interface _FinalStage { + ListTagsForAContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, _FinalStage { + private String contactId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListTagsForAContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public _FinalStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + @java.lang.Override + public ListTagsForAContactRequest build() { + return new ListTagsForAContactRequest(contactId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/MergeContactsRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/MergeContactsRequest.java new file mode 100644 index 0000000..16fd6e9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/MergeContactsRequest.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MergeContactsRequest.Builder.class) +public final class MergeContactsRequest { + private final Optional from; + + private final Optional into; + + private final Map additionalProperties; + + private MergeContactsRequest( + Optional from, Optional into, Map additionalProperties) { + this.from = from; + this.into = into; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact to merge away from. Must be a lead. + */ + @JsonProperty("from") + public Optional getFrom() { + return from; + } + + /** + * @return The unique identifier for the contact to merge into. Must be a user. + */ + @JsonProperty("into") + public Optional getInto() { + return into; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MergeContactsRequest && equalTo((MergeContactsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MergeContactsRequest other) { + return from.equals(other.from) && into.equals(other.into); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.from, this.into); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional from = Optional.empty(); + + private Optional into = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(MergeContactsRequest other) { + from(other.getFrom()); + into(other.getInto()); + return this; + } + + /** + *

The unique identifier for the contact to merge away from. Must be a lead.

+ */ + @JsonSetter(value = "from", nulls = Nulls.SKIP) + public Builder from(Optional from) { + this.from = from; + return this; + } + + public Builder from(String from) { + this.from = Optional.ofNullable(from); + return this; + } + + /** + *

The unique identifier for the contact to merge into. Must be a user.

+ */ + @JsonSetter(value = "into", nulls = Nulls.SKIP) + public Builder into(Optional into) { + this.into = into; + return this; + } + + public Builder into(String into) { + this.into = Optional.ofNullable(into); + return this; + } + + public MergeContactsRequest build() { + return new MergeContactsRequest(from, into, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ShowContactByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ShowContactByExternalIdRequest.java new file mode 100644 index 0000000..a0d5979 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ShowContactByExternalIdRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowContactByExternalIdRequest.Builder.class) +public final class ShowContactByExternalIdRequest { + private final String externalId; + + private final Map additionalProperties; + + private ShowContactByExternalIdRequest(String externalId, Map additionalProperties) { + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The external ID of the user that you want to retrieve + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowContactByExternalIdRequest && equalTo((ShowContactByExternalIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowContactByExternalIdRequest other) { + return externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ExternalIdStage builder() { + return new Builder(); + } + + public interface ExternalIdStage { + /** + * The external ID of the user that you want to retrieve + */ + _FinalStage externalId(@NotNull String externalId); + + Builder from(ShowContactByExternalIdRequest other); + } + + public interface _FinalStage { + ShowContactByExternalIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ExternalIdStage, _FinalStage { + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ShowContactByExternalIdRequest other) { + externalId(other.getExternalId()); + return this; + } + + /** + * The external ID of the user that you want to retrieve

The external ID of the user that you want to retrieve

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public ShowContactByExternalIdRequest build() { + return new ShowContactByExternalIdRequest(externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ShowContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ShowContactRequest.java new file mode 100644 index 0000000..0b1dc34 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/ShowContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowContactRequest.Builder.class) +public final class ShowContactRequest { + private final String id; + + private final Map additionalProperties; + + private ShowContactRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowContactRequest && equalTo((ShowContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowContactRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * id + */ + _FinalStage id(@NotNull String id); + + Builder from(ShowContactRequest other); + } + + public interface _FinalStage { + ShowContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ShowContactRequest other) { + id(other.getId()); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public ShowContactRequest build() { + return new ShowContactRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/UnarchiveContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/UnarchiveContactRequest.java new file mode 100644 index 0000000..06dc966 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/UnarchiveContactRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UnarchiveContactRequest.Builder.class) +public final class UnarchiveContactRequest { + private final String id; + + private final Map additionalProperties; + + private UnarchiveContactRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UnarchiveContactRequest && equalTo((UnarchiveContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UnarchiveContactRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * id + */ + _FinalStage id(@NotNull String id); + + Builder from(UnarchiveContactRequest other); + } + + public interface _FinalStage { + UnarchiveContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UnarchiveContactRequest other) { + id(other.getId()); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public UnarchiveContactRequest build() { + return new UnarchiveContactRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/requests/UpdateContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/UpdateContactRequest.java new file mode 100644 index 0000000..4837503 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/requests/UpdateContactRequest.java @@ -0,0 +1,614 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateContactRequest.Builder.class) +public final class UpdateContactRequest { + private final String id; + + private final Optional role; + + private final Optional externalId; + + private final Optional email; + + private final Optional phone; + + private final Optional name; + + private final Optional avatar; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional ownerId; + + private final Optional unsubscribedFromEmails; + + private final Optional> customAttributes; + + private final Map additionalProperties; + + private UpdateContactRequest( + String id, + Optional role, + Optional externalId, + Optional email, + Optional phone, + Optional name, + Optional avatar, + Optional signedUpAt, + Optional lastSeenAt, + Optional ownerId, + Optional unsubscribedFromEmails, + Optional> customAttributes, + Map additionalProperties) { + this.id = id; + this.role = role; + this.externalId = externalId; + this.email = email; + this.phone = phone; + this.name = name; + this.avatar = avatar; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.ownerId = ownerId; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return A unique identifier for the contact which is given to Intercom + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The contacts email + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contacts phone + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts name + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return An image URL containing the avatar of a contact + */ + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + /** + * @return The time specified for when a contact signed up + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact is unsubscribed from emails + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return The custom attributes which are set for the contact + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateContactRequest && equalTo((UpdateContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateContactRequest other) { + return id.equals(other.id) + && role.equals(other.role) + && externalId.equals(other.externalId) + && email.equals(other.email) + && phone.equals(other.phone) + && name.equals(other.name) + && avatar.equals(other.avatar) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && ownerId.equals(other.ownerId) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.role, + this.externalId, + this.email, + this.phone, + this.name, + this.avatar, + this.signedUpAt, + this.lastSeenAt, + this.ownerId, + this.unsubscribedFromEmails, + this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * id + */ + _FinalStage id(@NotNull String id); + + Builder from(UpdateContactRequest other); + } + + public interface _FinalStage { + UpdateContactRequest build(); + + /** + *

The role of the contact.

+ */ + _FinalStage role(Optional role); + + _FinalStage role(String role); + + /** + *

A unique identifier for the contact which is given to Intercom

+ */ + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + + /** + *

The contacts email

+ */ + _FinalStage email(Optional email); + + _FinalStage email(String email); + + /** + *

The contacts phone

+ */ + _FinalStage phone(Optional phone); + + _FinalStage phone(String phone); + + /** + *

The contacts name

+ */ + _FinalStage name(Optional name); + + _FinalStage name(String name); + + /** + *

An image URL containing the avatar of a contact

+ */ + _FinalStage avatar(Optional avatar); + + _FinalStage avatar(String avatar); + + /** + *

The time specified for when a contact signed up

+ */ + _FinalStage signedUpAt(Optional signedUpAt); + + _FinalStage signedUpAt(Integer signedUpAt); + + /** + *

The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually)

+ */ + _FinalStage lastSeenAt(Optional lastSeenAt); + + _FinalStage lastSeenAt(Integer lastSeenAt); + + /** + *

The id of an admin that has been assigned account ownership of the contact

+ */ + _FinalStage ownerId(Optional ownerId); + + _FinalStage ownerId(Integer ownerId); + + /** + *

Whether the contact is unsubscribed from emails

+ */ + _FinalStage unsubscribedFromEmails(Optional unsubscribedFromEmails); + + _FinalStage unsubscribedFromEmails(Boolean unsubscribedFromEmails); + + /** + *

The custom attributes which are set for the contact

+ */ + _FinalStage customAttributes(Optional> customAttributes); + + _FinalStage customAttributes(Map customAttributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional> customAttributes = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional role = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateContactRequest other) { + id(other.getId()); + role(other.getRole()); + externalId(other.getExternalId()); + email(other.getEmail()); + phone(other.getPhone()); + name(other.getName()); + avatar(other.getAvatar()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + ownerId(other.getOwnerId()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + *

The custom attributes which are set for the contact

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

The custom attributes which are set for the contact

+ */ + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + /** + *

Whether the contact is unsubscribed from emails

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails

+ */ + @java.lang.Override + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public _FinalStage unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact

+ */ + @java.lang.Override + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public _FinalStage ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + /** + *

The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually)

+ */ + @java.lang.Override + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public _FinalStage lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + /** + *

The time specified for when a contact signed up

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

The time specified for when a contact signed up

+ */ + @java.lang.Override + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public _FinalStage signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + /** + *

An image URL containing the avatar of a contact

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + /** + *

An image URL containing the avatar of a contact

+ */ + @java.lang.Override + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public _FinalStage avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + /** + *

The contacts name

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The contacts name

+ */ + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + /** + *

The contacts phone

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts phone

+ */ + @java.lang.Override + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public _FinalStage phone(Optional phone) { + this.phone = phone; + return this; + } + + /** + *

The contacts email

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contacts email

+ */ + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + return this; + } + + /** + *

A unique identifier for the contact which is given to Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

A unique identifier for the contact which is given to Intercom

+ */ + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + /** + *

The role of the contact.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The role of the contact.

+ */ + @java.lang.Override + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public _FinalStage role(Optional role) { + this.role = role; + return this; + } + + @java.lang.Override + public UpdateContactRequest build() { + return new UpdateContactRequest( + id, + role, + externalId, + email, + phone, + name, + avatar, + signedUpAt, + lastSeenAt, + ownerId, + unsubscribedFromEmails, + customAttributes, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/types/Contact.java b/src/main/java/com/intercom/api/resources/unstable/contacts/types/Contact.java new file mode 100644 index 0000000..ecb3eb4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/types/Contact.java @@ -0,0 +1,1626 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContactCompanies; +import com.intercom.api.resources.unstable.types.ContactLocation; +import com.intercom.api.resources.unstable.types.ContactNotes; +import com.intercom.api.resources.unstable.types.ContactSocialProfiles; +import com.intercom.api.resources.unstable.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Contact.Builder.class) +public final class Contact implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional formattedPhone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Map additionalProperties; + + private Contact( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional formattedPhone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.formattedPhone = formattedPhone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts phone number normalized to the E164 format + */ + @JsonProperty("formatted_phone") + public Optional getFormattedPhone() { + return formattedPhone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Contact && equalTo((Contact) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Contact other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && formattedPhone.equals(other.formattedPhone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.formattedPhone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional formattedPhone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Contact other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + formattedPhone(other.getFormattedPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts phone number normalized to the E164 format

+ */ + @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) + public Builder formattedPhone(Optional formattedPhone) { + this.formattedPhone = formattedPhone; + return this; + } + + public Builder formattedPhone(String formattedPhone) { + this.formattedPhone = Optional.ofNullable(formattedPhone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + public Contact build() { + return new Contact( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + formattedPhone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Avatar.Builder.class) + public static final class Avatar { + private final Optional type; + + private final Optional imageUrl; + + private final Map additionalProperties; + + private Avatar(Optional type, Optional imageUrl, Map additionalProperties) { + this.type = type; + this.imageUrl = imageUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("image_url") + public Optional getImageUrl() { + return imageUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Avatar && equalTo((Avatar) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Avatar other) { + return type.equals(other.type) && imageUrl.equals(other.imageUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.imageUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional imageUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Avatar other) { + type(other.getType()); + imageUrl(other.getImageUrl()); + return this; + } + + /** + *

The type of object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "image_url", nulls = Nulls.SKIP) + public Builder imageUrl(Optional imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public Builder imageUrl(String imageUrl) { + this.imageUrl = Optional.ofNullable(imageUrl); + return this; + } + + public Avatar build() { + return new Avatar(type, imageUrl, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/types/CreateContactResponse.java b/src/main/java/com/intercom/api/resources/unstable/contacts/types/CreateContactResponse.java new file mode 100644 index 0000000..32d35f7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/types/CreateContactResponse.java @@ -0,0 +1,1658 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContactCompanies; +import com.intercom.api.resources.unstable.types.ContactLocation; +import com.intercom.api.resources.unstable.types.ContactNotes; +import com.intercom.api.resources.unstable.types.ContactSocialProfiles; +import com.intercom.api.resources.unstable.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateContactResponse.Builder.class) +public final class CreateContactResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional formattedPhone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private CreateContactResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional formattedPhone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.formattedPhone = formattedPhone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts phone number normalized to the E164 format + */ + @JsonProperty("formatted_phone") + public Optional getFormattedPhone() { + return formattedPhone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateContactResponse && equalTo((CreateContactResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateContactResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && formattedPhone.equals(other.formattedPhone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.formattedPhone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional formattedPhone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreateContactResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + formattedPhone(other.getFormattedPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts phone number normalized to the E164 format

+ */ + @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) + public Builder formattedPhone(Optional formattedPhone) { + this.formattedPhone = formattedPhone; + return this; + } + + public Builder formattedPhone(String formattedPhone) { + this.formattedPhone = Optional.ofNullable(formattedPhone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public CreateContactResponse build() { + return new CreateContactResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + formattedPhone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Avatar.Builder.class) + public static final class Avatar { + private final Optional type; + + private final Optional imageUrl; + + private final Map additionalProperties; + + private Avatar(Optional type, Optional imageUrl, Map additionalProperties) { + this.type = type; + this.imageUrl = imageUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("image_url") + public Optional getImageUrl() { + return imageUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Avatar && equalTo((Avatar) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Avatar other) { + return type.equals(other.type) && imageUrl.equals(other.imageUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.imageUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional imageUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Avatar other) { + type(other.getType()); + imageUrl(other.getImageUrl()); + return this; + } + + /** + *

The type of object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "image_url", nulls = Nulls.SKIP) + public Builder imageUrl(Optional imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public Builder imageUrl(String imageUrl) { + this.imageUrl = Optional.ofNullable(imageUrl); + return this; + } + + public Avatar build() { + return new Avatar(type, imageUrl, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/types/IContact.java b/src/main/java/com/intercom/api/resources/unstable/contacts/types/IContact.java new file mode 100644 index 0000000..2fa10ab --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/types/IContact.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.types; + +import com.intercom.api.resources.unstable.types.ContactCompanies; +import com.intercom.api.resources.unstable.types.ContactLocation; +import com.intercom.api.resources.unstable.types.ContactNotes; +import com.intercom.api.resources.unstable.types.ContactSocialProfiles; +import com.intercom.api.resources.unstable.types.ContactTags; +import java.util.Map; +import java.util.Optional; + +public interface IContact { + Optional getType(); + + Optional getId(); + + Optional getExternalId(); + + Optional getWorkspaceId(); + + Optional getRole(); + + Optional getEmail(); + + Optional getEmailDomain(); + + Optional getPhone(); + + Optional getFormattedPhone(); + + Optional getName(); + + Optional getOwnerId(); + + Optional getHasHardBounced(); + + Optional getMarkedEmailAsSpam(); + + Optional getUnsubscribedFromEmails(); + + Optional getCreatedAt(); + + Optional getUpdatedAt(); + + Optional getSignedUpAt(); + + Optional getLastSeenAt(); + + Optional getLastRepliedAt(); + + Optional getLastContactedAt(); + + Optional getLastEmailOpenedAt(); + + Optional getLastEmailClickedAt(); + + Optional getLanguageOverride(); + + Optional getBrowser(); + + Optional getBrowserVersion(); + + Optional getBrowserLanguage(); + + Optional getOs(); + + Optional getAndroidAppName(); + + Optional getAndroidAppVersion(); + + Optional getAndroidDevice(); + + Optional getAndroidOsVersion(); + + Optional getAndroidSdkVersion(); + + Optional getAndroidLastSeenAt(); + + Optional getIosAppName(); + + Optional getIosAppVersion(); + + Optional getIosDevice(); + + Optional getIosOsVersion(); + + Optional getIosSdkVersion(); + + Optional getIosLastSeenAt(); + + Optional> getCustomAttributes(); + + Optional getTags(); + + Optional getNotes(); + + Optional getCompanies(); + + Optional getLocation(); + + Optional getSocialProfiles(); +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/types/MergeContactResponse.java b/src/main/java/com/intercom/api/resources/unstable/contacts/types/MergeContactResponse.java new file mode 100644 index 0000000..23177c0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/types/MergeContactResponse.java @@ -0,0 +1,1658 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContactCompanies; +import com.intercom.api.resources.unstable.types.ContactLocation; +import com.intercom.api.resources.unstable.types.ContactNotes; +import com.intercom.api.resources.unstable.types.ContactSocialProfiles; +import com.intercom.api.resources.unstable.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MergeContactResponse.Builder.class) +public final class MergeContactResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional formattedPhone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private MergeContactResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional formattedPhone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.formattedPhone = formattedPhone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts phone number normalized to the E164 format + */ + @JsonProperty("formatted_phone") + public Optional getFormattedPhone() { + return formattedPhone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MergeContactResponse && equalTo((MergeContactResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MergeContactResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && formattedPhone.equals(other.formattedPhone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.formattedPhone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional formattedPhone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(MergeContactResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + formattedPhone(other.getFormattedPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts phone number normalized to the E164 format

+ */ + @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) + public Builder formattedPhone(Optional formattedPhone) { + this.formattedPhone = formattedPhone; + return this; + } + + public Builder formattedPhone(String formattedPhone) { + this.formattedPhone = Optional.ofNullable(formattedPhone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public MergeContactResponse build() { + return new MergeContactResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + formattedPhone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Avatar.Builder.class) + public static final class Avatar { + private final Optional type; + + private final Optional imageUrl; + + private final Map additionalProperties; + + private Avatar(Optional type, Optional imageUrl, Map additionalProperties) { + this.type = type; + this.imageUrl = imageUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("image_url") + public Optional getImageUrl() { + return imageUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Avatar && equalTo((Avatar) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Avatar other) { + return type.equals(other.type) && imageUrl.equals(other.imageUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.imageUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional imageUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Avatar other) { + type(other.getType()); + imageUrl(other.getImageUrl()); + return this; + } + + /** + *

The type of object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "image_url", nulls = Nulls.SKIP) + public Builder imageUrl(Optional imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public Builder imageUrl(String imageUrl) { + this.imageUrl = Optional.ofNullable(imageUrl); + return this; + } + + public Avatar build() { + return new Avatar(type, imageUrl, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/types/ShowContactByExternalIdResponse.java b/src/main/java/com/intercom/api/resources/unstable/contacts/types/ShowContactByExternalIdResponse.java new file mode 100644 index 0000000..b3bcafe --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/types/ShowContactByExternalIdResponse.java @@ -0,0 +1,1658 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContactCompanies; +import com.intercom.api.resources.unstable.types.ContactLocation; +import com.intercom.api.resources.unstable.types.ContactNotes; +import com.intercom.api.resources.unstable.types.ContactSocialProfiles; +import com.intercom.api.resources.unstable.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowContactByExternalIdResponse.Builder.class) +public final class ShowContactByExternalIdResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional formattedPhone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private ShowContactByExternalIdResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional formattedPhone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.formattedPhone = formattedPhone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts phone number normalized to the E164 format + */ + @JsonProperty("formatted_phone") + public Optional getFormattedPhone() { + return formattedPhone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowContactByExternalIdResponse && equalTo((ShowContactByExternalIdResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowContactByExternalIdResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && formattedPhone.equals(other.formattedPhone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.formattedPhone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional formattedPhone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ShowContactByExternalIdResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + formattedPhone(other.getFormattedPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts phone number normalized to the E164 format

+ */ + @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) + public Builder formattedPhone(Optional formattedPhone) { + this.formattedPhone = formattedPhone; + return this; + } + + public Builder formattedPhone(String formattedPhone) { + this.formattedPhone = Optional.ofNullable(formattedPhone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public ShowContactByExternalIdResponse build() { + return new ShowContactByExternalIdResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + formattedPhone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Avatar.Builder.class) + public static final class Avatar { + private final Optional type; + + private final Optional imageUrl; + + private final Map additionalProperties; + + private Avatar(Optional type, Optional imageUrl, Map additionalProperties) { + this.type = type; + this.imageUrl = imageUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("image_url") + public Optional getImageUrl() { + return imageUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Avatar && equalTo((Avatar) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Avatar other) { + return type.equals(other.type) && imageUrl.equals(other.imageUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.imageUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional imageUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Avatar other) { + type(other.getType()); + imageUrl(other.getImageUrl()); + return this; + } + + /** + *

The type of object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "image_url", nulls = Nulls.SKIP) + public Builder imageUrl(Optional imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public Builder imageUrl(String imageUrl) { + this.imageUrl = Optional.ofNullable(imageUrl); + return this; + } + + public Avatar build() { + return new Avatar(type, imageUrl, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/types/ShowContactResponse.java b/src/main/java/com/intercom/api/resources/unstable/contacts/types/ShowContactResponse.java new file mode 100644 index 0000000..feb71de --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/types/ShowContactResponse.java @@ -0,0 +1,1658 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContactCompanies; +import com.intercom.api.resources.unstable.types.ContactLocation; +import com.intercom.api.resources.unstable.types.ContactNotes; +import com.intercom.api.resources.unstable.types.ContactSocialProfiles; +import com.intercom.api.resources.unstable.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ShowContactResponse.Builder.class) +public final class ShowContactResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional formattedPhone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private ShowContactResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional formattedPhone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.formattedPhone = formattedPhone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts phone number normalized to the E164 format + */ + @JsonProperty("formatted_phone") + public Optional getFormattedPhone() { + return formattedPhone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowContactResponse && equalTo((ShowContactResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowContactResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && formattedPhone.equals(other.formattedPhone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.formattedPhone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional formattedPhone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ShowContactResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + formattedPhone(other.getFormattedPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts phone number normalized to the E164 format

+ */ + @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) + public Builder formattedPhone(Optional formattedPhone) { + this.formattedPhone = formattedPhone; + return this; + } + + public Builder formattedPhone(String formattedPhone) { + this.formattedPhone = Optional.ofNullable(formattedPhone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public ShowContactResponse build() { + return new ShowContactResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + formattedPhone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Avatar.Builder.class) + public static final class Avatar { + private final Optional type; + + private final Optional imageUrl; + + private final Map additionalProperties; + + private Avatar(Optional type, Optional imageUrl, Map additionalProperties) { + this.type = type; + this.imageUrl = imageUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("image_url") + public Optional getImageUrl() { + return imageUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Avatar && equalTo((Avatar) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Avatar other) { + return type.equals(other.type) && imageUrl.equals(other.imageUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.imageUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional imageUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Avatar other) { + type(other.getType()); + imageUrl(other.getImageUrl()); + return this; + } + + /** + *

The type of object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "image_url", nulls = Nulls.SKIP) + public Builder imageUrl(Optional imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public Builder imageUrl(String imageUrl) { + this.imageUrl = Optional.ofNullable(imageUrl); + return this; + } + + public Avatar build() { + return new Avatar(type, imageUrl, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/contacts/types/UpdateContactResponse.java b/src/main/java/com/intercom/api/resources/unstable/contacts/types/UpdateContactResponse.java new file mode 100644 index 0000000..ce090c9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/contacts/types/UpdateContactResponse.java @@ -0,0 +1,1658 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.contacts.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContactCompanies; +import com.intercom.api.resources.unstable.types.ContactLocation; +import com.intercom.api.resources.unstable.types.ContactNotes; +import com.intercom.api.resources.unstable.types.ContactSocialProfiles; +import com.intercom.api.resources.unstable.types.ContactTags; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateContactResponse.Builder.class) +public final class UpdateContactResponse implements IContact { + private final Optional type; + + private final Optional id; + + private final Optional externalId; + + private final Optional workspaceId; + + private final Optional role; + + private final Optional email; + + private final Optional emailDomain; + + private final Optional phone; + + private final Optional formattedPhone; + + private final Optional name; + + private final Optional ownerId; + + private final Optional hasHardBounced; + + private final Optional markedEmailAsSpam; + + private final Optional unsubscribedFromEmails; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional signedUpAt; + + private final Optional lastSeenAt; + + private final Optional lastRepliedAt; + + private final Optional lastContactedAt; + + private final Optional lastEmailOpenedAt; + + private final Optional lastEmailClickedAt; + + private final Optional languageOverride; + + private final Optional browser; + + private final Optional browserVersion; + + private final Optional browserLanguage; + + private final Optional os; + + private final Optional androidAppName; + + private final Optional androidAppVersion; + + private final Optional androidDevice; + + private final Optional androidOsVersion; + + private final Optional androidSdkVersion; + + private final Optional androidLastSeenAt; + + private final Optional iosAppName; + + private final Optional iosAppVersion; + + private final Optional iosDevice; + + private final Optional iosOsVersion; + + private final Optional iosSdkVersion; + + private final Optional iosLastSeenAt; + + private final Optional> customAttributes; + + private final Optional avatar; + + private final Optional tags; + + private final Optional notes; + + private final Optional companies; + + private final Optional location; + + private final Optional socialProfiles; + + private final Optional enabledPushMessaging; + + private final Map additionalProperties; + + private UpdateContactResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + Optional formattedPhone, + Optional name, + Optional ownerId, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, + Optional signedUpAt, + Optional lastSeenAt, + Optional lastRepliedAt, + Optional lastContactedAt, + Optional lastEmailOpenedAt, + Optional lastEmailClickedAt, + Optional languageOverride, + Optional browser, + Optional browserVersion, + Optional browserLanguage, + Optional os, + Optional androidAppName, + Optional androidAppVersion, + Optional androidDevice, + Optional androidOsVersion, + Optional androidSdkVersion, + Optional androidLastSeenAt, + Optional iosAppName, + Optional iosAppVersion, + Optional iosDevice, + Optional iosOsVersion, + Optional iosSdkVersion, + Optional iosLastSeenAt, + Optional> customAttributes, + Optional avatar, + Optional tags, + Optional notes, + Optional companies, + Optional location, + Optional socialProfiles, + Optional enabledPushMessaging, + Map additionalProperties) { + this.type = type; + this.id = id; + this.externalId = externalId; + this.workspaceId = workspaceId; + this.role = role; + this.email = email; + this.emailDomain = emailDomain; + this.phone = phone; + this.formattedPhone = formattedPhone; + this.name = name; + this.ownerId = ownerId; + this.hasHardBounced = hasHardBounced; + this.markedEmailAsSpam = markedEmailAsSpam; + this.unsubscribedFromEmails = unsubscribedFromEmails; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.signedUpAt = signedUpAt; + this.lastSeenAt = lastSeenAt; + this.lastRepliedAt = lastRepliedAt; + this.lastContactedAt = lastContactedAt; + this.lastEmailOpenedAt = lastEmailOpenedAt; + this.lastEmailClickedAt = lastEmailClickedAt; + this.languageOverride = languageOverride; + this.browser = browser; + this.browserVersion = browserVersion; + this.browserLanguage = browserLanguage; + this.os = os; + this.androidAppName = androidAppName; + this.androidAppVersion = androidAppVersion; + this.androidDevice = androidDevice; + this.androidOsVersion = androidOsVersion; + this.androidSdkVersion = androidSdkVersion; + this.androidLastSeenAt = androidLastSeenAt; + this.iosAppName = iosAppName; + this.iosAppVersion = iosAppVersion; + this.iosDevice = iosDevice; + this.iosOsVersion = iosOsVersion; + this.iosSdkVersion = iosSdkVersion; + this.iosLastSeenAt = iosLastSeenAt; + this.customAttributes = customAttributes; + this.avatar = avatar; + this.tags = tags; + this.notes = notes; + this.companies = companies; + this.location = location; + this.socialProfiles = socialProfiles; + this.enabledPushMessaging = enabledPushMessaging; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The unique identifier for the contact which is provided by the Client. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The id of the workspace which the contact belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The role of the contact. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + /** + * @return The contact's email. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return The contact's email domain. + */ + @JsonProperty("email_domain") + public Optional getEmailDomain() { + return emailDomain; + } + + /** + * @return The contacts phone. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return The contacts phone number normalized to the E164 format + */ + @JsonProperty("formatted_phone") + public Optional getFormattedPhone() { + return formattedPhone; + } + + /** + * @return The contacts name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The id of an admin that has been assigned account ownership of the contact. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return Whether the contact has had an email sent to them hard bounce. + */ + @JsonProperty("has_hard_bounced") + public Optional getHasHardBounced() { + return hasHardBounced; + } + + /** + * @return Whether the contact has marked an email sent to them as spam. + */ + @JsonProperty("marked_email_as_spam") + public Optional getMarkedEmailAsSpam() { + return markedEmailAsSpam; + } + + /** + * @return Whether the contact is unsubscribed from emails. + */ + @JsonProperty("unsubscribed_from_emails") + public Optional getUnsubscribedFromEmails() { + return unsubscribedFromEmails; + } + + /** + * @return (UNIX timestamp) The time when the contact was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return (UNIX timestamp) The time specified for when a contact signed up. + */ + @JsonProperty("signed_up_at") + public Optional getSignedUpAt() { + return signedUpAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + @JsonProperty("last_seen_at") + public Optional getLastSeenAt() { + return lastSeenAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last messaged in. + */ + @JsonProperty("last_replied_at") + public Optional getLastRepliedAt() { + return lastRepliedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact was last messaged. + */ + @JsonProperty("last_contacted_at") + public Optional getLastContactedAt() { + return lastContactedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last opened an email. + */ + @JsonProperty("last_email_opened_at") + public Optional getLastEmailOpenedAt() { + return lastEmailOpenedAt; + } + + /** + * @return (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + @JsonProperty("last_email_clicked_at") + public Optional getLastEmailClickedAt() { + return lastEmailClickedAt; + } + + /** + * @return A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + @JsonProperty("language_override") + public Optional getLanguageOverride() { + return languageOverride; + } + + /** + * @return The name of the browser which the contact is using. + */ + @JsonProperty("browser") + public Optional getBrowser() { + return browser; + } + + /** + * @return The version of the browser which the contact is using. + */ + @JsonProperty("browser_version") + public Optional getBrowserVersion() { + return browserVersion; + } + + /** + * @return The language set by the browser which the contact is using. + */ + @JsonProperty("browser_language") + public Optional getBrowserLanguage() { + return browserLanguage; + } + + /** + * @return The operating system which the contact is using. + */ + @JsonProperty("os") + public Optional getOs() { + return os; + } + + /** + * @return The name of the Android app which the contact is using. + */ + @JsonProperty("android_app_name") + public Optional getAndroidAppName() { + return androidAppName; + } + + /** + * @return The version of the Android app which the contact is using. + */ + @JsonProperty("android_app_version") + public Optional getAndroidAppVersion() { + return androidAppVersion; + } + + /** + * @return The Android device which the contact is using. + */ + @JsonProperty("android_device") + public Optional getAndroidDevice() { + return androidDevice; + } + + /** + * @return The version of the Android OS which the contact is using. + */ + @JsonProperty("android_os_version") + public Optional getAndroidOsVersion() { + return androidOsVersion; + } + + /** + * @return The version of the Android SDK which the contact is using. + */ + @JsonProperty("android_sdk_version") + public Optional getAndroidSdkVersion() { + return androidSdkVersion; + } + + /** + * @return (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + @JsonProperty("android_last_seen_at") + public Optional getAndroidLastSeenAt() { + return androidLastSeenAt; + } + + /** + * @return The name of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_name") + public Optional getIosAppName() { + return iosAppName; + } + + /** + * @return The version of the iOS app which the contact is using. + */ + @JsonProperty("ios_app_version") + public Optional getIosAppVersion() { + return iosAppVersion; + } + + /** + * @return The iOS device which the contact is using. + */ + @JsonProperty("ios_device") + public Optional getIosDevice() { + return iosDevice; + } + + /** + * @return The version of iOS which the contact is using. + */ + @JsonProperty("ios_os_version") + public Optional getIosOsVersion() { + return iosOsVersion; + } + + /** + * @return The version of the iOS SDK which the contact is using. + */ + @JsonProperty("ios_sdk_version") + public Optional getIosSdkVersion() { + return iosSdkVersion; + } + + /** + * @return (UNIX timestamp) The last time the contact used the iOS app. + */ + @JsonProperty("ios_last_seen_at") + public Optional getIosLastSeenAt() { + return iosLastSeenAt; + } + + /** + * @return The custom attributes which are set for the contact. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("avatar") + public Optional getAvatar() { + return avatar; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("notes") + public Optional getNotes() { + return notes; + } + + @JsonProperty("companies") + public Optional getCompanies() { + return companies; + } + + @JsonProperty("location") + public Optional getLocation() { + return location; + } + + @JsonProperty("social_profiles") + public Optional getSocialProfiles() { + return socialProfiles; + } + + /** + * @return If the user has enabled push messaging. + */ + @JsonProperty("enabled_push_messaging") + public Optional getEnabledPushMessaging() { + return enabledPushMessaging; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateContactResponse && equalTo((UpdateContactResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateContactResponse other) { + return type.equals(other.type) + && id.equals(other.id) + && externalId.equals(other.externalId) + && workspaceId.equals(other.workspaceId) + && role.equals(other.role) + && email.equals(other.email) + && emailDomain.equals(other.emailDomain) + && phone.equals(other.phone) + && formattedPhone.equals(other.formattedPhone) + && name.equals(other.name) + && ownerId.equals(other.ownerId) + && hasHardBounced.equals(other.hasHardBounced) + && markedEmailAsSpam.equals(other.markedEmailAsSpam) + && unsubscribedFromEmails.equals(other.unsubscribedFromEmails) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && signedUpAt.equals(other.signedUpAt) + && lastSeenAt.equals(other.lastSeenAt) + && lastRepliedAt.equals(other.lastRepliedAt) + && lastContactedAt.equals(other.lastContactedAt) + && lastEmailOpenedAt.equals(other.lastEmailOpenedAt) + && lastEmailClickedAt.equals(other.lastEmailClickedAt) + && languageOverride.equals(other.languageOverride) + && browser.equals(other.browser) + && browserVersion.equals(other.browserVersion) + && browserLanguage.equals(other.browserLanguage) + && os.equals(other.os) + && androidAppName.equals(other.androidAppName) + && androidAppVersion.equals(other.androidAppVersion) + && androidDevice.equals(other.androidDevice) + && androidOsVersion.equals(other.androidOsVersion) + && androidSdkVersion.equals(other.androidSdkVersion) + && androidLastSeenAt.equals(other.androidLastSeenAt) + && iosAppName.equals(other.iosAppName) + && iosAppVersion.equals(other.iosAppVersion) + && iosDevice.equals(other.iosDevice) + && iosOsVersion.equals(other.iosOsVersion) + && iosSdkVersion.equals(other.iosSdkVersion) + && iosLastSeenAt.equals(other.iosLastSeenAt) + && customAttributes.equals(other.customAttributes) + && avatar.equals(other.avatar) + && tags.equals(other.tags) + && notes.equals(other.notes) + && companies.equals(other.companies) + && location.equals(other.location) + && socialProfiles.equals(other.socialProfiles) + && enabledPushMessaging.equals(other.enabledPushMessaging); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.externalId, + this.workspaceId, + this.role, + this.email, + this.emailDomain, + this.phone, + this.formattedPhone, + this.name, + this.ownerId, + this.hasHardBounced, + this.markedEmailAsSpam, + this.unsubscribedFromEmails, + this.createdAt, + this.updatedAt, + this.signedUpAt, + this.lastSeenAt, + this.lastRepliedAt, + this.lastContactedAt, + this.lastEmailOpenedAt, + this.lastEmailClickedAt, + this.languageOverride, + this.browser, + this.browserVersion, + this.browserLanguage, + this.os, + this.androidAppName, + this.androidAppVersion, + this.androidDevice, + this.androidOsVersion, + this.androidSdkVersion, + this.androidLastSeenAt, + this.iosAppName, + this.iosAppVersion, + this.iosDevice, + this.iosOsVersion, + this.iosSdkVersion, + this.iosLastSeenAt, + this.customAttributes, + this.avatar, + this.tags, + this.notes, + this.companies, + this.location, + this.socialProfiles, + this.enabledPushMessaging); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional emailDomain = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional formattedPhone = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional hasHardBounced = Optional.empty(); + + private Optional markedEmailAsSpam = Optional.empty(); + + private Optional unsubscribedFromEmails = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional signedUpAt = Optional.empty(); + + private Optional lastSeenAt = Optional.empty(); + + private Optional lastRepliedAt = Optional.empty(); + + private Optional lastContactedAt = Optional.empty(); + + private Optional lastEmailOpenedAt = Optional.empty(); + + private Optional lastEmailClickedAt = Optional.empty(); + + private Optional languageOverride = Optional.empty(); + + private Optional browser = Optional.empty(); + + private Optional browserVersion = Optional.empty(); + + private Optional browserLanguage = Optional.empty(); + + private Optional os = Optional.empty(); + + private Optional androidAppName = Optional.empty(); + + private Optional androidAppVersion = Optional.empty(); + + private Optional androidDevice = Optional.empty(); + + private Optional androidOsVersion = Optional.empty(); + + private Optional androidSdkVersion = Optional.empty(); + + private Optional androidLastSeenAt = Optional.empty(); + + private Optional iosAppName = Optional.empty(); + + private Optional iosAppVersion = Optional.empty(); + + private Optional iosDevice = Optional.empty(); + + private Optional iosOsVersion = Optional.empty(); + + private Optional iosSdkVersion = Optional.empty(); + + private Optional iosLastSeenAt = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional avatar = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional notes = Optional.empty(); + + private Optional companies = Optional.empty(); + + private Optional location = Optional.empty(); + + private Optional socialProfiles = Optional.empty(); + + private Optional enabledPushMessaging = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(UpdateContactResponse other) { + type(other.getType()); + id(other.getId()); + externalId(other.getExternalId()); + workspaceId(other.getWorkspaceId()); + role(other.getRole()); + email(other.getEmail()); + emailDomain(other.getEmailDomain()); + phone(other.getPhone()); + formattedPhone(other.getFormattedPhone()); + name(other.getName()); + ownerId(other.getOwnerId()); + hasHardBounced(other.getHasHardBounced()); + markedEmailAsSpam(other.getMarkedEmailAsSpam()); + unsubscribedFromEmails(other.getUnsubscribedFromEmails()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + signedUpAt(other.getSignedUpAt()); + lastSeenAt(other.getLastSeenAt()); + lastRepliedAt(other.getLastRepliedAt()); + lastContactedAt(other.getLastContactedAt()); + lastEmailOpenedAt(other.getLastEmailOpenedAt()); + lastEmailClickedAt(other.getLastEmailClickedAt()); + languageOverride(other.getLanguageOverride()); + browser(other.getBrowser()); + browserVersion(other.getBrowserVersion()); + browserLanguage(other.getBrowserLanguage()); + os(other.getOs()); + androidAppName(other.getAndroidAppName()); + androidAppVersion(other.getAndroidAppVersion()); + androidDevice(other.getAndroidDevice()); + androidOsVersion(other.getAndroidOsVersion()); + androidSdkVersion(other.getAndroidSdkVersion()); + androidLastSeenAt(other.getAndroidLastSeenAt()); + iosAppName(other.getIosAppName()); + iosAppVersion(other.getIosAppVersion()); + iosDevice(other.getIosDevice()); + iosOsVersion(other.getIosOsVersion()); + iosSdkVersion(other.getIosSdkVersion()); + iosLastSeenAt(other.getIosLastSeenAt()); + customAttributes(other.getCustomAttributes()); + avatar(other.getAvatar()); + tags(other.getTags()); + notes(other.getNotes()); + companies(other.getCompanies()); + location(other.getLocation()); + socialProfiles(other.getSocialProfiles()); + enabledPushMessaging(other.getEnabledPushMessaging()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the contact which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The unique identifier for the contact which is provided by the Client.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The id of the workspace which the contact belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The role of the contact.

+ */ + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } + + /** + *

The contact's email.

+ */ + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

The contact's email domain.

+ */ + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } + + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } + + /** + *

The contacts phone.

+ */ + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } + + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } + + /** + *

The contacts phone number normalized to the E164 format

+ */ + @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) + public Builder formattedPhone(Optional formattedPhone) { + this.formattedPhone = formattedPhone; + return this; + } + + public Builder formattedPhone(String formattedPhone) { + this.formattedPhone = Optional.ofNullable(formattedPhone); + return this; + } + + /** + *

The contacts name.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The id of an admin that has been assigned account ownership of the contact.

+ */ + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } + + /** + *

Whether the contact has had an email sent to them hard bounce.

+ */ + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } + + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } + + /** + *

Whether the contact has marked an email sent to them as spam.

+ */ + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { + this.markedEmailAsSpam = markedEmailAsSpam; + return this; + } + + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); + return this; + } + + /** + *

Whether the contact is unsubscribed from emails.

+ */ + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; + return this; + } + + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

(UNIX timestamp) The time specified for when a contact signed up.

+ */ + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; + return this; + } + + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually).

+ */ + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; + return this; + } + + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last messaged in.

+ */ + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; + return this; + } + + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last messaged.

+ */ + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; + return this; + } + + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last opened an email.

+ */ + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; + return this; + } + + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact last clicked a link in an email.

+ */ + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; + return this; + } + + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + return this; + } + + /** + *

A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change.

+ */ + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; + return this; + } + + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); + return this; + } + + /** + *

The name of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; + return this; + } + + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); + return this; + } + + /** + *

The version of the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; + return this; + } + + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); + return this; + } + + /** + *

The language set by the browser which the contact is using.

+ */ + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; + return this; + } + + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); + return this; + } + + /** + *

The operating system which the contact is using.

+ */ + @JsonSetter(value = "os", nulls = Nulls.SKIP) + public Builder os(Optional os) { + this.os = os; + return this; + } + + public Builder os(String os) { + this.os = Optional.ofNullable(os); + return this; + } + + /** + *

The name of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_name", nulls = Nulls.SKIP) + public Builder androidAppName(Optional androidAppName) { + this.androidAppName = androidAppName; + return this; + } + + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); + return this; + } + + /** + *

The version of the Android app which the contact is using.

+ */ + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; + return this; + } + + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); + return this; + } + + /** + *

The Android device which the contact is using.

+ */ + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; + return this; + } + + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); + return this; + } + + /** + *

The version of the Android OS which the contact is using.

+ */ + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; + return this; + } + + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); + return this; + } + + /** + *

The version of the Android SDK which the contact is using.

+ */ + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; + return this; + } + + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The time when the contact was last seen on an Android device.

+ */ + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; + return this; + } + + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + return this; + } + + /** + *

The name of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; + return this; + } + + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); + return this; + } + + /** + *

The version of the iOS app which the contact is using.

+ */ + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; + return this; + } + + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); + return this; + } + + /** + *

The iOS device which the contact is using.

+ */ + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; + return this; + } + + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); + return this; + } + + /** + *

The version of iOS which the contact is using.

+ */ + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; + return this; + } + + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); + return this; + } + + /** + *

The version of the iOS SDK which the contact is using.

+ */ + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; + return this; + } + + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + return this; + } + + /** + *

(UNIX timestamp) The last time the contact used the iOS app.

+ */ + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; + return this; + } + + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + return this; + } + + /** + *

The custom attributes which are set for the contact.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; + return this; + } + + public Builder avatar(Avatar avatar) { + this.avatar = Optional.ofNullable(avatar); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; + return this; + } + + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); + return this; + } + + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; + return this; + } + + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); + return this; + } + + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; + return this; + } + + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); + return this; + } + + @JsonSetter(value = "social_profiles", nulls = Nulls.SKIP) + public Builder socialProfiles(Optional socialProfiles) { + this.socialProfiles = socialProfiles; + return this; + } + + public Builder socialProfiles(ContactSocialProfiles socialProfiles) { + this.socialProfiles = Optional.ofNullable(socialProfiles); + return this; + } + + /** + *

If the user has enabled push messaging.

+ */ + @JsonSetter(value = "enabled_push_messaging", nulls = Nulls.SKIP) + public Builder enabledPushMessaging(Optional enabledPushMessaging) { + this.enabledPushMessaging = enabledPushMessaging; + return this; + } + + public Builder enabledPushMessaging(Boolean enabledPushMessaging) { + this.enabledPushMessaging = Optional.ofNullable(enabledPushMessaging); + return this; + } + + public UpdateContactResponse build() { + return new UpdateContactResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + formattedPhone, + name, + ownerId, + hasHardBounced, + markedEmailAsSpam, + unsubscribedFromEmails, + createdAt, + updatedAt, + signedUpAt, + lastSeenAt, + lastRepliedAt, + lastContactedAt, + lastEmailOpenedAt, + lastEmailClickedAt, + languageOverride, + browser, + browserVersion, + browserLanguage, + os, + androidAppName, + androidAppVersion, + androidDevice, + androidOsVersion, + androidSdkVersion, + androidLastSeenAt, + iosAppName, + iosAppVersion, + iosDevice, + iosOsVersion, + iosSdkVersion, + iosLastSeenAt, + customAttributes, + avatar, + tags, + notes, + companies, + location, + socialProfiles, + enabledPushMessaging, + additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Avatar.Builder.class) + public static final class Avatar { + private final Optional type; + + private final Optional imageUrl; + + private final Map additionalProperties; + + private Avatar(Optional type, Optional imageUrl, Map additionalProperties) { + this.type = type; + this.imageUrl = imageUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @JsonProperty("image_url") + public Optional getImageUrl() { + return imageUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Avatar && equalTo((Avatar) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Avatar other) { + return type.equals(other.type) && imageUrl.equals(other.imageUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.imageUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional imageUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Avatar other) { + type(other.getType()); + imageUrl(other.getImageUrl()); + return this; + } + + /** + *

The type of object

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @JsonSetter(value = "image_url", nulls = Nulls.SKIP) + public Builder imageUrl(Optional imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + public Builder imageUrl(String imageUrl) { + this.imageUrl = Optional.ofNullable(imageUrl); + return this; + } + + public Avatar build() { + return new Avatar(type, imageUrl, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/AsyncConversationsClient.java b/src/main/java/com/intercom/api/resources/unstable/conversations/AsyncConversationsClient.java new file mode 100644 index 0000000..7429f70 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/AsyncConversationsClient.java @@ -0,0 +1,498 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.conversations.requests.AttachContactToConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ConvertConversationToTicketRequest; +import com.intercom.api.resources.unstable.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DeleteConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DetachContactFromConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ListConversationsRequest; +import com.intercom.api.resources.unstable.conversations.requests.ManageConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ReplyConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.RetrieveConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.UpdateConversationRequest; +import com.intercom.api.resources.unstable.conversations.types.Conversation; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.ConversationDeleted; +import com.intercom.api.resources.unstable.types.ConversationList; +import com.intercom.api.resources.unstable.types.RedactConversationRequest; +import com.intercom.api.resources.unstable.types.SearchRequest; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncConversationsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawConversationsClient rawClient; + + public AsyncConversationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawConversationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawConversationsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture listConversations() { + return this.rawClient.listConversations().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture listConversations(ListConversationsRequest request) { + return this.rawClient.listConversations(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture listConversations( + ListConversationsRequest request, RequestOptions requestOptions) { + return this.rawClient.listConversations(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public CompletableFuture createConversation(CreateConversationRequest request) { + return this.rawClient.createConversation(request).thenApply(response -> response.body()); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public CompletableFuture createConversation( + CreateConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.createConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public CompletableFuture retrieveConversation(RetrieveConversationRequest request) { + return this.rawClient.retrieveConversation(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public CompletableFuture retrieveConversation( + RetrieveConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture updateConversation(UpdateConversationRequest request) { + return this.rawClient.updateConversation(request).thenApply(response -> response.body()); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture updateConversation( + UpdateConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.updateConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single conversation. + */ + public CompletableFuture deleteConversation(DeleteConversationRequest request) { + return this.rawClient.deleteConversation(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single conversation. + */ + public CompletableFuture deleteConversation( + DeleteConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture searchConversations(SearchRequest request) { + return this.rawClient.searchConversations(request).thenApply(response -> response.body()); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture searchConversations( + SearchRequest request, RequestOptions requestOptions) { + return this.rawClient.searchConversations(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture replyConversation(ReplyConversationRequest request) { + return this.rawClient.replyConversation(request).thenApply(response -> response.body()); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture replyConversation( + ReplyConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.replyConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public CompletableFuture manageConversation(ManageConversationRequest request) { + return this.rawClient.manageConversation(request).thenApply(response -> response.body()); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public CompletableFuture manageConversation( + ManageConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.manageConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture attachContactToConversation(AttachContactToConversationRequest request) { + return this.rawClient.attachContactToConversation(request).thenApply(response -> response.body()); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture attachContactToConversation( + AttachContactToConversationRequest request, RequestOptions requestOptions) { + return this.rawClient + .attachContactToConversation(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture detachContactFromConversation(DetachContactFromConversationRequest request) { + return this.rawClient.detachContactFromConversation(request).thenApply(response -> response.body()); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture detachContactFromConversation( + DetachContactFromConversationRequest request, RequestOptions requestOptions) { + return this.rawClient + .detachContactFromConversation(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public CompletableFuture redactConversation(RedactConversationRequest request) { + return this.rawClient.redactConversation(request).thenApply(response -> response.body()); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public CompletableFuture redactConversation( + RedactConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.redactConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can convert a conversation to a ticket. + */ + public CompletableFuture> convertConversationToTicket(ConvertConversationToTicketRequest request) { + return this.rawClient.convertConversationToTicket(request).thenApply(response -> response.body()); + } + + /** + * You can convert a conversation to a ticket. + */ + public CompletableFuture> convertConversationToTicket( + ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + return this.rawClient + .convertConversationToTicket(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/AsyncRawConversationsClient.java b/src/main/java/com/intercom/api/resources/unstable/conversations/AsyncRawConversationsClient.java new file mode 100644 index 0000000..d7043b0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/AsyncRawConversationsClient.java @@ -0,0 +1,1340 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.conversations.requests.AttachContactToConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ConvertConversationToTicketRequest; +import com.intercom.api.resources.unstable.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DeleteConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DetachContactFromConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ListConversationsRequest; +import com.intercom.api.resources.unstable.conversations.requests.ManageConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ReplyConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.RetrieveConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.UpdateConversationRequest; +import com.intercom.api.resources.unstable.conversations.types.Conversation; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.ForbiddenError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.ConversationDeleted; +import com.intercom.api.resources.unstable.types.ConversationList; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.RedactConversationRequest; +import com.intercom.api.resources.unstable.types.SearchRequest; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawConversationsClient { + protected final ClientOptions clientOptions; + + public AsyncRawConversationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> listConversations() { + return listConversations(ListConversationsRequest.builder().build()); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> listConversations( + ListConversationsRequest request) { + return listConversations(request, null); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public CompletableFuture> listConversations( + ListConversationsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations"); + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ConversationList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public CompletableFuture> createConversation(CreateConversationRequest request) { + return createConversation(request, null); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public CompletableFuture> createConversation( + CreateConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Message.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public CompletableFuture> retrieveConversation( + RetrieveConversationRequest request) { + return retrieveConversation(request, null); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public CompletableFuture> retrieveConversation( + RetrieveConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Conversation.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture> updateConversation(UpdateConversationRequest request) { + return updateConversation(request, null); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public CompletableFuture> updateConversation( + UpdateConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().get(), false); + } + Map properties = new HashMap<>(); + if (request.getRead().isPresent()) { + properties.put("read", request.getRead()); + } + if (request.getTitle().isPresent()) { + properties.put("title", request.getTitle()); + } + if (request.getCustomAttributes().isPresent()) { + properties.put("custom_attributes", request.getCustomAttributes()); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Conversation.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a single conversation. + */ + public CompletableFuture> deleteConversation( + DeleteConversationRequest request) { + return deleteConversation(request, null); + } + + /** + * You can delete a single conversation. + */ + public CompletableFuture> deleteConversation( + DeleteConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ConversationDeleted.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> searchConversations(SearchRequest request) { + return searchConversations(request, null); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> searchConversations( + SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), ConversationList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture> replyConversation(ReplyConversationRequest request) { + return replyConversation(request, null); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture> replyConversation( + ReplyConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Conversation.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public CompletableFuture> manageConversation(ManageConversationRequest request) { + return manageConversation(request, null); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public CompletableFuture> manageConversation( + ManageConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getId()) + .addPathSegments("parts") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Conversation.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture> attachContactToConversation( + AttachContactToConversationRequest request) { + return attachContactToConversation(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture> attachContactToConversation( + AttachContactToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getId()) + .addPathSegments("customers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Conversation.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture> detachContactFromConversation( + DetachContactFromConversationRequest request) { + return detachContactFromConversation(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public CompletableFuture> detachContactFromConversation( + DetachContactFromConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("customers") + .addPathSegment(request.getContactId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Conversation.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public CompletableFuture> redactConversation(RedactConversationRequest request) { + return redactConversation(request, null); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public CompletableFuture> redactConversation( + RedactConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/redact") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Conversation.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can convert a conversation to a ticket. + */ + public CompletableFuture>> convertConversationToTicket( + ConvertConversationToTicketRequest request) { + return convertConversationToTicket(request, null); + } + + /** + * You can convert a conversation to a ticket. + */ + public CompletableFuture>> convertConversationToTicket( + ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("convert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 400) { + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/ConversationsClient.java b/src/main/java/com/intercom/api/resources/unstable/conversations/ConversationsClient.java new file mode 100644 index 0000000..46374f0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/ConversationsClient.java @@ -0,0 +1,488 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.conversations.requests.AttachContactToConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ConvertConversationToTicketRequest; +import com.intercom.api.resources.unstable.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DeleteConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DetachContactFromConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ListConversationsRequest; +import com.intercom.api.resources.unstable.conversations.requests.ManageConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ReplyConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.RetrieveConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.UpdateConversationRequest; +import com.intercom.api.resources.unstable.conversations.types.Conversation; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.ConversationDeleted; +import com.intercom.api.resources.unstable.types.ConversationList; +import com.intercom.api.resources.unstable.types.RedactConversationRequest; +import com.intercom.api.resources.unstable.types.SearchRequest; +import java.util.Optional; + +public class ConversationsClient { + protected final ClientOptions clientOptions; + + private final RawConversationsClient rawClient; + + public ConversationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawConversationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawConversationsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public ConversationList listConversations() { + return this.rawClient.listConversations().body(); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public ConversationList listConversations(ListConversationsRequest request) { + return this.rawClient.listConversations(request).body(); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public ConversationList listConversations(ListConversationsRequest request, RequestOptions requestOptions) { + return this.rawClient.listConversations(request, requestOptions).body(); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public Message createConversation(CreateConversationRequest request) { + return this.rawClient.createConversation(request).body(); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public Message createConversation(CreateConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.createConversation(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public Conversation retrieveConversation(RetrieveConversationRequest request) { + return this.rawClient.retrieveConversation(request).body(); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public Conversation retrieveConversation(RetrieveConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveConversation(request, requestOptions).body(); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public Conversation updateConversation(UpdateConversationRequest request) { + return this.rawClient.updateConversation(request).body(); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public Conversation updateConversation(UpdateConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.updateConversation(request, requestOptions).body(); + } + + /** + * You can delete a single conversation. + */ + public ConversationDeleted deleteConversation(DeleteConversationRequest request) { + return this.rawClient.deleteConversation(request).body(); + } + + /** + * You can delete a single conversation. + */ + public ConversationDeleted deleteConversation(DeleteConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteConversation(request, requestOptions).body(); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public ConversationList searchConversations(SearchRequest request) { + return this.rawClient.searchConversations(request).body(); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public ConversationList searchConversations(SearchRequest request, RequestOptions requestOptions) { + return this.rawClient.searchConversations(request, requestOptions).body(); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public Conversation replyConversation(ReplyConversationRequest request) { + return this.rawClient.replyConversation(request).body(); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public Conversation replyConversation(ReplyConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.replyConversation(request, requestOptions).body(); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public Conversation manageConversation(ManageConversationRequest request) { + return this.rawClient.manageConversation(request).body(); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public Conversation manageConversation(ManageConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.manageConversation(request, requestOptions).body(); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation attachContactToConversation(AttachContactToConversationRequest request) { + return this.rawClient.attachContactToConversation(request).body(); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation attachContactToConversation( + AttachContactToConversationRequest request, RequestOptions requestOptions) { + return this.rawClient + .attachContactToConversation(request, requestOptions) + .body(); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation detachContactFromConversation(DetachContactFromConversationRequest request) { + return this.rawClient.detachContactFromConversation(request).body(); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public Conversation detachContactFromConversation( + DetachContactFromConversationRequest request, RequestOptions requestOptions) { + return this.rawClient + .detachContactFromConversation(request, requestOptions) + .body(); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public Conversation redactConversation(RedactConversationRequest request) { + return this.rawClient.redactConversation(request).body(); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public Conversation redactConversation(RedactConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.redactConversation(request, requestOptions).body(); + } + + /** + * You can convert a conversation to a ticket. + */ + public Optional convertConversationToTicket(ConvertConversationToTicketRequest request) { + return this.rawClient.convertConversationToTicket(request).body(); + } + + /** + * You can convert a conversation to a ticket. + */ + public Optional convertConversationToTicket( + ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + return this.rawClient + .convertConversationToTicket(request, requestOptions) + .body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/RawConversationsClient.java b/src/main/java/com/intercom/api/resources/unstable/conversations/RawConversationsClient.java new file mode 100644 index 0000000..2f0b1ab --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/RawConversationsClient.java @@ -0,0 +1,1110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.conversations.requests.AttachContactToConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ConvertConversationToTicketRequest; +import com.intercom.api.resources.unstable.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DeleteConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.DetachContactFromConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ListConversationsRequest; +import com.intercom.api.resources.unstable.conversations.requests.ManageConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.ReplyConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.RetrieveConversationRequest; +import com.intercom.api.resources.unstable.conversations.requests.UpdateConversationRequest; +import com.intercom.api.resources.unstable.conversations.types.Conversation; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.ForbiddenError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.ConversationDeleted; +import com.intercom.api.resources.unstable.types.ConversationList; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.RedactConversationRequest; +import com.intercom.api.resources.unstable.types.SearchRequest; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawConversationsClient { + protected final ClientOptions clientOptions; + + public RawConversationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public IntercomHttpResponse listConversations() { + return listConversations(ListConversationsRequest.builder().build()); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public IntercomHttpResponse listConversations(ListConversationsRequest request) { + return listConversations(request, null); + } + + /** + * You can fetch a list of all conversations. + *

You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ */ + public IntercomHttpResponse listConversations( + ListConversationsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations"); + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public IntercomHttpResponse createConversation(CreateConversationRequest request) { + return createConversation(request, null); + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + *

{% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their user_id or id value in the from field, along with a type field value of contact. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %}

+ *

This will return the Message model that has been created.

+ */ + public IntercomHttpResponse createConversation( + CreateConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public IntercomHttpResponse retrieveConversation(RetrieveConversationRequest request) { + return retrieveConversation(request, null); + } + + /** + * You can fetch the details of a single conversation. + *

This will return a single Conversation model with all its conversation parts.

+ *

{% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %}

+ *

For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a paid feature.

+ */ + public IntercomHttpResponse retrieveConversation( + RetrieveConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public IntercomHttpResponse updateConversation(UpdateConversationRequest request) { + return updateConversation(request, null); + } + + /** + * You can update an existing conversation. + *

{% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %}

+ *

{% admonition type="info" %} + * This endpoint handles both conversation updates and custom object associations.

+ *

See update a conversation with an association to a custom object instance in the request/response examples to see the custom object association format. + * {% /admonition %}

+ */ + public IntercomHttpResponse updateConversation( + UpdateConversationRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())); + if (request.getDisplayAs().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_as", request.getDisplayAs().get(), false); + } + Map properties = new HashMap<>(); + if (request.getRead().isPresent()) { + properties.put("read", request.getRead()); + } + if (request.getTitle().isPresent()) { + properties.put("title", request.getTitle()); + } + if (request.getCustomAttributes().isPresent()) { + properties.put("custom_attributes", request.getCustomAttributes()); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single conversation. + */ + public IntercomHttpResponse deleteConversation(DeleteConversationRequest request) { + return deleteConversation(request, null); + } + + /** + * You can delete a single conversation. + */ + public IntercomHttpResponse deleteConversation( + DeleteConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationDeleted.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public IntercomHttpResponse searchConversations(SearchRequest request) { + return searchConversations(request, null); + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + *

To search for conversations, you need to send a POST request to https://api.intercom.io/conversations/search.

+ *

This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page and maximum is 150. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foorbar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String<br>Accepted fields are conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String |

+ *

Accepted Operators

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public IntercomHttpResponse searchConversations( + SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ConversationList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public IntercomHttpResponse replyConversation(ReplyConversationRequest request) { + return replyConversation(request, null); + } + + /** + * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public IntercomHttpResponse replyConversation( + ReplyConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public IntercomHttpResponse manageConversation(ManageConversationRequest request) { + return manageConversation(request, null); + } + + /** + * For managing conversations you can: + *
    + *
  • Close a conversation
  • + *
  • Snooze a conversation to reopen on a future date
  • + *
  • Open a conversation which is snoozed or closed
  • + *
  • Assign a conversation to an admin and/or team.
  • + *
+ */ + public IntercomHttpResponse manageConversation( + ManageConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getId()) + .addPathSegments("parts") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public IntercomHttpResponse attachContactToConversation(AttachContactToConversationRequest request) { + return attachContactToConversation(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public IntercomHttpResponse attachContactToConversation( + AttachContactToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getId()) + .addPathSegments("customers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public IntercomHttpResponse detachContactFromConversation( + DetachContactFromConversationRequest request) { + return detachContactFromConversation(request, null); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + *

{% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with role set to lead. + * {% /admonition %}

+ */ + public IntercomHttpResponse detachContactFromConversation( + DetachContactFromConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("customers") + .addPathSegment(request.getContactId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public IntercomHttpResponse redactConversation(RedactConversationRequest request) { + return redactConversation(request, null); + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + *

{% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a body. If you are redacting a source message, it must have been created by a contact. We will return a conversation_part_not_redactable error if these criteria are not met. + * {% /admonition %}

+ */ + public IntercomHttpResponse redactConversation( + RedactConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations/redact") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can convert a conversation to a ticket. + */ + public IntercomHttpResponse> convertConversationToTicket( + ConvertConversationToTicketRequest request) { + return convertConversationToTicket(request, null); + } + + /** + * You can convert a conversation to a ticket. + */ + public IntercomHttpResponse> convertConversationToTicket( + ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("convert") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 400) { + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/AttachContactToConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/AttachContactToConversationRequest.java new file mode 100644 index 0000000..f6d873b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/AttachContactToConversationRequest.java @@ -0,0 +1,662 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.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.resources.unstable.types.CustomerRequest; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AttachContactToConversationRequest.Builder.class) +public final class AttachContactToConversationRequest { + private final String id; + + private final Optional adminId; + + private final Optional customer; + + private final Map additionalProperties; + + private AttachContactToConversationRequest( + String id, + Optional adminId, + Optional customer, + Map additionalProperties) { + this.id = id; + this.adminId = adminId; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the conversation as given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The id of the admin who is adding the new participant. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachContactToConversationRequest + && equalTo((AttachContactToConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachContactToConversationRequest other) { + return id.equals(other.id) && adminId.equals(other.adminId) && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.adminId, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The identifier for the conversation as given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(AttachContactToConversationRequest other); + } + + public interface _FinalStage { + AttachContactToConversationRequest build(); + + /** + *

The id of the admin who is adding the new participant.

+ */ + _FinalStage adminId(Optional adminId); + + _FinalStage adminId(String adminId); + + _FinalStage customer(Optional customer); + + _FinalStage customer(Customer customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional customer = Optional.empty(); + + private Optional adminId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachContactToConversationRequest other) { + id(other.getId()); + adminId(other.getAdminId()); + customer(other.getCustomer()); + return this; + } + + /** + * The identifier for the conversation as given by Intercom.

The identifier for the conversation as given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(Customer customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + /** + *

The id of the admin who is adding the new participant.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + /** + *

The id of the admin who is adding the new participant.

+ */ + @java.lang.Override + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + @java.lang.Override + public AttachContactToConversationRequest build() { + return new AttachContactToConversationRequest(id, adminId, customer, additionalProperties); + } + } + + @JsonDeserialize(using = Customer.Deserializer.class) + public static final class Customer { + private final Object value; + + private final int type; + + private Customer(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((IntercomUserId) this.value); + } else if (this.type == 1) { + return visitor.visit((UserId) this.value); + } else if (this.type == 2) { + return visitor.visit((Customer_) 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 Customer && equalTo((Customer) other); + } + + private boolean equalTo(Customer 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 Customer of(IntercomUserId value) { + return new Customer(value, 0); + } + + public static Customer of(UserId value) { + return new Customer(value, 1); + } + + public static Customer of(Customer_ value) { + return new Customer(value, 2); + } + + public interface Visitor { + T visit(IntercomUserId value); + + T visit(UserId value); + + T visit(Customer_ value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(Customer.class); + } + + @java.lang.Override + public Customer deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, IntercomUserId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, UserId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Customer_.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Customer_.Builder.class) + public static final class Customer_ { + private final String email; + + private final Optional customer; + + private final Map additionalProperties; + + private Customer_( + String email, Optional customer, Map additionalProperties) { + this.email = email; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The email you have defined for the contact who is being added as a participant. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Customer_ && equalTo((Customer_) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Customer_ other) { + return email.equals(other.email) && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.email, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EmailStage builder() { + return new Builder(); + } + + public interface EmailStage { + /** + * The email you have defined for the contact who is being added as a participant. + */ + _FinalStage email(@NotNull String email); + + Builder from(Customer_ other); + } + + public interface _FinalStage { + Customer_ build(); + + _FinalStage customer(Optional customer); + + _FinalStage customer(CustomerRequest customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EmailStage, _FinalStage { + private String email; + + private Optional customer = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Customer_ other) { + email(other.getEmail()); + customer(other.getCustomer()); + return this; + } + + /** + * The email you have defined for the contact who is being added as a participant.

The email you have defined for the contact who is being added as a participant.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("email") + public _FinalStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(CustomerRequest customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + @java.lang.Override + public Customer_ build() { + return new Customer_(email, customer, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = UserId.Builder.class) + public static final class UserId { + private final String userId; + + private final Optional customer; + + private final Map additionalProperties; + + private UserId( + String userId, Optional customer, Map additionalProperties) { + this.userId = userId; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The external_id you have defined for the contact who is being added as a participant. + */ + @JsonProperty("user_id") + public String getUserId() { + return userId; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserId && equalTo((UserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UserId other) { + return userId.equals(other.userId) && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + /** + * The external_id you have defined for the contact who is being added as a participant. + */ + _FinalStage userId(@NotNull String userId); + + Builder from(UserId other); + } + + public interface _FinalStage { + UserId build(); + + _FinalStage customer(Optional customer); + + _FinalStage customer(CustomerRequest customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + private Optional customer = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UserId other) { + userId(other.getUserId()); + customer(other.getCustomer()); + return this; + } + + /** + * The external_id you have defined for the contact who is being added as a participant.

The external_id you have defined for the contact who is being added as a participant.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("user_id") + public _FinalStage userId(@NotNull String userId) { + this.userId = Objects.requireNonNull(userId, "userId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(CustomerRequest customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + @java.lang.Override + public UserId build() { + return new UserId(userId, customer, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = IntercomUserId.Builder.class) + public static final class IntercomUserId { + private final String intercomUserId; + + private final Optional customer; + + private final Map additionalProperties; + + private IntercomUserId( + String intercomUserId, + Optional customer, + Map additionalProperties) { + this.intercomUserId = intercomUserId; + this.customer = customer; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the contact as given by Intercom. + */ + @JsonProperty("intercom_user_id") + public String getIntercomUserId() { + return intercomUserId; + } + + @JsonProperty("customer") + public Optional getCustomer() { + return customer; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof IntercomUserId && equalTo((IntercomUserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(IntercomUserId other) { + return intercomUserId.equals(other.intercomUserId) && customer.equals(other.customer); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.intercomUserId, this.customer); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IntercomUserIdStage builder() { + return new Builder(); + } + + public interface IntercomUserIdStage { + /** + * The identifier for the contact as given by Intercom. + */ + _FinalStage intercomUserId(@NotNull String intercomUserId); + + Builder from(IntercomUserId other); + } + + public interface _FinalStage { + IntercomUserId build(); + + _FinalStage customer(Optional customer); + + _FinalStage customer(CustomerRequest customer); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IntercomUserIdStage, _FinalStage { + private String intercomUserId; + + private Optional customer = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(IntercomUserId other) { + intercomUserId(other.getIntercomUserId()); + customer(other.getCustomer()); + return this; + } + + /** + * The identifier for the contact as given by Intercom.

The identifier for the contact as given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("intercom_user_id") + public _FinalStage intercomUserId(@NotNull String intercomUserId) { + this.intercomUserId = Objects.requireNonNull(intercomUserId, "intercomUserId must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage customer(CustomerRequest customer) { + this.customer = Optional.ofNullable(customer); + return this; + } + + @java.lang.Override + @JsonSetter(value = "customer", nulls = Nulls.SKIP) + public _FinalStage customer(Optional customer) { + this.customer = customer; + return this; + } + + @java.lang.Override + public IntercomUserId build() { + return new IntercomUserId(intercomUserId, customer, additionalProperties); + } + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ConvertConversationToTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ConvertConversationToTicketRequest.java new file mode 100644 index 0000000..e3a8dca --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ConvertConversationToTicketRequest.java @@ -0,0 +1,290 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ConvertConversationToTicketRequest.Builder.class) +public final class ConvertConversationToTicketRequest { + private final int id; + + private final String ticketTypeId; + + private final Optional> attributes; + + private final Map additionalProperties; + + private ConvertConversationToTicketRequest( + int id, + String ticketTypeId, + Optional> attributes, + Map additionalProperties) { + this.id = id; + this.ticketTypeId = ticketTypeId; + this.attributes = attributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the conversation to target + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return The ID of the type of ticket you want to convert the conversation to + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + @JsonProperty("attributes") + public Optional> getAttributes() { + return attributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ConvertConversationToTicketRequest + && equalTo((ConvertConversationToTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ConvertConversationToTicketRequest other) { + return id == other.id && ticketTypeId.equals(other.ticketTypeId) && attributes.equals(other.attributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.ticketTypeId, this.attributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The id of the conversation to target + */ + TicketTypeIdStage id(int id); + + Builder from(ConvertConversationToTicketRequest other); + } + + public interface TicketTypeIdStage { + /** + * The ID of the type of ticket you want to convert the conversation to + */ + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + } + + public interface _FinalStage { + ConvertConversationToTicketRequest build(); + + _FinalStage attributes(Optional> attributes); + + _FinalStage attributes(Map attributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, TicketTypeIdStage, _FinalStage { + private int id; + + private String ticketTypeId; + + private Optional> attributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ConvertConversationToTicketRequest other) { + id(other.getId()); + ticketTypeId(other.getTicketTypeId()); + attributes(other.getAttributes()); + return this; + } + + /** + * The id of the conversation to target

The id of the conversation to target

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public TicketTypeIdStage id(int id) { + this.id = id; + return this; + } + + /** + * The ID of the type of ticket you want to convert the conversation to

The ID of the type of ticket you want to convert the conversation to

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ticket_type_id") + public _FinalStage ticketTypeId(@NotNull String ticketTypeId) { + this.ticketTypeId = Objects.requireNonNull(ticketTypeId, "ticketTypeId must not be null"); + return this; + } + + @java.lang.Override + 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) { + this.attributes = attributes; + return this; + } + + @java.lang.Override + public ConvertConversationToTicketRequest build() { + return new ConvertConversationToTicketRequest(id, 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; + } + + @SuppressWarnings("unchecked") + 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/unstable/conversations/requests/CreateConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/CreateConversationRequest.java new file mode 100644 index 0000000..84b7b0e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/CreateConversationRequest.java @@ -0,0 +1,392 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateConversationRequest.Builder.class) +public final class CreateConversationRequest { + private final From from; + + private final String body; + + private final Optional createdAt; + + private final Map additionalProperties; + + private CreateConversationRequest( + From from, String body, Optional createdAt, Map additionalProperties) { + this.from = from; + this.body = body; + this.createdAt = createdAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("from") + public From getFrom() { + return from; + } + + /** + * @return The content of the message. HTML is not supported. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateConversationRequest && equalTo((CreateConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateConversationRequest other) { + return from.equals(other.from) && body.equals(other.body) && createdAt.equals(other.createdAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.from, this.body, this.createdAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FromStage builder() { + return new Builder(); + } + + public interface FromStage { + BodyStage from(@NotNull From from); + + Builder from(CreateConversationRequest other); + } + + public interface BodyStage { + /** + * The content of the message. HTML is not supported. + */ + _FinalStage body(@NotNull String body); + } + + public interface _FinalStage { + CreateConversationRequest build(); + + /** + *

The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom.

+ */ + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements FromStage, BodyStage, _FinalStage { + private From from; + + private String body; + + private Optional createdAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateConversationRequest other) { + from(other.getFrom()); + body(other.getBody()); + createdAt(other.getCreatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("from") + public BodyStage from(@NotNull From from) { + this.from = Objects.requireNonNull(from, "from must not be null"); + return this; + } + + /** + * The content of the message. HTML is not supported.

The content of the message. HTML is not supported.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull String body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + /** + *

The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom.

+ */ + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + @java.lang.Override + public CreateConversationRequest build() { + return new CreateConversationRequest(from, body, createdAt, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = From.Builder.class) + public static final class From { + private final Type type; + + private final String id; + + private final Map additionalProperties; + + private From(Type type, String id, Map additionalProperties) { + this.type = type; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The role associated to the contact - user or lead. + */ + @JsonProperty("type") + public Type getType() { + return type; + } + + /** + * @return The identifier for the contact which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof From && equalTo((From) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(From other) { + return type.equals(other.type) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + /** + * The role associated to the contact - user or lead. + */ + IdStage type(@NotNull Type type); + + Builder from(From other); + } + + public interface IdStage { + /** + * The identifier for the contact which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + From build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TypeStage, IdStage, _FinalStage { + private Type type; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(From other) { + type(other.getType()); + id(other.getId()); + return this; + } + + /** + * The role associated to the contact - user or lead.

The role associated to the contact - user or lead.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("type") + public IdStage type(@NotNull Type type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + * The identifier for the contact which is given by Intercom.

The identifier for the contact which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public From build() { + return new From(type, id, additionalProperties); + } + } + + public static final class Type { + public static final Type USER = new Type(Value.USER, "user"); + + public static final Type CONTACT = new Type(Value.CONTACT, "contact"); + + public static final Type LEAD = new Type(Value.LEAD, "lead"); + + private final Value value; + + private final String string; + + Type(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Type && this.string.equals(((Type) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case CONTACT: + return visitor.visitContact(); + case LEAD: + return visitor.visitLead(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Type valueOf(String value) { + switch (value) { + case "user": + return USER; + case "contact": + return CONTACT; + case "lead": + return LEAD; + default: + return new Type(Value.UNKNOWN, value); + } + } + + public enum Value { + LEAD, + + USER, + + CONTACT, + + UNKNOWN + } + + public interface Visitor { + T visitLead(); + + T visitUser(); + + T visitContact(); + + T visitUnknown(String unknownType); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/DeleteConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/DeleteConversationRequest.java new file mode 100644 index 0000000..8853392 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/DeleteConversationRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteConversationRequest.Builder.class) +public final class DeleteConversationRequest { + private final int id; + + private final Map additionalProperties; + + private DeleteConversationRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteConversationRequest && equalTo((DeleteConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteConversationRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * id + */ + _FinalStage id(int id); + + Builder from(DeleteConversationRequest other); + } + + public interface _FinalStage { + DeleteConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteConversationRequest other) { + id(other.getId()); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public DeleteConversationRequest build() { + return new DeleteConversationRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/DetachContactFromConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/DetachContactFromConversationRequest.java new file mode 100644 index 0000000..c013c9a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/DetachContactFromConversationRequest.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetachContactFromConversationRequest.Builder.class) +public final class DetachContactFromConversationRequest { + private final String conversationId; + + private final String contactId; + + private final String adminId; + + private final Map additionalProperties; + + private DetachContactFromConversationRequest( + String conversationId, String contactId, String adminId, Map additionalProperties) { + this.conversationId = conversationId; + this.contactId = contactId; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the conversation as given by Intercom. + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return The identifier for the contact as given by Intercom. + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The id of the admin who is performing the action. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachContactFromConversationRequest + && equalTo((DetachContactFromConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachContactFromConversationRequest other) { + return conversationId.equals(other.conversationId) + && contactId.equals(other.contactId) + && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.contactId, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + /** + * The identifier for the conversation as given by Intercom. + */ + ContactIdStage conversationId(@NotNull String conversationId); + + Builder from(DetachContactFromConversationRequest other); + } + + public interface ContactIdStage { + /** + * The identifier for the contact as given by Intercom. + */ + AdminIdStage contactId(@NotNull String contactId); + } + + public interface AdminIdStage { + /** + * The `id` of the admin who is performing the action. + */ + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + DetachContactFromConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, ContactIdStage, AdminIdStage, _FinalStage { + private String conversationId; + + private String contactId; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachContactFromConversationRequest other) { + conversationId(other.getConversationId()); + contactId(other.getContactId()); + adminId(other.getAdminId()); + return this; + } + + /** + * The identifier for the conversation as given by Intercom.

The identifier for the conversation as given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("conversation_id") + public ContactIdStage conversationId(@NotNull String conversationId) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + /** + * The identifier for the contact as given by Intercom.

The identifier for the contact as given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public AdminIdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + * The `id` of the admin who is performing the action.

The id of the admin who is performing the action.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public DetachContactFromConversationRequest build() { + return new DetachContactFromConversationRequest(conversationId, contactId, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ListConversationsRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ListConversationsRequest.java new file mode 100644 index 0000000..43cb614 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ListConversationsRequest.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListConversationsRequest.Builder.class) +public final class ListConversationsRequest { + private final Optional perPage; + + private final Optional startingAfter; + + private final Map additionalProperties; + + private ListConversationsRequest( + Optional perPage, Optional startingAfter, Map additionalProperties) { + this.perPage = perPage; + this.startingAfter = startingAfter; + this.additionalProperties = additionalProperties; + } + + /** + * @return How many results per page + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + /** + * @return String used to get the next page of conversations. + */ + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListConversationsRequest && equalTo((ListConversationsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListConversationsRequest other) { + return perPage.equals(other.perPage) && startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.perPage, this.startingAfter); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional perPage = Optional.empty(); + + private Optional startingAfter = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListConversationsRequest other) { + perPage(other.getPerPage()); + startingAfter(other.getStartingAfter()); + return this; + } + + /** + *

How many results per page

+ */ + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public Builder perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + public Builder perPage(Integer perPage) { + this.perPage = Optional.ofNullable(perPage); + return this; + } + + /** + *

String used to get the next page of conversations.

+ */ + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public Builder startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + public Builder startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + public ListConversationsRequest build() { + return new ListConversationsRequest(perPage, startingAfter, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ManageConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ManageConversationRequest.java new file mode 100644 index 0000000..a3a6628 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ManageConversationRequest.java @@ -0,0 +1,136 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.conversations.types.ManageConversationRequestBody; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ManageConversationRequest.Builder.class) +public final class ManageConversationRequest { + private final String id; + + private final ManageConversationRequestBody body; + + private final Map additionalProperties; + + private ManageConversationRequest( + String id, ManageConversationRequestBody body, Map additionalProperties) { + this.id = id; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the conversation as given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("body") + public ManageConversationRequestBody getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ManageConversationRequest && equalTo((ManageConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ManageConversationRequest other) { + return id.equals(other.id) && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The identifier for the conversation as given by Intercom. + */ + BodyStage id(@NotNull String id); + + Builder from(ManageConversationRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull ManageConversationRequestBody body); + } + + public interface _FinalStage { + ManageConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, BodyStage, _FinalStage { + private String id; + + private ManageConversationRequestBody body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ManageConversationRequest other) { + id(other.getId()); + body(other.getBody()); + return this; + } + + /** + * The identifier for the conversation as given by Intercom.

The identifier for the conversation as given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public BodyStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull ManageConversationRequestBody body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public ManageConversationRequest build() { + return new ManageConversationRequest(id, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ReplyConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ReplyConversationRequest.java new file mode 100644 index 0000000..02bfe5f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/ReplyConversationRequest.java @@ -0,0 +1,136 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ReplyConversationRequestBody; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReplyConversationRequest.Builder.class) +public final class ReplyConversationRequest { + private final String id; + + private final ReplyConversationRequestBody body; + + private final Map additionalProperties; + + private ReplyConversationRequest( + String id, ReplyConversationRequestBody body, Map additionalProperties) { + this.id = id; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("body") + public ReplyConversationRequestBody getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReplyConversationRequest && equalTo((ReplyConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReplyConversationRequest other) { + return id.equals(other.id) && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + */ + BodyStage id(@NotNull String id); + + Builder from(ReplyConversationRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull ReplyConversationRequestBody body); + } + + public interface _FinalStage { + ReplyConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, BodyStage, _FinalStage { + private String id; + + private ReplyConversationRequestBody body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReplyConversationRequest other) { + id(other.getId()); + body(other.getBody()); + return this; + } + + /** + * The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation

The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public BodyStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull ReplyConversationRequestBody body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public ReplyConversationRequest build() { + return new ReplyConversationRequest(id, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/RetrieveConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/RetrieveConversationRequest.java new file mode 100644 index 0000000..16a5595 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/RetrieveConversationRequest.java @@ -0,0 +1,154 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveConversationRequest.Builder.class) +public final class RetrieveConversationRequest { + private final int id; + + private final Optional displayAs; + + private final Map additionalProperties; + + private RetrieveConversationRequest(int id, Optional displayAs, Map additionalProperties) { + this.id = id; + this.displayAs = displayAs; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the conversation to target + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return Set to plaintext to retrieve conversation messages in plain text. + */ + @JsonProperty("display_as") + public Optional getDisplayAs() { + return displayAs; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveConversationRequest && equalTo((RetrieveConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveConversationRequest other) { + return id == other.id && displayAs.equals(other.displayAs); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.displayAs); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The id of the conversation to target + */ + _FinalStage id(int id); + + Builder from(RetrieveConversationRequest other); + } + + public interface _FinalStage { + RetrieveConversationRequest build(); + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ + _FinalStage displayAs(Optional displayAs); + + _FinalStage displayAs(String displayAs); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + private Optional displayAs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveConversationRequest other) { + id(other.getId()); + displayAs(other.getDisplayAs()); + return this; + } + + /** + * The id of the conversation to target

The id of the conversation to target

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage displayAs(String displayAs) { + this.displayAs = Optional.ofNullable(displayAs); + return this; + } + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ + @java.lang.Override + @JsonSetter(value = "display_as", nulls = Nulls.SKIP) + public _FinalStage displayAs(Optional displayAs) { + this.displayAs = displayAs; + return this; + } + + @java.lang.Override + public RetrieveConversationRequest build() { + return new RetrieveConversationRequest(id, displayAs, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/requests/UpdateConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/UpdateConversationRequest.java new file mode 100644 index 0000000..b3d50e2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/requests/UpdateConversationRequest.java @@ -0,0 +1,386 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.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.resources.unstable.types.CustomObjectInstanceList; +import com.intercom.api.resources.unstable.types.Datetime; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateConversationRequest.Builder.class) +public final class UpdateConversationRequest { + private final int id; + + private final Optional displayAs; + + private final Optional read; + + private final Optional title; + + private final Optional> customAttributes; + + private final Map additionalProperties; + + private UpdateConversationRequest( + int id, + Optional displayAs, + Optional read, + Optional title, + Optional> customAttributes, + Map additionalProperties) { + this.id = id; + this.displayAs = displayAs; + this.read = read; + this.title = title; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the conversation to target + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return Set to plaintext to retrieve conversation messages in plain text. + */ + @JsonProperty("display_as") + public Optional getDisplayAs() { + return displayAs; + } + + /** + * @return Mark a conversation as read within Intercom. + */ + @JsonProperty("read") + public Optional getRead() { + return read; + } + + /** + * @return The title given to the conversation + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateConversationRequest && equalTo((UpdateConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateConversationRequest other) { + return id == other.id + && displayAs.equals(other.displayAs) + && read.equals(other.read) + && title.equals(other.title) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.displayAs, this.read, this.title, this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The id of the conversation to target + */ + _FinalStage id(int id); + + Builder from(UpdateConversationRequest other); + } + + public interface _FinalStage { + UpdateConversationRequest build(); + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ + _FinalStage displayAs(Optional displayAs); + + _FinalStage displayAs(String displayAs); + + /** + *

Mark a conversation as read within Intercom.

+ */ + _FinalStage read(Optional read); + + _FinalStage read(Boolean read); + + /** + *

The title given to the conversation

+ */ + _FinalStage title(Optional title); + + _FinalStage title(String title); + + _FinalStage customAttributes(Optional> customAttributes); + + _FinalStage customAttributes(Map customAttributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + private Optional> customAttributes = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional read = Optional.empty(); + + private Optional displayAs = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateConversationRequest other) { + id(other.getId()); + displayAs(other.getDisplayAs()); + read(other.getRead()); + title(other.getTitle()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + * The id of the conversation to target

The id of the conversation to target

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public _FinalStage customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + /** + *

The title given to the conversation

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

The title given to the conversation

+ */ + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + /** + *

Mark a conversation as read within Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage read(Boolean read) { + this.read = Optional.ofNullable(read); + return this; + } + + /** + *

Mark a conversation as read within Intercom.

+ */ + @java.lang.Override + @JsonSetter(value = "read", nulls = Nulls.SKIP) + public _FinalStage read(Optional read) { + this.read = read; + return this; + } + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage displayAs(String displayAs) { + this.displayAs = Optional.ofNullable(displayAs); + return this; + } + + /** + *

Set to plaintext to retrieve conversation messages in plain text.

+ */ + @java.lang.Override + @JsonSetter(value = "display_as", nulls = Nulls.SKIP) + public _FinalStage displayAs(Optional displayAs) { + this.displayAs = displayAs; + return this; + } + + @java.lang.Override + public UpdateConversationRequest build() { + return new UpdateConversationRequest(id, displayAs, read, title, customAttributes, additionalProperties); + } + } + + @JsonDeserialize(using = CustomAttributesValue.Deserializer.class) + public static final class CustomAttributesValue { + private final Object value; + + private final int type; + + private CustomAttributesValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((int) this.value); + } else if (this.type == 2) { + return visitor.visit((Datetime) this.value); + } else if (this.type == 3) { + return visitor.visit((CustomObjectInstanceList) 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 CustomAttributesValue && equalTo((CustomAttributesValue) other); + } + + private boolean equalTo(CustomAttributesValue 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 CustomAttributesValue of(String value) { + return new CustomAttributesValue(value, 0); + } + + public static CustomAttributesValue of(int value) { + return new CustomAttributesValue(value, 1); + } + + public static CustomAttributesValue of(Datetime value) { + return new CustomAttributesValue(value, 2); + } + + public static CustomAttributesValue of(CustomObjectInstanceList value) { + return new CustomAttributesValue(value, 3); + } + + public interface Visitor { + T visit(String value); + + T visit(int value); + + T visit(Datetime value); + + T visit(CustomObjectInstanceList value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(CustomAttributesValue.class); + } + + @java.lang.Override + public CustomAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + if (value instanceof Integer) { + return of((Integer) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Datetime.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomObjectInstanceList.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/types/Conversation.java b/src/main/java/com/intercom/api/resources/unstable/conversations/types/Conversation.java new file mode 100644 index 0000000..4cebaef --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/types/Conversation.java @@ -0,0 +1,1118 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.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.resources.unstable.aiagent.types.AiAgent; +import com.intercom.api.resources.unstable.types.ConversationContacts; +import com.intercom.api.resources.unstable.types.ConversationFirstContactReply; +import com.intercom.api.resources.unstable.types.ConversationParts; +import com.intercom.api.resources.unstable.types.ConversationRating; +import com.intercom.api.resources.unstable.types.ConversationSource; +import com.intercom.api.resources.unstable.types.ConversationStatistics; +import com.intercom.api.resources.unstable.types.ConversationTeammates; +import com.intercom.api.resources.unstable.types.CustomObjectInstanceList; +import com.intercom.api.resources.unstable.types.Datetime; +import com.intercom.api.resources.unstable.types.LinkedObjectList; +import com.intercom.api.resources.unstable.types.SlaApplied; +import com.intercom.api.resources.unstable.types.Tags; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Conversation.Builder.class) +public final class Conversation { + private final Optional type; + + private final Optional id; + + private final Optional title; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional waitingSince; + + private final Optional snoozedUntil; + + private final Optional open; + + private final Optional state; + + private final Optional read; + + private final Optional priority; + + private final Optional adminAssigneeId; + + private final Optional teamAssigneeId; + + private final Optional tags; + + private final Optional conversationRating; + + private final Optional source; + + private final Optional contacts; + + private final Optional teammates; + + private final Optional> customAttributes; + + private final Optional firstContactReply; + + private final Optional slaApplied; + + private final Optional statistics; + + private final Optional conversationParts; + + private final Optional linkedObjects; + + private final Optional aiAgentParticipated; + + private final Optional aiAgent; + + private final Map additionalProperties; + + private Conversation( + Optional type, + Optional id, + Optional title, + Optional createdAt, + Optional updatedAt, + Optional waitingSince, + Optional snoozedUntil, + Optional open, + Optional state, + Optional read, + Optional priority, + Optional adminAssigneeId, + Optional teamAssigneeId, + Optional tags, + Optional conversationRating, + Optional source, + Optional contacts, + Optional teammates, + Optional> customAttributes, + Optional firstContactReply, + Optional slaApplied, + Optional statistics, + Optional conversationParts, + Optional linkedObjects, + Optional aiAgentParticipated, + Optional aiAgent, + Map additionalProperties) { + this.type = type; + this.id = id; + this.title = title; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.waitingSince = waitingSince; + this.snoozedUntil = snoozedUntil; + this.open = open; + this.state = state; + this.read = read; + this.priority = priority; + this.adminAssigneeId = adminAssigneeId; + this.teamAssigneeId = teamAssigneeId; + this.tags = tags; + this.conversationRating = conversationRating; + this.source = source; + this.contacts = contacts; + this.teammates = teammates; + this.customAttributes = customAttributes; + this.firstContactReply = firstContactReply; + this.slaApplied = slaApplied; + this.statistics = statistics; + this.conversationParts = conversationParts; + this.linkedObjects = linkedObjects; + this.aiAgentParticipated = aiAgentParticipated; + this.aiAgent = aiAgent; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always conversation. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id representing the conversation. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The title given to the conversation. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The time the conversation was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the conversation was updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. + */ + @JsonProperty("waiting_since") + public Optional getWaitingSince() { + return waitingSince; + } + + /** + * @return If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. + */ + @JsonProperty("snoozed_until") + public Optional getSnoozedUntil() { + return snoozedUntil; + } + + /** + * @return Indicates whether a conversation is open (true) or closed (false). + */ + @JsonProperty("open") + public Optional getOpen() { + return open; + } + + /** + * @return Can be set to "open", "closed" or "snoozed". + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return Indicates whether a conversation has been read. + */ + @JsonProperty("read") + public Optional getRead() { + return read; + } + + /** + * @return If marked as priority, it will return priority or else not_priority. + */ + @JsonProperty("priority") + public Optional getPriority() { + return priority; + } + + /** + * @return The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. + */ + @JsonProperty("admin_assignee_id") + public Optional getAdminAssigneeId() { + return adminAssigneeId; + } + + /** + * @return The id of the team assigned to the conversation. If it's not assigned to a team it will return null. + */ + @JsonProperty("team_assignee_id") + public Optional getTeamAssigneeId() { + return teamAssigneeId; + } + + @JsonProperty("tags") + public Optional getTags() { + return tags; + } + + @JsonProperty("conversation_rating") + public Optional getConversationRating() { + return conversationRating; + } + + @JsonProperty("source") + public Optional getSource() { + return source; + } + + @JsonProperty("contacts") + public Optional getContacts() { + return contacts; + } + + @JsonProperty("teammates") + public Optional getTeammates() { + return teammates; + } + + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @JsonProperty("first_contact_reply") + public Optional getFirstContactReply() { + return firstContactReply; + } + + @JsonProperty("sla_applied") + public Optional getSlaApplied() { + return slaApplied; + } + + @JsonProperty("statistics") + public Optional getStatistics() { + return statistics; + } + + @JsonProperty("conversation_parts") + public Optional getConversationParts() { + return conversationParts; + } + + @JsonProperty("linked_objects") + public Optional getLinkedObjects() { + return linkedObjects; + } + + /** + * @return Indicates whether the AI Agent participated in the conversation. + */ + @JsonProperty("ai_agent_participated") + public Optional getAiAgentParticipated() { + return aiAgentParticipated; + } + + @JsonProperty("ai_agent") + public Optional getAiAgent() { + return aiAgent; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Conversation && equalTo((Conversation) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Conversation other) { + return type.equals(other.type) + && id.equals(other.id) + && title.equals(other.title) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && waitingSince.equals(other.waitingSince) + && snoozedUntil.equals(other.snoozedUntil) + && open.equals(other.open) + && state.equals(other.state) + && read.equals(other.read) + && priority.equals(other.priority) + && adminAssigneeId.equals(other.adminAssigneeId) + && teamAssigneeId.equals(other.teamAssigneeId) + && tags.equals(other.tags) + && conversationRating.equals(other.conversationRating) + && source.equals(other.source) + && contacts.equals(other.contacts) + && teammates.equals(other.teammates) + && customAttributes.equals(other.customAttributes) + && firstContactReply.equals(other.firstContactReply) + && slaApplied.equals(other.slaApplied) + && statistics.equals(other.statistics) + && conversationParts.equals(other.conversationParts) + && linkedObjects.equals(other.linkedObjects) + && aiAgentParticipated.equals(other.aiAgentParticipated) + && aiAgent.equals(other.aiAgent); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.title, + this.createdAt, + this.updatedAt, + this.waitingSince, + this.snoozedUntil, + this.open, + this.state, + this.read, + this.priority, + this.adminAssigneeId, + this.teamAssigneeId, + this.tags, + this.conversationRating, + this.source, + this.contacts, + this.teammates, + this.customAttributes, + this.firstContactReply, + this.slaApplied, + this.statistics, + this.conversationParts, + this.linkedObjects, + this.aiAgentParticipated, + this.aiAgent); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional waitingSince = Optional.empty(); + + private Optional snoozedUntil = Optional.empty(); + + private Optional open = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional read = Optional.empty(); + + private Optional priority = Optional.empty(); + + private Optional adminAssigneeId = Optional.empty(); + + private Optional teamAssigneeId = Optional.empty(); + + private Optional tags = Optional.empty(); + + private Optional conversationRating = Optional.empty(); + + private Optional source = Optional.empty(); + + private Optional contacts = Optional.empty(); + + private Optional teammates = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional firstContactReply = Optional.empty(); + + private Optional slaApplied = Optional.empty(); + + private Optional statistics = Optional.empty(); + + private Optional conversationParts = Optional.empty(); + + private Optional linkedObjects = Optional.empty(); + + private Optional aiAgentParticipated = Optional.empty(); + + private Optional aiAgent = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Conversation other) { + type(other.getType()); + id(other.getId()); + title(other.getTitle()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + waitingSince(other.getWaitingSince()); + snoozedUntil(other.getSnoozedUntil()); + open(other.getOpen()); + state(other.getState()); + read(other.getRead()); + priority(other.getPriority()); + adminAssigneeId(other.getAdminAssigneeId()); + teamAssigneeId(other.getTeamAssigneeId()); + tags(other.getTags()); + conversationRating(other.getConversationRating()); + source(other.getSource()); + contacts(other.getContacts()); + teammates(other.getTeammates()); + customAttributes(other.getCustomAttributes()); + firstContactReply(other.getFirstContactReply()); + slaApplied(other.getSlaApplied()); + statistics(other.getStatistics()); + conversationParts(other.getConversationParts()); + linkedObjects(other.getLinkedObjects()); + aiAgentParticipated(other.getAiAgentParticipated()); + aiAgent(other.getAiAgent()); + return this; + } + + /** + *

Always conversation.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id representing the conversation.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The title given to the conversation.

+ */ + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

The time the conversation was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The last time the conversation was updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin.

+ */ + @JsonSetter(value = "waiting_since", nulls = Nulls.SKIP) + public Builder waitingSince(Optional waitingSince) { + this.waitingSince = waitingSince; + return this; + } + + public Builder waitingSince(Integer waitingSince) { + this.waitingSince = Optional.ofNullable(waitingSince); + return this; + } + + /** + *

If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time.

+ */ + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public Builder snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; + return this; + } + + public Builder snoozedUntil(Integer snoozedUntil) { + this.snoozedUntil = Optional.ofNullable(snoozedUntil); + return this; + } + + /** + *

Indicates whether a conversation is open (true) or closed (false).

+ */ + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public Builder open(Optional open) { + this.open = open; + return this; + } + + public Builder open(Boolean open) { + this.open = Optional.ofNullable(open); + return this; + } + + /** + *

Can be set to "open", "closed" or "snoozed".

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(State state) { + this.state = Optional.ofNullable(state); + return this; + } + + /** + *

Indicates whether a conversation has been read.

+ */ + @JsonSetter(value = "read", nulls = Nulls.SKIP) + public Builder read(Optional read) { + this.read = read; + return this; + } + + public Builder read(Boolean read) { + this.read = Optional.ofNullable(read); + return this; + } + + /** + *

If marked as priority, it will return priority or else not_priority.

+ */ + @JsonSetter(value = "priority", nulls = Nulls.SKIP) + public Builder priority(Optional priority) { + this.priority = priority; + return this; + } + + public Builder priority(Priority priority) { + this.priority = Optional.ofNullable(priority); + return this; + } + + /** + *

The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null.

+ */ + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; + return this; + } + + public Builder adminAssigneeId(Integer adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + return this; + } + + /** + *

The id of the team assigned to the conversation. If it's not assigned to a team it will return null.

+ */ + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; + return this; + } + + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + return this; + } + + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; + return this; + } + + public Builder tags(Tags tags) { + this.tags = Optional.ofNullable(tags); + return this; + } + + @JsonSetter(value = "conversation_rating", nulls = Nulls.SKIP) + public Builder conversationRating(Optional conversationRating) { + this.conversationRating = conversationRating; + return this; + } + + public Builder conversationRating(ConversationRating conversationRating) { + this.conversationRating = Optional.ofNullable(conversationRating); + return this; + } + + @JsonSetter(value = "source", nulls = Nulls.SKIP) + public Builder source(Optional source) { + this.source = source; + return this; + } + + public Builder source(ConversationSource source) { + this.source = Optional.ofNullable(source); + return this; + } + + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional contacts) { + this.contacts = contacts; + return this; + } + + public Builder contacts(ConversationContacts contacts) { + this.contacts = Optional.ofNullable(contacts); + return this; + } + + @JsonSetter(value = "teammates", nulls = Nulls.SKIP) + public Builder teammates(Optional teammates) { + this.teammates = teammates; + return this; + } + + public Builder teammates(ConversationTeammates teammates) { + this.teammates = Optional.ofNullable(teammates); + return this; + } + + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + @JsonSetter(value = "first_contact_reply", nulls = Nulls.SKIP) + public Builder firstContactReply(Optional firstContactReply) { + this.firstContactReply = firstContactReply; + return this; + } + + public Builder firstContactReply(ConversationFirstContactReply firstContactReply) { + this.firstContactReply = Optional.ofNullable(firstContactReply); + return this; + } + + @JsonSetter(value = "sla_applied", nulls = Nulls.SKIP) + public Builder slaApplied(Optional slaApplied) { + this.slaApplied = slaApplied; + return this; + } + + public Builder slaApplied(SlaApplied slaApplied) { + this.slaApplied = Optional.ofNullable(slaApplied); + return this; + } + + @JsonSetter(value = "statistics", nulls = Nulls.SKIP) + public Builder statistics(Optional statistics) { + this.statistics = statistics; + return this; + } + + public Builder statistics(ConversationStatistics statistics) { + this.statistics = Optional.ofNullable(statistics); + return this; + } + + @JsonSetter(value = "conversation_parts", nulls = Nulls.SKIP) + public Builder conversationParts(Optional conversationParts) { + this.conversationParts = conversationParts; + return this; + } + + public Builder conversationParts(ConversationParts conversationParts) { + this.conversationParts = Optional.ofNullable(conversationParts); + return this; + } + + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public Builder linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; + return this; + } + + public Builder linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); + return this; + } + + /** + *

Indicates whether the AI Agent participated in the conversation.

+ */ + @JsonSetter(value = "ai_agent_participated", nulls = Nulls.SKIP) + public Builder aiAgentParticipated(Optional aiAgentParticipated) { + this.aiAgentParticipated = aiAgentParticipated; + return this; + } + + public Builder aiAgentParticipated(Boolean aiAgentParticipated) { + this.aiAgentParticipated = Optional.ofNullable(aiAgentParticipated); + return this; + } + + @JsonSetter(value = "ai_agent", nulls = Nulls.SKIP) + public Builder aiAgent(Optional aiAgent) { + this.aiAgent = aiAgent; + return this; + } + + public Builder aiAgent(AiAgent aiAgent) { + this.aiAgent = Optional.ofNullable(aiAgent); + return this; + } + + public Conversation build() { + return new Conversation( + type, + id, + title, + createdAt, + updatedAt, + waitingSince, + snoozedUntil, + open, + state, + read, + priority, + adminAssigneeId, + teamAssigneeId, + tags, + conversationRating, + source, + contacts, + teammates, + customAttributes, + firstContactReply, + slaApplied, + statistics, + conversationParts, + linkedObjects, + aiAgentParticipated, + aiAgent, + additionalProperties); + } + } + + public static final class State { + public static final State SNOOZED = new State(Value.SNOOZED, "snoozed"); + + public static final State CLOSED = new State(Value.CLOSED, "closed"); + + public static final State OPEN = new State(Value.OPEN, "open"); + + private final Value value; + + private final String string; + + State(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof State && this.string.equals(((State) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case SNOOZED: + return visitor.visitSnoozed(); + case CLOSED: + return visitor.visitClosed(); + case OPEN: + return visitor.visitOpen(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "snoozed": + return SNOOZED; + case "closed": + return CLOSED; + case "open": + return OPEN; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + OPEN, + + CLOSED, + + SNOOZED, + + UNKNOWN + } + + public interface Visitor { + T visitOpen(); + + T visitClosed(); + + T visitSnoozed(); + + T visitUnknown(String unknownType); + } + } + + public static final class Priority { + public static final Priority PRIORITY = new Priority(Value.PRIORITY, "priority"); + + public static final Priority NOT_PRIORITY = new Priority(Value.NOT_PRIORITY, "not_priority"); + + private final Value value; + + private final String string; + + Priority(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Priority && this.string.equals(((Priority) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PRIORITY: + return visitor.visitPriority(); + case NOT_PRIORITY: + return visitor.visitNotPriority(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Priority valueOf(String value) { + switch (value) { + case "priority": + return PRIORITY; + case "not_priority": + return NOT_PRIORITY; + default: + return new Priority(Value.UNKNOWN, value); + } + } + + public enum Value { + PRIORITY, + + NOT_PRIORITY, + + UNKNOWN + } + + public interface Visitor { + T visitPriority(); + + T visitNotPriority(); + + T visitUnknown(String unknownType); + } + } + + @JsonDeserialize(using = CustomAttributesValue.Deserializer.class) + public static final class CustomAttributesValue { + private final Object value; + + private final int type; + + private CustomAttributesValue(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((int) this.value); + } else if (this.type == 2) { + return visitor.visit((Datetime) this.value); + } else if (this.type == 3) { + return visitor.visit((CustomObjectInstanceList) 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 CustomAttributesValue && equalTo((CustomAttributesValue) other); + } + + private boolean equalTo(CustomAttributesValue 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 CustomAttributesValue of(String value) { + return new CustomAttributesValue(value, 0); + } + + public static CustomAttributesValue of(int value) { + return new CustomAttributesValue(value, 1); + } + + public static CustomAttributesValue of(Datetime value) { + return new CustomAttributesValue(value, 2); + } + + public static CustomAttributesValue of(CustomObjectInstanceList value) { + return new CustomAttributesValue(value, 3); + } + + public interface Visitor { + T visit(String value); + + T visit(int value); + + T visit(Datetime value); + + T visit(CustomObjectInstanceList value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(CustomAttributesValue.class); + } + + @java.lang.Override + public CustomAttributesValue deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + if (value instanceof Integer) { + return of((Integer) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Datetime.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomObjectInstanceList.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/conversations/types/ManageConversationRequestBody.java b/src/main/java/com/intercom/api/resources/unstable/conversations/types/ManageConversationRequestBody.java new file mode 100644 index 0000000..faed384 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/conversations/types/ManageConversationRequestBody.java @@ -0,0 +1,328 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.conversations.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.resources.unstable.types.AssignConversationRequest; +import com.intercom.api.resources.unstable.types.CloseConversationRequest; +import com.intercom.api.resources.unstable.types.OpenConversationRequest; +import com.intercom.api.resources.unstable.types.SnoozeConversationRequest; +import java.util.Objects; +import java.util.Optional; + +public final class ManageConversationRequestBody { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private ManageConversationRequestBody(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static ManageConversationRequestBody close(CloseConversationRequest value) { + return new ManageConversationRequestBody(new CloseValue(value)); + } + + public static ManageConversationRequestBody snoozed(SnoozeConversationRequest value) { + return new ManageConversationRequestBody(new SnoozedValue(value)); + } + + public static ManageConversationRequestBody open(OpenConversationRequest value) { + return new ManageConversationRequestBody(new OpenValue(value)); + } + + public static ManageConversationRequestBody assignment(AssignConversationRequest value) { + return new ManageConversationRequestBody(new AssignmentValue(value)); + } + + public boolean isClose() { + return value instanceof CloseValue; + } + + public boolean isSnoozed() { + return value instanceof SnoozedValue; + } + + public boolean isOpen() { + return value instanceof OpenValue; + } + + public boolean isAssignment() { + return value instanceof AssignmentValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getClose() { + if (isClose()) { + return Optional.of(((CloseValue) value).value); + } + return Optional.empty(); + } + + public Optional getSnoozed() { + if (isSnoozed()) { + return Optional.of(((SnoozedValue) value).value); + } + return Optional.empty(); + } + + public Optional getOpen() { + if (isOpen()) { + return Optional.of(((OpenValue) value).value); + } + return Optional.empty(); + } + + public Optional getAssignment() { + if (isAssignment()) { + return Optional.of(((AssignmentValue) 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 visitClose(CloseConversationRequest close); + + T visitSnoozed(SnoozeConversationRequest snoozed); + + T visitOpen(OpenConversationRequest open); + + T visitAssignment(AssignConversationRequest assignment); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "message_type", + visible = true, + defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(CloseValue.class), + @JsonSubTypes.Type(SnoozedValue.class), + @JsonSubTypes.Type(OpenValue.class), + @JsonSubTypes.Type(AssignmentValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("close") + @JsonIgnoreProperties("message_type") + private static final class CloseValue implements Value { + @JsonUnwrapped + private CloseConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private CloseValue() {} + + private CloseValue(CloseConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitClose(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CloseValue && equalTo((CloseValue) other); + } + + private boolean equalTo(CloseValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ManageConversationRequestBody{" + "value: " + value + "}"; + } + } + + @JsonTypeName("snoozed") + @JsonIgnoreProperties("message_type") + private static final class SnoozedValue implements Value { + @JsonUnwrapped + private SnoozeConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private SnoozedValue() {} + + private SnoozedValue(SnoozeConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitSnoozed(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SnoozedValue && equalTo((SnoozedValue) other); + } + + private boolean equalTo(SnoozedValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ManageConversationRequestBody{" + "value: " + value + "}"; + } + } + + @JsonTypeName("open") + @JsonIgnoreProperties("message_type") + private static final class OpenValue implements Value { + @JsonUnwrapped + private OpenConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private OpenValue() {} + + private OpenValue(OpenConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitOpen(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OpenValue && equalTo((OpenValue) other); + } + + private boolean equalTo(OpenValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ManageConversationRequestBody{" + "value: " + value + "}"; + } + } + + @JsonTypeName("assignment") + @JsonIgnoreProperties("message_type") + private static final class AssignmentValue implements Value { + @JsonUnwrapped + private AssignConversationRequest value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private AssignmentValue() {} + + private AssignmentValue(AssignConversationRequest value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitAssignment(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AssignmentValue && equalTo((AssignmentValue) other); + } + + private boolean equalTo(AssignmentValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ManageConversationRequestBody{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("message_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 "ManageConversationRequestBody{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customchannelevents/AsyncCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/AsyncCustomChannelEventsClient.java new file mode 100644 index 0000000..746c16d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/AsyncCustomChannelEventsClient.java @@ -0,0 +1,117 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customchannelevents; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.resources.unstable.types.CustomChannelBaseEvent; +import com.intercom.api.resources.unstable.types.CustomChannelNotificationResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncCustomChannelEventsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCustomChannelEventsClient rawClient; + + public AsyncCustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCustomChannelEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCustomChannelEventsClient withRawResponse() { + return this.rawClient; + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyNewConversation(CustomChannelBaseEvent request) { + return this.rawClient.notifyNewConversation(request).thenApply(response -> response.body()); + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + return this.rawClient.notifyNewConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyNewMessage(NotifyNewMessageRequest request) { + return this.rawClient.notifyNewMessage(request).thenApply(response -> response.body()); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyNewMessage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request) { + return this.rawClient.notifyQuickReplySelected(request).thenApply(response -> response.body()); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyQuickReplySelected(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyAttributeCollected( + NotifyAttributeCollectedRequest request) { + return this.rawClient.notifyAttributeCollected(request).thenApply(response -> response.body()); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyAttributeCollected(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customchannelevents/AsyncRawCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/AsyncRawCustomChannelEventsClient.java new file mode 100644 index 0000000..6417fe5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/AsyncRawCustomChannelEventsClient.java @@ -0,0 +1,439 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customchannelevents; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.types.CustomChannelBaseEvent; +import com.intercom.api.resources.unstable.types.CustomChannelNotificationResponse; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCustomChannelEventsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyNewConversation( + CustomChannelBaseEvent request) { + return notifyNewConversation(request, null); + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_conversation") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyNewMessage( + NotifyNewMessageRequest request) { + return notifyNewMessage(request, null); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_message") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request) { + return notifyQuickReplySelected(request, null); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_quick_reply_selected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyAttributeCollected( + NotifyAttributeCollectedRequest request) { + return notifyAttributeCollected(request, null); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CompletableFuture> notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_attribute_collected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CustomChannelNotificationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customchannelevents/CustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/CustomChannelEventsClient.java new file mode 100644 index 0000000..ed2a4b9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/CustomChannelEventsClient.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customchannelevents; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.resources.unstable.types.CustomChannelBaseEvent; +import com.intercom.api.resources.unstable.types.CustomChannelNotificationResponse; + +public class CustomChannelEventsClient { + protected final ClientOptions clientOptions; + + private final RawCustomChannelEventsClient rawClient; + + public CustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCustomChannelEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCustomChannelEventsClient withRawResponse() { + return this.rawClient; + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyNewConversation(CustomChannelBaseEvent request) { + return this.rawClient.notifyNewConversation(request).body(); + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + return this.rawClient.notifyNewConversation(request, requestOptions).body(); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyNewMessage(NotifyNewMessageRequest request) { + return this.rawClient.notifyNewMessage(request).body(); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyNewMessage(request, requestOptions).body(); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyQuickReplySelected(NotifyQuickReplySelectedRequest request) { + return this.rawClient.notifyQuickReplySelected(request).body(); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyQuickReplySelected(request, requestOptions).body(); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyAttributeCollected(NotifyAttributeCollectedRequest request) { + return this.rawClient.notifyAttributeCollected(request).body(); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public CustomChannelNotificationResponse notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyAttributeCollected(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customchannelevents/RawCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/RawCustomChannelEventsClient.java new file mode 100644 index 0000000..ef0f670 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/RawCustomChannelEventsClient.java @@ -0,0 +1,350 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customchannelevents; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.unstable.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.types.CustomChannelBaseEvent; +import com.intercom.api.resources.unstable.types.CustomChannelNotificationResponse; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCustomChannelEventsClient { + protected final ClientOptions clientOptions; + + public RawCustomChannelEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyNewConversation( + CustomChannelBaseEvent request) { + return notifyNewConversation(request, null); + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyNewConversation( + CustomChannelBaseEvent request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_conversation") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyNewMessage(NotifyNewMessageRequest request) { + return notifyNewMessage(request, null); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyNewMessage( + NotifyNewMessageRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_new_message") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request) { + return notifyQuickReplySelected(request, null); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyQuickReplySelected( + NotifyQuickReplySelectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_quick_reply_selected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyAttributeCollected( + NotifyAttributeCollectedRequest request) { + return notifyAttributeCollected(request, null); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + *
+ *

Note: This endpoint is restricted to customers with access to the closed beta for "Fin over API".

+ *
+ */ + public IntercomHttpResponse notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_channel_events/notify_attribute_collected") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CustomChannelNotificationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyAttributeCollectedRequest.java b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyAttributeCollectedRequest.java new file mode 100644 index 0000000..2d2984a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyAttributeCollectedRequest.java @@ -0,0 +1,202 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customchannelevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.CustomChannelAttribute; +import com.intercom.api.resources.unstable.types.CustomChannelContact; +import com.intercom.api.resources.unstable.types.ICustomChannelBaseEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NotifyAttributeCollectedRequest.Builder.class) +public final class NotifyAttributeCollectedRequest implements ICustomChannelBaseEvent { + private final String eventId; + + private final String externalConversationId; + + private final CustomChannelContact contact; + + private final CustomChannelAttribute attribute; + + private final Map additionalProperties; + + private NotifyAttributeCollectedRequest( + String eventId, + String externalConversationId, + CustomChannelContact contact, + CustomChannelAttribute attribute, + Map additionalProperties) { + this.eventId = eventId; + this.externalConversationId = externalConversationId; + this.contact = contact; + this.attribute = attribute; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier for the event. + */ + @JsonProperty("event_id") + public String getEventId() { + return eventId; + } + + /** + * @return Identifier for the conversation in your application. + */ + @JsonProperty("external_conversation_id") + public String getExternalConversationId() { + return externalConversationId; + } + + @JsonProperty("contact") + public CustomChannelContact getContact() { + return contact; + } + + @JsonProperty("attribute") + public CustomChannelAttribute getAttribute() { + return attribute; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NotifyAttributeCollectedRequest && equalTo((NotifyAttributeCollectedRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NotifyAttributeCollectedRequest other) { + return eventId.equals(other.eventId) + && externalConversationId.equals(other.externalConversationId) + && contact.equals(other.contact) + && attribute.equals(other.attribute); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventId, this.externalConversationId, this.contact, this.attribute); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventIdStage builder() { + return new Builder(); + } + + public interface EventIdStage { + /** + * Unique identifier for the event. + */ + ExternalConversationIdStage eventId(@NotNull String eventId); + + Builder from(NotifyAttributeCollectedRequest other); + } + + public interface ExternalConversationIdStage { + /** + * Identifier for the conversation in your application. + */ + ContactStage externalConversationId(@NotNull String externalConversationId); + } + + public interface ContactStage { + AttributeStage contact(@NotNull CustomChannelContact contact); + } + + public interface AttributeStage { + _FinalStage attribute(@NotNull CustomChannelAttribute attribute); + } + + public interface _FinalStage { + NotifyAttributeCollectedRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EventIdStage, ExternalConversationIdStage, ContactStage, AttributeStage, _FinalStage { + private String eventId; + + private String externalConversationId; + + private CustomChannelContact contact; + + private CustomChannelAttribute attribute; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NotifyAttributeCollectedRequest other) { + eventId(other.getEventId()); + externalConversationId(other.getExternalConversationId()); + contact(other.getContact()); + attribute(other.getAttribute()); + return this; + } + + /** + * Unique identifier for the event.

Unique identifier for the event.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_id") + public ExternalConversationIdStage eventId(@NotNull String eventId) { + this.eventId = Objects.requireNonNull(eventId, "eventId must not be null"); + return this; + } + + /** + * Identifier for the conversation in your application.

Identifier for the conversation in your application.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_conversation_id") + public ContactStage externalConversationId(@NotNull String externalConversationId) { + this.externalConversationId = + Objects.requireNonNull(externalConversationId, "externalConversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contact") + public AttributeStage contact(@NotNull CustomChannelContact contact) { + this.contact = Objects.requireNonNull(contact, "contact must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("attribute") + public _FinalStage attribute(@NotNull CustomChannelAttribute attribute) { + this.attribute = Objects.requireNonNull(attribute, "attribute must not be null"); + return this; + } + + @java.lang.Override + public NotifyAttributeCollectedRequest build() { + return new NotifyAttributeCollectedRequest( + eventId, externalConversationId, contact, attribute, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyNewMessageRequest.java b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyNewMessageRequest.java new file mode 100644 index 0000000..9e2f6ba --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyNewMessageRequest.java @@ -0,0 +1,210 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customchannelevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.CustomChannelContact; +import com.intercom.api.resources.unstable.types.ICustomChannelBaseEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NotifyNewMessageRequest.Builder.class) +public final class NotifyNewMessageRequest implements ICustomChannelBaseEvent { + private final String eventId; + + private final String externalConversationId; + + private final CustomChannelContact contact; + + private final String body; + + private final Map additionalProperties; + + private NotifyNewMessageRequest( + String eventId, + String externalConversationId, + CustomChannelContact contact, + String body, + Map additionalProperties) { + this.eventId = eventId; + this.externalConversationId = externalConversationId; + this.contact = contact; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier for the event. + */ + @JsonProperty("event_id") + public String getEventId() { + return eventId; + } + + /** + * @return Identifier for the conversation in your application. + */ + @JsonProperty("external_conversation_id") + public String getExternalConversationId() { + return externalConversationId; + } + + @JsonProperty("contact") + public CustomChannelContact getContact() { + return contact; + } + + /** + * @return The message content sent by the user. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NotifyNewMessageRequest && equalTo((NotifyNewMessageRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NotifyNewMessageRequest other) { + return eventId.equals(other.eventId) + && externalConversationId.equals(other.externalConversationId) + && contact.equals(other.contact) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventId, this.externalConversationId, this.contact, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventIdStage builder() { + return new Builder(); + } + + public interface EventIdStage { + /** + * Unique identifier for the event. + */ + ExternalConversationIdStage eventId(@NotNull String eventId); + + Builder from(NotifyNewMessageRequest other); + } + + public interface ExternalConversationIdStage { + /** + * Identifier for the conversation in your application. + */ + ContactStage externalConversationId(@NotNull String externalConversationId); + } + + public interface ContactStage { + BodyStage contact(@NotNull CustomChannelContact contact); + } + + public interface BodyStage { + /** + * The message content sent by the user. + */ + _FinalStage body(@NotNull String body); + } + + public interface _FinalStage { + NotifyNewMessageRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EventIdStage, ExternalConversationIdStage, ContactStage, BodyStage, _FinalStage { + private String eventId; + + private String externalConversationId; + + private CustomChannelContact contact; + + private String body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NotifyNewMessageRequest other) { + eventId(other.getEventId()); + externalConversationId(other.getExternalConversationId()); + contact(other.getContact()); + body(other.getBody()); + return this; + } + + /** + * Unique identifier for the event.

Unique identifier for the event.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_id") + public ExternalConversationIdStage eventId(@NotNull String eventId) { + this.eventId = Objects.requireNonNull(eventId, "eventId must not be null"); + return this; + } + + /** + * Identifier for the conversation in your application.

Identifier for the conversation in your application.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_conversation_id") + public ContactStage externalConversationId(@NotNull String externalConversationId) { + this.externalConversationId = + Objects.requireNonNull(externalConversationId, "externalConversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contact") + public BodyStage contact(@NotNull CustomChannelContact contact) { + this.contact = Objects.requireNonNull(contact, "contact must not be null"); + return this; + } + + /** + * The message content sent by the user.

The message content sent by the user.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull String body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public NotifyNewMessageRequest build() { + return new NotifyNewMessageRequest(eventId, externalConversationId, contact, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyQuickReplySelectedRequest.java b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyQuickReplySelectedRequest.java new file mode 100644 index 0000000..64b3ab1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customchannelevents/requests/NotifyQuickReplySelectedRequest.java @@ -0,0 +1,211 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customchannelevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.CustomChannelContact; +import com.intercom.api.resources.unstable.types.ICustomChannelBaseEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NotifyQuickReplySelectedRequest.Builder.class) +public final class NotifyQuickReplySelectedRequest implements ICustomChannelBaseEvent { + private final String eventId; + + private final String externalConversationId; + + private final CustomChannelContact contact; + + private final String quickReplyOptionId; + + private final Map additionalProperties; + + private NotifyQuickReplySelectedRequest( + String eventId, + String externalConversationId, + CustomChannelContact contact, + String quickReplyOptionId, + Map additionalProperties) { + this.eventId = eventId; + this.externalConversationId = externalConversationId; + this.contact = contact; + this.quickReplyOptionId = quickReplyOptionId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier for the event. + */ + @JsonProperty("event_id") + public String getEventId() { + return eventId; + } + + /** + * @return Identifier for the conversation in your application. + */ + @JsonProperty("external_conversation_id") + public String getExternalConversationId() { + return externalConversationId; + } + + @JsonProperty("contact") + public CustomChannelContact getContact() { + return contact; + } + + /** + * @return Id of the selected quick reply option. + */ + @JsonProperty("quick_reply_option_id") + public String getQuickReplyOptionId() { + return quickReplyOptionId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NotifyQuickReplySelectedRequest && equalTo((NotifyQuickReplySelectedRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NotifyQuickReplySelectedRequest other) { + return eventId.equals(other.eventId) + && externalConversationId.equals(other.externalConversationId) + && contact.equals(other.contact) + && quickReplyOptionId.equals(other.quickReplyOptionId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventId, this.externalConversationId, this.contact, this.quickReplyOptionId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventIdStage builder() { + return new Builder(); + } + + public interface EventIdStage { + /** + * Unique identifier for the event. + */ + ExternalConversationIdStage eventId(@NotNull String eventId); + + Builder from(NotifyQuickReplySelectedRequest other); + } + + public interface ExternalConversationIdStage { + /** + * Identifier for the conversation in your application. + */ + ContactStage externalConversationId(@NotNull String externalConversationId); + } + + public interface ContactStage { + QuickReplyOptionIdStage contact(@NotNull CustomChannelContact contact); + } + + public interface QuickReplyOptionIdStage { + /** + * Id of the selected quick reply option. + */ + _FinalStage quickReplyOptionId(@NotNull String quickReplyOptionId); + } + + public interface _FinalStage { + NotifyQuickReplySelectedRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements EventIdStage, ExternalConversationIdStage, ContactStage, QuickReplyOptionIdStage, _FinalStage { + private String eventId; + + private String externalConversationId; + + private CustomChannelContact contact; + + private String quickReplyOptionId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(NotifyQuickReplySelectedRequest other) { + eventId(other.getEventId()); + externalConversationId(other.getExternalConversationId()); + contact(other.getContact()); + quickReplyOptionId(other.getQuickReplyOptionId()); + return this; + } + + /** + * Unique identifier for the event.

Unique identifier for the event.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_id") + public ExternalConversationIdStage eventId(@NotNull String eventId) { + this.eventId = Objects.requireNonNull(eventId, "eventId must not be null"); + return this; + } + + /** + * Identifier for the conversation in your application.

Identifier for the conversation in your application.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_conversation_id") + public ContactStage externalConversationId(@NotNull String externalConversationId) { + this.externalConversationId = + Objects.requireNonNull(externalConversationId, "externalConversationId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("contact") + public QuickReplyOptionIdStage contact(@NotNull CustomChannelContact contact) { + this.contact = Objects.requireNonNull(contact, "contact must not be null"); + return this; + } + + /** + * Id of the selected quick reply option.

Id of the selected quick reply option.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("quick_reply_option_id") + public _FinalStage quickReplyOptionId(@NotNull String quickReplyOptionId) { + this.quickReplyOptionId = Objects.requireNonNull(quickReplyOptionId, "quickReplyOptionId must not be null"); + return this; + } + + @java.lang.Override + public NotifyQuickReplySelectedRequest build() { + return new NotifyQuickReplySelectedRequest( + eventId, externalConversationId, contact, quickReplyOptionId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/AsyncCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/AsyncCustomObjectInstancesClient.java new file mode 100644 index 0000000..f06e90e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/AsyncCustomObjectInstancesClient.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.resources.unstable.types.CustomObjectInstanceDeleted; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncCustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCustomObjectInstancesClient rawClient; + + public AsyncCustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCustomObjectInstancesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCustomObjectInstancesClient withRawResponse() { + return this.rawClient; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.getCustomObjectInstancesByExternalId(request).thenApply(response -> response.body()); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesByExternalId(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return this.rawClient.createCustomObjectInstances(request).thenApply(response -> response.body()); + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + return this.rawClient + .createCustomObjectInstances(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesById(request).thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesById(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request) { + return this.rawClient.getCustomObjectInstancesById(request).thenApply(response -> response.body()); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesById(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesByExternalId(request).thenApply(response -> response.body()); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesByExternalId(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/AsyncRawCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/AsyncRawCustomObjectInstancesClient.java new file mode 100644 index 0000000..be52363 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/AsyncRawCustomObjectInstancesClient.java @@ -0,0 +1,440 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.CustomObjectInstanceDeleted; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture>> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return getCustomObjectInstancesByExternalId(request, null); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public CompletableFuture>> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture>> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return createCustomObjectInstances(request, null); + } + + /** + * Create or update a custom object instance + */ + public CompletableFuture>> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture> deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request) { + return deleteCustomObjectInstancesById(request, null); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CompletableFuture> deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CustomObjectInstanceDeleted.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture>> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request) { + return getCustomObjectInstancesById(request, null); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public CompletableFuture>> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture> deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return deleteCustomObjectInstancesByExternalId(request, null); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CompletableFuture> deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CustomObjectInstanceDeleted.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/CustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/CustomObjectInstancesClient.java new file mode 100644 index 0000000..eeeb0f4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/CustomObjectInstancesClient.java @@ -0,0 +1,121 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.resources.unstable.types.CustomObjectInstanceDeleted; +import java.util.Optional; + +public class CustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + private final RawCustomObjectInstancesClient rawClient; + + public CustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCustomObjectInstancesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCustomObjectInstancesClient withRawResponse() { + return this.rawClient; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public Optional getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.getCustomObjectInstancesByExternalId(request).body(); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public Optional getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesByExternalId(request, requestOptions) + .body(); + } + + /** + * Create or update a custom object instance + */ + public Optional createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return this.rawClient.createCustomObjectInstances(request).body(); + } + + /** + * Create or update a custom object instance + */ + public Optional createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + return this.rawClient + .createCustomObjectInstances(request, requestOptions) + .body(); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesById(request).body(); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesById(request, requestOptions) + .body(); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public Optional getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest request) { + return this.rawClient.getCustomObjectInstancesById(request).body(); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public Optional getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .getCustomObjectInstancesById(request, requestOptions) + .body(); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return this.rawClient.deleteCustomObjectInstancesByExternalId(request).body(); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public CustomObjectInstanceDeleted deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + return this.rawClient + .deleteCustomObjectInstancesByExternalId(request, requestOptions) + .body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/RawCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/RawCustomObjectInstancesClient.java new file mode 100644 index 0000000..58eb804 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/RawCustomObjectInstancesClient.java @@ -0,0 +1,349 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.unstable.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.CustomObjectInstanceDeleted; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCustomObjectInstancesClient { + protected final ClientOptions clientOptions; + + public RawCustomObjectInstancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public IntercomHttpResponse> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request) { + return getCustomObjectInstancesByExternalId(request, null); + } + + /** + * Fetch a Custom Object Instance by external_id. + */ + public IntercomHttpResponse> getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Create or update a custom object instance + */ + public IntercomHttpResponse> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request) { + return createCustomObjectInstances(request, null); + } + + /** + * Create or update a custom object instance + */ + public IntercomHttpResponse> createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request) { + return deleteCustomObjectInstancesById(request, null); + } + + /** + * Delete a single Custom Object instance by external_id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "external_id", request.getExternalId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObjectInstanceDeleted.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Fetch a Custom Object Instance by id. + */ + public IntercomHttpResponse> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request) { + return getCustomObjectInstancesById(request, null); + } + + /** + * Fetch a Custom Object Instance by id. + */ + public IntercomHttpResponse> getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request) { + return deleteCustomObjectInstancesByExternalId(request, null); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + */ + public IntercomHttpResponse deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("custom_object_instances") + .addPathSegment(request.getCustomObjectTypeIdentifier()) + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObjectInstanceDeleted.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java new file mode 100644 index 0000000..e219db8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java @@ -0,0 +1,301 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateOrUpdateCustomObjectInstanceRequest.Builder.class) +public final class CreateOrUpdateCustomObjectInstanceRequest { + private final String customObjectTypeIdentifier; + + private final Optional externalId; + + private final Optional externalCreatedAt; + + private final Optional externalUpdatedAt; + + private final Optional>> customAttributes; + + private final Map additionalProperties; + + private CreateOrUpdateCustomObjectInstanceRequest( + String customObjectTypeIdentifier, + Optional externalId, + Optional externalCreatedAt, + Optional externalUpdatedAt, + Optional>> customAttributes, + Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.externalId = externalId; + this.externalCreatedAt = externalCreatedAt; + this.externalUpdatedAt = externalUpdatedAt; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + /** + * @return A unique identifier for the Custom Object instance in the external system it originated from. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The time when the Custom Object instance was created in the external system it originated from. + */ + @JsonProperty("external_created_at") + public Optional getExternalCreatedAt() { + return externalCreatedAt; + } + + /** + * @return The time when the Custom Object instance was last updated in the external system it originated from. + */ + @JsonProperty("external_updated_at") + public Optional getExternalUpdatedAt() { + return externalUpdatedAt; + } + + /** + * @return The custom attributes which are set for the Custom Object instance. + */ + @JsonProperty("custom_attributes") + public Optional>> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateOrUpdateCustomObjectInstanceRequest + && equalTo((CreateOrUpdateCustomObjectInstanceRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateOrUpdateCustomObjectInstanceRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && externalId.equals(other.externalId) + && externalCreatedAt.equals(other.externalCreatedAt) + && externalUpdatedAt.equals(other.externalUpdatedAt) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.customObjectTypeIdentifier, + this.externalId, + this.externalCreatedAt, + this.externalUpdatedAt, + this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + _FinalStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(CreateOrUpdateCustomObjectInstanceRequest other); + } + + public interface _FinalStage { + CreateOrUpdateCustomObjectInstanceRequest build(); + + /** + *

A unique identifier for the Custom Object instance in the external system it originated from.

+ */ + _FinalStage externalId(Optional externalId); + + _FinalStage externalId(String externalId); + + /** + *

The time when the Custom Object instance was created in the external system it originated from.

+ */ + _FinalStage externalCreatedAt(Optional externalCreatedAt); + + _FinalStage externalCreatedAt(Integer externalCreatedAt); + + /** + *

The time when the Custom Object instance was last updated in the external system it originated from.

+ */ + _FinalStage externalUpdatedAt(Optional externalUpdatedAt); + + _FinalStage externalUpdatedAt(Integer externalUpdatedAt); + + /** + *

The custom attributes which are set for the Custom Object instance.

+ */ + _FinalStage customAttributes(Optional>> customAttributes); + + _FinalStage customAttributes(Map> customAttributes); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, _FinalStage { + private String customObjectTypeIdentifier; + + private Optional>> customAttributes = Optional.empty(); + + private Optional externalUpdatedAt = Optional.empty(); + + private Optional externalCreatedAt = Optional.empty(); + + private Optional externalId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateOrUpdateCustomObjectInstanceRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + externalId(other.getExternalId()); + externalCreatedAt(other.getExternalCreatedAt()); + externalUpdatedAt(other.getExternalUpdatedAt()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

The unique identifier of the custom object type that defines the structure of the custom object instance.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public _FinalStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + /** + *

The custom attributes which are set for the Custom Object instance.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customAttributes(Map> customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + /** + *

The custom attributes which are set for the Custom Object instance.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public _FinalStage customAttributes(Optional>> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + /** + *

The time when the Custom Object instance was last updated in the external system it originated from.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalUpdatedAt(Integer externalUpdatedAt) { + this.externalUpdatedAt = Optional.ofNullable(externalUpdatedAt); + return this; + } + + /** + *

The time when the Custom Object instance was last updated in the external system it originated from.

+ */ + @java.lang.Override + @JsonSetter(value = "external_updated_at", nulls = Nulls.SKIP) + public _FinalStage externalUpdatedAt(Optional externalUpdatedAt) { + this.externalUpdatedAt = externalUpdatedAt; + return this; + } + + /** + *

The time when the Custom Object instance was created in the external system it originated from.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalCreatedAt(Integer externalCreatedAt) { + this.externalCreatedAt = Optional.ofNullable(externalCreatedAt); + return this; + } + + /** + *

The time when the Custom Object instance was created in the external system it originated from.

+ */ + @java.lang.Override + @JsonSetter(value = "external_created_at", nulls = Nulls.SKIP) + public _FinalStage externalCreatedAt(Optional externalCreatedAt) { + this.externalCreatedAt = externalCreatedAt; + return this; + } + + /** + *

A unique identifier for the Custom Object instance in the external system it originated from.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

A unique identifier for the Custom Object instance in the external system it originated from.

+ */ + @java.lang.Override + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public _FinalStage externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + @java.lang.Override + public CreateOrUpdateCustomObjectInstanceRequest build() { + return new CreateOrUpdateCustomObjectInstanceRequest( + customObjectTypeIdentifier, + externalId, + externalCreatedAt, + externalUpdatedAt, + customAttributes, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java new file mode 100644 index 0000000..0cb80dd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java @@ -0,0 +1,148 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteCustomObjectInstancesByExternalIdRequest.Builder.class) +public final class DeleteCustomObjectInstancesByExternalIdRequest { + private final String customObjectTypeIdentifier; + + private final String id; + + private final Map additionalProperties; + + private DeleteCustomObjectInstancesByExternalIdRequest( + String customObjectTypeIdentifier, String id, Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + /** + * @return The Intercom defined id of the custom object instance + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCustomObjectInstancesByExternalIdRequest + && equalTo((DeleteCustomObjectInstancesByExternalIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCustomObjectInstancesByExternalIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + IdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(DeleteCustomObjectInstancesByExternalIdRequest other); + } + + public interface IdStage { + /** + * The Intercom defined id of the custom object instance + */ + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + DeleteCustomObjectInstancesByExternalIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, IdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCustomObjectInstancesByExternalIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + id(other.getId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

The unique identifier of the custom object type that defines the structure of the custom object instance.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public IdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + /** + * The Intercom defined id of the custom object instance

The Intercom defined id of the custom object instance

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DeleteCustomObjectInstancesByExternalIdRequest build() { + return new DeleteCustomObjectInstancesByExternalIdRequest( + customObjectTypeIdentifier, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java new file mode 100644 index 0000000..ca2cef3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteCustomObjectInstancesByIdRequest.Builder.class) +public final class DeleteCustomObjectInstancesByIdRequest { + private final String customObjectTypeIdentifier; + + private final String externalId; + + private final Map additionalProperties; + + private DeleteCustomObjectInstancesByIdRequest( + String customObjectTypeIdentifier, String externalId, Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCustomObjectInstancesByIdRequest + && equalTo((DeleteCustomObjectInstancesByIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCustomObjectInstancesByIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(DeleteCustomObjectInstancesByIdRequest other); + } + + public interface ExternalIdStage { + _FinalStage externalId(@NotNull String externalId); + } + + public interface _FinalStage { + DeleteCustomObjectInstancesByIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, ExternalIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCustomObjectInstancesByIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + externalId(other.getExternalId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

The unique identifier of the custom object type that defines the structure of the custom object instance.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public DeleteCustomObjectInstancesByIdRequest build() { + return new DeleteCustomObjectInstancesByIdRequest( + customObjectTypeIdentifier, externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java new file mode 100644 index 0000000..5021dcf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCustomObjectInstancesByExternalIdRequest.Builder.class) +public final class GetCustomObjectInstancesByExternalIdRequest { + private final String customObjectTypeIdentifier; + + private final String externalId; + + private final Map additionalProperties; + + private GetCustomObjectInstancesByExternalIdRequest( + String customObjectTypeIdentifier, String externalId, Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCustomObjectInstancesByExternalIdRequest + && equalTo((GetCustomObjectInstancesByExternalIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCustomObjectInstancesByExternalIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) + && externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(GetCustomObjectInstancesByExternalIdRequest other); + } + + public interface ExternalIdStage { + _FinalStage externalId(@NotNull String externalId); + } + + public interface _FinalStage { + GetCustomObjectInstancesByExternalIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, ExternalIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCustomObjectInstancesByExternalIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + externalId(other.getExternalId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

The unique identifier of the custom object type that defines the structure of the custom object instance.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public ExternalIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public GetCustomObjectInstancesByExternalIdRequest build() { + return new GetCustomObjectInstancesByExternalIdRequest( + customObjectTypeIdentifier, externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java new file mode 100644 index 0000000..af465a8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java @@ -0,0 +1,147 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetCustomObjectInstancesByIdRequest.Builder.class) +public final class GetCustomObjectInstancesByIdRequest { + private final String customObjectTypeIdentifier; + + private final String id; + + private final Map additionalProperties; + + private GetCustomObjectInstancesByIdRequest( + String customObjectTypeIdentifier, String id, Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("custom_object_type_identifier") + public String getCustomObjectTypeIdentifier() { + return customObjectTypeIdentifier; + } + + /** + * @return The id or external_id of the custom object instance + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetCustomObjectInstancesByIdRequest + && equalTo((GetCustomObjectInstancesByIdRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetCustomObjectInstancesByIdRequest other) { + return customObjectTypeIdentifier.equals(other.customObjectTypeIdentifier) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CustomObjectTypeIdentifierStage builder() { + return new Builder(); + } + + public interface CustomObjectTypeIdentifierStage { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + IdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(GetCustomObjectInstancesByIdRequest other); + } + + public interface IdStage { + /** + * The id or external_id of the custom object instance + */ + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + GetCustomObjectInstancesByIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CustomObjectTypeIdentifierStage, IdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCustomObjectInstancesByIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + id(other.getId()); + return this; + } + + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance.

The unique identifier of the custom object type that defines the structure of the custom object instance.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("custom_object_type_identifier") + public IdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier) { + this.customObjectTypeIdentifier = + Objects.requireNonNull(customObjectTypeIdentifier, "customObjectTypeIdentifier must not be null"); + return this; + } + + /** + * The id or external_id of the custom object instance

The id or external_id of the custom object instance

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public GetCustomObjectInstancesByIdRequest build() { + return new GetCustomObjectInstancesByIdRequest(customObjectTypeIdentifier, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/types/CustomObjectInstance.java b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/types/CustomObjectInstance.java new file mode 100644 index 0000000..f591c9d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/customobjectinstances/types/CustomObjectInstance.java @@ -0,0 +1,330 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.customobjectinstances.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CustomObjectInstance.Builder.class) +public final class CustomObjectInstance { + private final Optional id; + + private final Optional externalId; + + private final Optional externalCreatedAt; + + private final Optional externalUpdatedAt; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional type; + + private final Optional> customAttributes; + + private final Map additionalProperties; + + private CustomObjectInstance( + Optional id, + Optional externalId, + Optional externalCreatedAt, + Optional externalUpdatedAt, + Optional createdAt, + Optional updatedAt, + Optional type, + Optional> customAttributes, + Map additionalProperties) { + this.id = id; + this.externalId = externalId; + this.externalCreatedAt = externalCreatedAt; + this.externalUpdatedAt = externalUpdatedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.type = type; + this.customAttributes = customAttributes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The Intercom defined id representing the custom object instance. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id you have defined for the custom object instance. + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return The time when the Custom Object instance was created in the external system it originated from. + */ + @JsonProperty("external_created_at") + public Optional getExternalCreatedAt() { + return externalCreatedAt; + } + + /** + * @return The time when the Custom Object instance was last updated in the external system it originated from. + */ + @JsonProperty("external_updated_at") + public Optional getExternalUpdatedAt() { + return externalUpdatedAt; + } + + /** + * @return The time the attribute was created as a UTC Unix timestamp + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time the attribute was last updated as a UTC Unix timestamp + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The identifier of the custom object type that defines the structure of the custom object instance. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The custom attributes you have set on the custom object instance. + */ + @JsonProperty("custom_attributes") + public Optional> getCustomAttributes() { + return customAttributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CustomObjectInstance && equalTo((CustomObjectInstance) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CustomObjectInstance other) { + return id.equals(other.id) + && externalId.equals(other.externalId) + && externalCreatedAt.equals(other.externalCreatedAt) + && externalUpdatedAt.equals(other.externalUpdatedAt) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && type.equals(other.type) + && customAttributes.equals(other.customAttributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.externalId, + this.externalCreatedAt, + this.externalUpdatedAt, + this.createdAt, + this.updatedAt, + this.type, + this.customAttributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional externalCreatedAt = Optional.empty(); + + private Optional externalUpdatedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional type = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CustomObjectInstance other) { + id(other.getId()); + externalId(other.getExternalId()); + externalCreatedAt(other.getExternalCreatedAt()); + externalUpdatedAt(other.getExternalUpdatedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + type(other.getType()); + customAttributes(other.getCustomAttributes()); + return this; + } + + /** + *

The Intercom defined id representing the custom object instance.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id you have defined for the custom object instance.

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

The time when the Custom Object instance was created in the external system it originated from.

+ */ + @JsonSetter(value = "external_created_at", nulls = Nulls.SKIP) + public Builder externalCreatedAt(Optional externalCreatedAt) { + this.externalCreatedAt = externalCreatedAt; + return this; + } + + public Builder externalCreatedAt(Integer externalCreatedAt) { + this.externalCreatedAt = Optional.ofNullable(externalCreatedAt); + return this; + } + + /** + *

The time when the Custom Object instance was last updated in the external system it originated from.

+ */ + @JsonSetter(value = "external_updated_at", nulls = Nulls.SKIP) + public Builder externalUpdatedAt(Optional externalUpdatedAt) { + this.externalUpdatedAt = externalUpdatedAt; + return this; + } + + public Builder externalUpdatedAt(Integer externalUpdatedAt) { + this.externalUpdatedAt = Optional.ofNullable(externalUpdatedAt); + return this; + } + + /** + *

The time the attribute was created as a UTC Unix timestamp

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time the attribute was last updated as a UTC Unix timestamp

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The identifier of the custom object type that defines the structure of the custom object instance.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The custom attributes you have set on the custom object instance.

+ */ + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; + return this; + } + + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); + return this; + } + + public CustomObjectInstance build() { + return new CustomObjectInstance( + id, + externalId, + externalCreatedAt, + externalUpdatedAt, + createdAt, + updatedAt, + type, + customAttributes, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/AsyncDataAttributesClient.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/AsyncDataAttributesClient.java new file mode 100644 index 0000000..03ad3dc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/AsyncDataAttributesClient.java @@ -0,0 +1,91 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataattributes.requests.CreateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.LisDataAttributesRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.UpdateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.types.DataAttribute; +import com.intercom.api.resources.unstable.types.DataAttributeList; +import java.util.concurrent.CompletableFuture; + +public class AsyncDataAttributesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDataAttributesClient rawClient; + + public AsyncDataAttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDataAttributesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDataAttributesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture lisDataAttributes() { + return this.rawClient.lisDataAttributes().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture lisDataAttributes(LisDataAttributesRequest request) { + return this.rawClient.lisDataAttributes(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture lisDataAttributes( + LisDataAttributesRequest request, RequestOptions requestOptions) { + return this.rawClient.lisDataAttributes(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public CompletableFuture createDataAttribute(CreateDataAttributeRequest request) { + return this.rawClient.createDataAttribute(request).thenApply(response -> response.body()); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public CompletableFuture createDataAttribute( + CreateDataAttributeRequest request, RequestOptions requestOptions) { + return this.rawClient.createDataAttribute(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public CompletableFuture updateDataAttribute(UpdateDataAttributeRequest request) { + return this.rawClient.updateDataAttribute(request).thenApply(response -> response.body()); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public CompletableFuture updateDataAttribute( + UpdateDataAttributeRequest request, RequestOptions requestOptions) { + return this.rawClient.updateDataAttribute(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/AsyncRawDataAttributesClient.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/AsyncRawDataAttributesClient.java new file mode 100644 index 0000000..9fc257d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/AsyncRawDataAttributesClient.java @@ -0,0 +1,312 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataattributes.requests.CreateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.LisDataAttributesRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.UpdateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.types.DataAttribute; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.types.DataAttributeList; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDataAttributesClient { + protected final ClientOptions clientOptions; + + public AsyncRawDataAttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture> lisDataAttributes() { + return lisDataAttributes(LisDataAttributesRequest.builder().build()); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture> lisDataAttributes( + LisDataAttributesRequest request) { + return lisDataAttributes(request, null); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public CompletableFuture> lisDataAttributes( + LisDataAttributesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes"); + if (request.getModel().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "model", request.getModel().get().toString(), false); + } + if (request.getIncludeArchived().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_archived", + request.getIncludeArchived().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DataAttributeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a data attributes for a contact or a company. + */ + public CompletableFuture> createDataAttribute( + CreateDataAttributeRequest request) { + return createDataAttribute(request, null); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public CompletableFuture> createDataAttribute( + CreateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DataAttribute.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public CompletableFuture> updateDataAttribute( + UpdateDataAttributeRequest request) { + return updateDataAttribute(request, null); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public CompletableFuture> updateDataAttribute( + UpdateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .addPathSegment(Integer.toString(request.getId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DataAttribute.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/DataAttributesClient.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/DataAttributesClient.java new file mode 100644 index 0000000..f0a39fd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/DataAttributesClient.java @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataattributes.requests.CreateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.LisDataAttributesRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.UpdateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.types.DataAttribute; +import com.intercom.api.resources.unstable.types.DataAttributeList; + +public class DataAttributesClient { + protected final ClientOptions clientOptions; + + private final RawDataAttributesClient rawClient; + + public DataAttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawDataAttributesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDataAttributesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public DataAttributeList lisDataAttributes() { + return this.rawClient.lisDataAttributes().body(); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public DataAttributeList lisDataAttributes(LisDataAttributesRequest request) { + return this.rawClient.lisDataAttributes(request).body(); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public DataAttributeList lisDataAttributes(LisDataAttributesRequest request, RequestOptions requestOptions) { + return this.rawClient.lisDataAttributes(request, requestOptions).body(); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public DataAttribute createDataAttribute(CreateDataAttributeRequest request) { + return this.rawClient.createDataAttribute(request).body(); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public DataAttribute createDataAttribute(CreateDataAttributeRequest request, RequestOptions requestOptions) { + return this.rawClient.createDataAttribute(request, requestOptions).body(); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public DataAttribute updateDataAttribute(UpdateDataAttributeRequest request) { + return this.rawClient.updateDataAttribute(request).body(); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public DataAttribute updateDataAttribute(UpdateDataAttributeRequest request, RequestOptions requestOptions) { + return this.rawClient.updateDataAttribute(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/RawDataAttributesClient.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/RawDataAttributesClient.java new file mode 100644 index 0000000..8a48b50 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/RawDataAttributesClient.java @@ -0,0 +1,250 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataattributes.requests.CreateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.LisDataAttributesRequest; +import com.intercom.api.resources.unstable.dataattributes.requests.UpdateDataAttributeRequest; +import com.intercom.api.resources.unstable.dataattributes.types.DataAttribute; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.types.DataAttributeList; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDataAttributesClient { + protected final ClientOptions clientOptions; + + public RawDataAttributesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public IntercomHttpResponse lisDataAttributes() { + return lisDataAttributes(LisDataAttributesRequest.builder().build()); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public IntercomHttpResponse lisDataAttributes(LisDataAttributesRequest request) { + return lisDataAttributes(request, null); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ + public IntercomHttpResponse lisDataAttributes( + LisDataAttributesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes"); + if (request.getModel().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "model", request.getModel().get().toString(), false); + } + if (request.getIncludeArchived().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_archived", + request.getIncludeArchived().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttributeList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a data attributes for a contact or a company. + */ + public IntercomHttpResponse createDataAttribute(CreateDataAttributeRequest request) { + return createDataAttribute(request, null); + } + + /** + * You can create a data attributes for a contact or a company. + */ + public IntercomHttpResponse createDataAttribute( + CreateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public IntercomHttpResponse updateDataAttribute(UpdateDataAttributeRequest request) { + return updateDataAttribute(request, null); + } + + /** + * You can update a data attribute. + *
+ *

🚧 Updating the data type is not possible

+ *

It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.

+ *
+ */ + public IntercomHttpResponse updateDataAttribute( + UpdateDataAttributeRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("data_attributes") + .addPathSegment(Integer.toString(request.getId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/CreateDataAttributeRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/CreateDataAttributeRequest.java new file mode 100644 index 0000000..9fcd362 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/CreateDataAttributeRequest.java @@ -0,0 +1,508 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateDataAttributeRequest.Builder.class) +public final class CreateDataAttributeRequest { + private final String name; + + private final Model model; + + private final DataType dataType; + + private final Optional description; + + private final Optional> options; + + private final Optional messengerWritable; + + private final Map additionalProperties; + + private CreateDataAttributeRequest( + String name, + Model model, + DataType dataType, + Optional description, + Optional> options, + Optional messengerWritable, + Map additionalProperties) { + this.name = name; + this.model = model; + this.dataType = dataType; + this.description = description; + this.options = options; + this.messengerWritable = messengerWritable; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the data attribute. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The model that the data attribute belongs to. + */ + @JsonProperty("model") + public Model getModel() { + return model; + } + + /** + * @return The type of data stored for this attribute. + */ + @JsonProperty("data_type") + public DataType getDataType() { + return dataType; + } + + /** + * @return The readable description you see in the UI for the attribute. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string. + */ + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + + /** + * @return Can this attribute be updated by the Messenger + */ + @JsonProperty("messenger_writable") + public Optional getMessengerWritable() { + return messengerWritable; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateDataAttributeRequest && equalTo((CreateDataAttributeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateDataAttributeRequest other) { + return name.equals(other.name) + && model.equals(other.model) + && dataType.equals(other.dataType) + && description.equals(other.description) + && options.equals(other.options) + && messengerWritable.equals(other.messengerWritable); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.name, this.model, this.dataType, this.description, this.options, this.messengerWritable); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + /** + * The name of the data attribute. + */ + ModelStage name(@NotNull String name); + + Builder from(CreateDataAttributeRequest other); + } + + public interface ModelStage { + /** + * The model that the data attribute belongs to. + */ + DataTypeStage model(@NotNull Model model); + } + + public interface DataTypeStage { + /** + * The type of data stored for this attribute. + */ + _FinalStage dataType(@NotNull DataType dataType); + } + + public interface _FinalStage { + CreateDataAttributeRequest build(); + + /** + *

The readable description you see in the UI for the attribute.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ + _FinalStage options(Optional> options); + + _FinalStage options(List options); + + /** + *

Can this attribute be updated by the Messenger

+ */ + _FinalStage messengerWritable(Optional messengerWritable); + + _FinalStage messengerWritable(Boolean messengerWritable); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, ModelStage, DataTypeStage, _FinalStage { + private String name; + + private Model model; + + private DataType dataType; + + private Optional messengerWritable = Optional.empty(); + + private Optional> options = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateDataAttributeRequest other) { + name(other.getName()); + model(other.getModel()); + dataType(other.getDataType()); + description(other.getDescription()); + options(other.getOptions()); + messengerWritable(other.getMessengerWritable()); + return this; + } + + /** + * The name of the data attribute.

The name of the data attribute.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public ModelStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + * The model that the data attribute belongs to.

The model that the data attribute belongs to.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("model") + public DataTypeStage model(@NotNull Model model) { + this.model = Objects.requireNonNull(model, "model must not be null"); + return this; + } + + /** + * The type of data stored for this attribute.

The type of data stored for this attribute.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("data_type") + public _FinalStage dataType(@NotNull DataType dataType) { + this.dataType = Objects.requireNonNull(dataType, "dataType must not be null"); + return this; + } + + /** + *

Can this attribute be updated by the Messenger

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage messengerWritable(Boolean messengerWritable) { + this.messengerWritable = Optional.ofNullable(messengerWritable); + return this; + } + + /** + *

Can this attribute be updated by the Messenger

+ */ + @java.lang.Override + @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) + public _FinalStage messengerWritable(Optional messengerWritable) { + this.messengerWritable = messengerWritable; + return this; + } + + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage options(List options) { + this.options = Optional.ofNullable(options); + return this; + } + + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ + @java.lang.Override + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; + return this; + } + + /** + *

The readable description you see in the UI for the attribute.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The readable description you see in the UI for the attribute.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public CreateDataAttributeRequest build() { + return new CreateDataAttributeRequest( + name, model, dataType, description, options, messengerWritable, additionalProperties); + } + } + + public static final class Model { + public static final Model CONTACT = new Model(Value.CONTACT, "contact"); + + public static final Model COMPANY = new Model(Value.COMPANY, "company"); + + private final Value value; + + private final String string; + + Model(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Model && this.string.equals(((Model) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CONTACT: + return visitor.visitContact(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Model valueOf(String value) { + switch (value) { + case "contact": + return CONTACT; + case "company": + return COMPANY; + default: + return new Model(Value.UNKNOWN, value); + } + } + + public enum Value { + CONTACT, + + COMPANY, + + UNKNOWN + } + + public interface Visitor { + T visitContact(); + + T visitCompany(); + + T visitUnknown(String unknownType); + } + } + + public static final class DataType { + public static final DataType STRING = new DataType(Value.STRING, "string"); + + public static final DataType FLOAT = new DataType(Value.FLOAT, "float"); + + public static final DataType INTEGER = new DataType(Value.INTEGER, "integer"); + + public static final DataType DATETIME = new DataType(Value.DATETIME, "datetime"); + + public static final DataType BOOLEAN = new DataType(Value.BOOLEAN, "boolean"); + + public static final DataType DATE = new DataType(Value.DATE, "date"); + + private final Value value; + + private final String string; + + DataType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof DataType && this.string.equals(((DataType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case STRING: + return visitor.visitString(); + case FLOAT: + return visitor.visitFloat(); + case INTEGER: + return visitor.visitInteger(); + case DATETIME: + return visitor.visitDatetime(); + case BOOLEAN: + return visitor.visitBoolean(); + case DATE: + return visitor.visitDate(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DataType valueOf(String value) { + switch (value) { + case "string": + return STRING; + case "float": + return FLOAT; + case "integer": + return INTEGER; + case "datetime": + return DATETIME; + case "boolean": + return BOOLEAN; + case "date": + return DATE; + default: + return new DataType(Value.UNKNOWN, value); + } + } + + public enum Value { + STRING, + + INTEGER, + + FLOAT, + + BOOLEAN, + + DATETIME, + + DATE, + + UNKNOWN + } + + public interface Visitor { + T visitString(); + + T visitInteger(); + + T visitFloat(); + + T visitBoolean(); + + T visitDatetime(); + + T visitDate(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/LisDataAttributesRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/LisDataAttributesRequest.java new file mode 100644 index 0000000..5379285 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/LisDataAttributesRequest.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.dataattributes.types.LisDataAttributesRequestModel; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LisDataAttributesRequest.Builder.class) +public final class LisDataAttributesRequest { + private final Optional model; + + private final Optional includeArchived; + + private final Map additionalProperties; + + private LisDataAttributesRequest( + Optional model, + Optional includeArchived, + Map additionalProperties) { + this.model = model; + this.includeArchived = includeArchived; + this.additionalProperties = additionalProperties; + } + + /** + * @return Specify the data attribute model to return. + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return Include archived attributes in the list. By default we return only non archived data attributes. + */ + @JsonProperty("include_archived") + public Optional getIncludeArchived() { + return includeArchived; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LisDataAttributesRequest && equalTo((LisDataAttributesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LisDataAttributesRequest other) { + return model.equals(other.model) && includeArchived.equals(other.includeArchived); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.model, this.includeArchived); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional model = Optional.empty(); + + private Optional includeArchived = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(LisDataAttributesRequest other) { + model(other.getModel()); + includeArchived(other.getIncludeArchived()); + return this; + } + + /** + *

Specify the data attribute model to return.

+ */ + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public Builder model(Optional model) { + this.model = model; + return this; + } + + public Builder model(LisDataAttributesRequestModel model) { + this.model = Optional.ofNullable(model); + return this; + } + + /** + *

Include archived attributes in the list. By default we return only non archived data attributes.

+ */ + @JsonSetter(value = "include_archived", nulls = Nulls.SKIP) + public Builder includeArchived(Optional includeArchived) { + this.includeArchived = includeArchived; + return this; + } + + public Builder includeArchived(Boolean includeArchived) { + this.includeArchived = Optional.ofNullable(includeArchived); + return this; + } + + public LisDataAttributesRequest build() { + return new LisDataAttributesRequest(model, includeArchived, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/UpdateDataAttributeRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/UpdateDataAttributeRequest.java new file mode 100644 index 0000000..d407f10 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/requests/UpdateDataAttributeRequest.java @@ -0,0 +1,289 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateDataAttributeRequest.Builder.class) +public final class UpdateDataAttributeRequest { + private final int id; + + private final Optional archived; + + private final Optional description; + + private final Optional> options; + + private final Optional messengerWritable; + + private final Map additionalProperties; + + private UpdateDataAttributeRequest( + int id, + Optional archived, + Optional description, + Optional> options, + Optional messengerWritable, + Map additionalProperties) { + this.id = id; + this.archived = archived; + this.description = description; + this.options = options; + this.messengerWritable = messengerWritable; + this.additionalProperties = additionalProperties; + } + + /** + * @return The data attribute id + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return Whether the attribute is to be archived or not. + */ + @JsonProperty("archived") + public Optional getArchived() { + return archived; + } + + /** + * @return The readable description you see in the UI for the attribute. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string. + */ + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + + /** + * @return Can this attribute be updated by the Messenger + */ + @JsonProperty("messenger_writable") + public Optional getMessengerWritable() { + return messengerWritable; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateDataAttributeRequest && equalTo((UpdateDataAttributeRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateDataAttributeRequest other) { + return id == other.id + && archived.equals(other.archived) + && description.equals(other.description) + && options.equals(other.options) + && messengerWritable.equals(other.messengerWritable); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.archived, this.description, this.options, this.messengerWritable); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The data attribute id + */ + _FinalStage id(int id); + + Builder from(UpdateDataAttributeRequest other); + } + + public interface _FinalStage { + UpdateDataAttributeRequest build(); + + /** + *

Whether the attribute is to be archived or not.

+ */ + _FinalStage archived(Optional archived); + + _FinalStage archived(Boolean archived); + + /** + *

The readable description you see in the UI for the attribute.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ + _FinalStage options(Optional> options); + + _FinalStage options(List options); + + /** + *

Can this attribute be updated by the Messenger

+ */ + _FinalStage messengerWritable(Optional messengerWritable); + + _FinalStage messengerWritable(Boolean messengerWritable); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + private Optional messengerWritable = Optional.empty(); + + private Optional> options = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional archived = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateDataAttributeRequest other) { + id(other.getId()); + archived(other.getArchived()); + description(other.getDescription()); + options(other.getOptions()); + messengerWritable(other.getMessengerWritable()); + return this; + } + + /** + * The data attribute id

The data attribute id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + /** + *

Can this attribute be updated by the Messenger

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage messengerWritable(Boolean messengerWritable) { + this.messengerWritable = Optional.ofNullable(messengerWritable); + return this; + } + + /** + *

Can this attribute be updated by the Messenger

+ */ + @java.lang.Override + @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) + public _FinalStage messengerWritable(Optional messengerWritable) { + this.messengerWritable = messengerWritable; + return this; + } + + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage options(List options) { + this.options = Optional.ofNullable(options); + return this; + } + + /** + *

To create list attributes. Provide a set of hashes with value as the key of the options you want to make. data_type must be string.

+ */ + @java.lang.Override + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public _FinalStage options(Optional> options) { + this.options = options; + return this; + } + + /** + *

The readable description you see in the UI for the attribute.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The readable description you see in the UI for the attribute.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

Whether the attribute is to be archived or not.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage archived(Boolean archived) { + this.archived = Optional.ofNullable(archived); + return this; + } + + /** + *

Whether the attribute is to be archived or not.

+ */ + @java.lang.Override + @JsonSetter(value = "archived", nulls = Nulls.SKIP) + public _FinalStage archived(Optional archived) { + this.archived = archived; + return this; + } + + @java.lang.Override + public UpdateDataAttributeRequest build() { + return new UpdateDataAttributeRequest( + id, archived, description, options, messengerWritable, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/types/DataAttribute.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/types/DataAttribute.java new file mode 100644 index 0000000..403fadd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/types/DataAttribute.java @@ -0,0 +1,801 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DataAttribute.Builder.class) +public final class DataAttribute { + private final Optional type; + + private final Optional id; + + private final Optional model; + + private final Optional name; + + private final Optional fullName; + + private final Optional label; + + private final Optional description; + + private final Optional dataType; + + private final Optional> options; + + private final Optional apiWritable; + + private final Optional messengerWritable; + + private final Optional uiWritable; + + private final Optional custom; + + private final Optional archived; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional adminId; + + private final Map additionalProperties; + + private DataAttribute( + Optional type, + Optional id, + Optional model, + Optional name, + Optional fullName, + Optional label, + Optional description, + Optional dataType, + Optional> options, + Optional apiWritable, + Optional messengerWritable, + Optional uiWritable, + Optional custom, + Optional archived, + Optional createdAt, + Optional updatedAt, + Optional adminId, + Map additionalProperties) { + this.type = type; + this.id = id; + this.model = model; + this.name = name; + this.fullName = fullName; + this.label = label; + this.description = description; + this.dataType = dataType; + this.options = options; + this.apiWritable = apiWritable; + this.messengerWritable = messengerWritable; + this.uiWritable = uiWritable; + this.custom = custom; + this.archived = archived; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is data_attribute. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return Value is contact for user/lead attributes and company for company attributes. + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return Name of the attribute. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on . to access nested user object values. + */ + @JsonProperty("full_name") + public Optional getFullName() { + return fullName; + } + + /** + * @return Readable name of the attribute (i.e. name you see in the UI) + */ + @JsonProperty("label") + public Optional getLabel() { + return label; + } + + /** + * @return Readable description of the attribute. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The data type of the attribute. + */ + @JsonProperty("data_type") + public Optional getDataType() { + return dataType; + } + + /** + * @return List of predefined options for attribute value. + */ + @JsonProperty("options") + public Optional> getOptions() { + return options; + } + + /** + * @return Can this attribute be updated through API + */ + @JsonProperty("api_writable") + public Optional getApiWritable() { + return apiWritable; + } + + /** + * @return Can this attribute be updated by the Messenger + */ + @JsonProperty("messenger_writable") + public Optional getMessengerWritable() { + return messengerWritable; + } + + /** + * @return Can this attribute be updated in the UI + */ + @JsonProperty("ui_writable") + public Optional getUiWritable() { + return uiWritable; + } + + /** + * @return Set to true if this is a CDA + */ + @JsonProperty("custom") + public Optional getCustom() { + return custom; + } + + /** + * @return Is this attribute archived. (Only applicable to CDAs) + */ + @JsonProperty("archived") + public Optional getArchived() { + return archived; + } + + /** + * @return The time the attribute was created as a UTC Unix timestamp + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time the attribute was last updated as a UTC Unix timestamp + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return Teammate who created the attribute. Only applicable to CDAs + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataAttribute && equalTo((DataAttribute) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataAttribute other) { + return type.equals(other.type) + && id.equals(other.id) + && model.equals(other.model) + && name.equals(other.name) + && fullName.equals(other.fullName) + && label.equals(other.label) + && description.equals(other.description) + && dataType.equals(other.dataType) + && options.equals(other.options) + && apiWritable.equals(other.apiWritable) + && messengerWritable.equals(other.messengerWritable) + && uiWritable.equals(other.uiWritable) + && custom.equals(other.custom) + && archived.equals(other.archived) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.model, + this.name, + this.fullName, + this.label, + this.description, + this.dataType, + this.options, + this.apiWritable, + this.messengerWritable, + this.uiWritable, + this.custom, + this.archived, + this.createdAt, + this.updatedAt, + this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional model = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional fullName = Optional.empty(); + + private Optional label = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional dataType = Optional.empty(); + + private Optional> options = Optional.empty(); + + private Optional apiWritable = Optional.empty(); + + private Optional messengerWritable = Optional.empty(); + + private Optional uiWritable = Optional.empty(); + + private Optional custom = Optional.empty(); + + private Optional archived = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional adminId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DataAttribute other) { + type(other.getType()); + id(other.getId()); + model(other.getModel()); + name(other.getName()); + fullName(other.getFullName()); + label(other.getLabel()); + description(other.getDescription()); + dataType(other.getDataType()); + options(other.getOptions()); + apiWritable(other.getApiWritable()); + messengerWritable(other.getMessengerWritable()); + uiWritable(other.getUiWritable()); + custom(other.getCustom()); + archived(other.getArchived()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + adminId(other.getAdminId()); + return this; + } + + /** + *

Value is data_attribute.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(Integer id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

Value is contact for user/lead attributes and company for company attributes.

+ */ + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public Builder model(Optional model) { + this.model = model; + return this; + } + + public Builder model(Model model) { + this.model = Optional.ofNullable(model); + return this; + } + + /** + *

Name of the attribute.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on . to access nested user object values.

+ */ + @JsonSetter(value = "full_name", nulls = Nulls.SKIP) + public Builder fullName(Optional fullName) { + this.fullName = fullName; + return this; + } + + public Builder fullName(String fullName) { + this.fullName = Optional.ofNullable(fullName); + return this; + } + + /** + *

Readable name of the attribute (i.e. name you see in the UI)

+ */ + @JsonSetter(value = "label", nulls = Nulls.SKIP) + public Builder label(Optional label) { + this.label = label; + return this; + } + + public Builder label(String label) { + this.label = Optional.ofNullable(label); + return this; + } + + /** + *

Readable description of the attribute.

+ */ + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The data type of the attribute.

+ */ + @JsonSetter(value = "data_type", nulls = Nulls.SKIP) + public Builder dataType(Optional dataType) { + this.dataType = dataType; + return this; + } + + public Builder dataType(DataType dataType) { + this.dataType = Optional.ofNullable(dataType); + return this; + } + + /** + *

List of predefined options for attribute value.

+ */ + @JsonSetter(value = "options", nulls = Nulls.SKIP) + public Builder options(Optional> options) { + this.options = options; + return this; + } + + public Builder options(List options) { + this.options = Optional.ofNullable(options); + return this; + } + + /** + *

Can this attribute be updated through API

+ */ + @JsonSetter(value = "api_writable", nulls = Nulls.SKIP) + public Builder apiWritable(Optional apiWritable) { + this.apiWritable = apiWritable; + return this; + } + + public Builder apiWritable(Boolean apiWritable) { + this.apiWritable = Optional.ofNullable(apiWritable); + return this; + } + + /** + *

Can this attribute be updated by the Messenger

+ */ + @JsonSetter(value = "messenger_writable", nulls = Nulls.SKIP) + public Builder messengerWritable(Optional messengerWritable) { + this.messengerWritable = messengerWritable; + return this; + } + + public Builder messengerWritable(Boolean messengerWritable) { + this.messengerWritable = Optional.ofNullable(messengerWritable); + return this; + } + + /** + *

Can this attribute be updated in the UI

+ */ + @JsonSetter(value = "ui_writable", nulls = Nulls.SKIP) + public Builder uiWritable(Optional uiWritable) { + this.uiWritable = uiWritable; + return this; + } + + public Builder uiWritable(Boolean uiWritable) { + this.uiWritable = Optional.ofNullable(uiWritable); + return this; + } + + /** + *

Set to true if this is a CDA

+ */ + @JsonSetter(value = "custom", nulls = Nulls.SKIP) + public Builder custom(Optional custom) { + this.custom = custom; + return this; + } + + public Builder custom(Boolean custom) { + this.custom = Optional.ofNullable(custom); + return this; + } + + /** + *

Is this attribute archived. (Only applicable to CDAs)

+ */ + @JsonSetter(value = "archived", nulls = Nulls.SKIP) + public Builder archived(Optional archived) { + this.archived = archived; + return this; + } + + public Builder archived(Boolean archived) { + this.archived = Optional.ofNullable(archived); + return this; + } + + /** + *

The time the attribute was created as a UTC Unix timestamp

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time the attribute was last updated as a UTC Unix timestamp

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

Teammate who created the attribute. Only applicable to CDAs

+ */ + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public Builder adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + public Builder adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + public DataAttribute build() { + return new DataAttribute( + type, + id, + model, + name, + fullName, + label, + description, + dataType, + options, + apiWritable, + messengerWritable, + uiWritable, + custom, + archived, + createdAt, + updatedAt, + adminId, + additionalProperties); + } + } + + public static final class DataType { + public static final DataType STRING = new DataType(Value.STRING, "string"); + + public static final DataType FLOAT = new DataType(Value.FLOAT, "float"); + + public static final DataType INTEGER = new DataType(Value.INTEGER, "integer"); + + public static final DataType BOOLEAN = new DataType(Value.BOOLEAN, "boolean"); + + public static final DataType DATE = new DataType(Value.DATE, "date"); + + private final Value value; + + private final String string; + + DataType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof DataType && this.string.equals(((DataType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case STRING: + return visitor.visitString(); + case FLOAT: + return visitor.visitFloat(); + case INTEGER: + return visitor.visitInteger(); + case BOOLEAN: + return visitor.visitBoolean(); + case DATE: + return visitor.visitDate(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DataType valueOf(String value) { + switch (value) { + case "string": + return STRING; + case "float": + return FLOAT; + case "integer": + return INTEGER; + case "boolean": + return BOOLEAN; + case "date": + return DATE; + default: + return new DataType(Value.UNKNOWN, value); + } + } + + public enum Value { + STRING, + + INTEGER, + + FLOAT, + + BOOLEAN, + + DATE, + + UNKNOWN + } + + public interface Visitor { + T visitString(); + + T visitInteger(); + + T visitFloat(); + + T visitBoolean(); + + T visitDate(); + + T visitUnknown(String unknownType); + } + } + + public static final class Model { + public static final Model CONTACT = new Model(Value.CONTACT, "contact"); + + public static final Model COMPANY = new Model(Value.COMPANY, "company"); + + private final Value value; + + private final String string; + + Model(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Model && this.string.equals(((Model) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CONTACT: + return visitor.visitContact(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Model valueOf(String value) { + switch (value) { + case "contact": + return CONTACT; + case "company": + return COMPANY; + default: + return new Model(Value.UNKNOWN, value); + } + } + + public enum Value { + CONTACT, + + COMPANY, + + UNKNOWN + } + + public interface Visitor { + T visitContact(); + + T visitCompany(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataattributes/types/LisDataAttributesRequestModel.java b/src/main/java/com/intercom/api/resources/unstable/dataattributes/types/LisDataAttributesRequestModel.java new file mode 100644 index 0000000..7ba62a0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataattributes/types/LisDataAttributesRequestModel.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataattributes.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class LisDataAttributesRequestModel { + public static final LisDataAttributesRequestModel CONTACT = + new LisDataAttributesRequestModel(Value.CONTACT, "contact"); + + public static final LisDataAttributesRequestModel CONVERSATION = + new LisDataAttributesRequestModel(Value.CONVERSATION, "conversation"); + + public static final LisDataAttributesRequestModel COMPANY = + new LisDataAttributesRequestModel(Value.COMPANY, "company"); + + private final Value value; + + private final String string; + + LisDataAttributesRequestModel(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof LisDataAttributesRequestModel + && this.string.equals(((LisDataAttributesRequestModel) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CONTACT: + return visitor.visitContact(); + case CONVERSATION: + return visitor.visitConversation(); + case COMPANY: + return visitor.visitCompany(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static LisDataAttributesRequestModel valueOf(String value) { + switch (value) { + case "contact": + return CONTACT; + case "conversation": + return CONVERSATION; + case "company": + return COMPANY; + default: + return new LisDataAttributesRequestModel(Value.UNKNOWN, value); + } + } + + public enum Value { + CONTACT, + + COMPANY, + + CONVERSATION, + + UNKNOWN + } + + public interface Visitor { + T visitContact(); + + T visitCompany(); + + T visitConversation(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/AsyncDataEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/AsyncDataEventsClient.java new file mode 100644 index 0000000..18749c0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/AsyncDataEventsClient.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataevents.requests.CreateDataEventSummariesRequest; +import com.intercom.api.resources.unstable.dataevents.requests.LisDataEventsRequest; +import com.intercom.api.resources.unstable.types.DataEventSummary; +import java.util.concurrent.CompletableFuture; + +public class AsyncDataEventsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDataEventsClient rawClient; + + public AsyncDataEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDataEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDataEventsClient withRawResponse() { + return this.rawClient; + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public CompletableFuture lisDataEvents(LisDataEventsRequest request) { + return this.rawClient.lisDataEvents(request).thenApply(response -> response.body()); + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public CompletableFuture lisDataEvents( + LisDataEventsRequest request, RequestOptions requestOptions) { + return this.rawClient.lisDataEvents(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public CompletableFuture createDataEvent(Object request) { + return this.rawClient.createDataEvent(request).thenApply(response -> response.body()); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public CompletableFuture createDataEvent(Object request, RequestOptions requestOptions) { + return this.rawClient.createDataEvent(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture dataEventSummaries() { + return this.rawClient.dataEventSummaries().thenApply(response -> response.body()); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture dataEventSummaries(CreateDataEventSummariesRequest request) { + return this.rawClient.dataEventSummaries(request).thenApply(response -> response.body()); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture dataEventSummaries( + CreateDataEventSummariesRequest request, RequestOptions requestOptions) { + return this.rawClient.dataEventSummaries(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/AsyncRawDataEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/AsyncRawDataEventsClient.java new file mode 100644 index 0000000..5715f18 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/AsyncRawDataEventsClient.java @@ -0,0 +1,345 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataevents.requests.CreateDataEventSummariesRequest; +import com.intercom.api.resources.unstable.dataevents.requests.LisDataEventsRequest; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.DataEventSummary; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDataEventsClient { + protected final ClientOptions clientOptions; + + public AsyncRawDataEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public CompletableFuture> lisDataEvents(LisDataEventsRequest request) { + return lisDataEvents(request, null); + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public CompletableFuture> lisDataEvents( + LisDataEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events"); + QueryStringMapper.addQueryParameter( + httpUrl, "filter", request.getFilter().toString(), false); + QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType(), false); + if (request.getSummary().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "summary", request.getSummary().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DataEventSummary.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public CompletableFuture> createDataEvent(Object request) { + return createDataEvent(request, null); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public CompletableFuture> createDataEvent( + Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture> dataEventSummaries() { + return dataEventSummaries(CreateDataEventSummariesRequest.builder().build()); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture> dataEventSummaries(CreateDataEventSummariesRequest request) { + return dataEventSummaries(request, null); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public CompletableFuture> dataEventSummaries( + CreateDataEventSummariesRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events/summaries") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/DataEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/DataEventsClient.java new file mode 100644 index 0000000..aa44fbc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/DataEventsClient.java @@ -0,0 +1,159 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataevents.requests.CreateDataEventSummariesRequest; +import com.intercom.api.resources.unstable.dataevents.requests.LisDataEventsRequest; +import com.intercom.api.resources.unstable.types.DataEventSummary; + +public class DataEventsClient { + protected final ClientOptions clientOptions; + + private final RawDataEventsClient rawClient; + + public DataEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawDataEventsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDataEventsClient withRawResponse() { + return this.rawClient; + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public DataEventSummary lisDataEvents(LisDataEventsRequest request) { + return this.rawClient.lisDataEvents(request).body(); + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public DataEventSummary lisDataEvents(LisDataEventsRequest request, RequestOptions requestOptions) { + return this.rawClient.lisDataEvents(request, requestOptions).body(); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public void createDataEvent(Object request) { + this.rawClient.createDataEvent(request).body(); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public void createDataEvent(Object request, RequestOptions requestOptions) { + this.rawClient.createDataEvent(request, requestOptions).body(); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public void dataEventSummaries() { + this.rawClient.dataEventSummaries().body(); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public void dataEventSummaries(CreateDataEventSummariesRequest request) { + this.rawClient.dataEventSummaries(request).body(); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public void dataEventSummaries(CreateDataEventSummariesRequest request, RequestOptions requestOptions) { + this.rawClient.dataEventSummaries(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/RawDataEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/RawDataEventsClient.java new file mode 100644 index 0000000..af80bb4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/RawDataEventsClient.java @@ -0,0 +1,297 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataevents.requests.CreateDataEventSummariesRequest; +import com.intercom.api.resources.unstable.dataevents.requests.LisDataEventsRequest; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.types.DataEventSummary; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDataEventsClient { + protected final ClientOptions clientOptions; + + public RawDataEventsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public IntercomHttpResponse lisDataEvents(LisDataEventsRequest request) { + return lisDataEvents(request, null); + } + + /** + *
+ * 🚧 + *

Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days

+ *
+ *

The events belonging to a customer can be listed by sending a GET request to https://api.intercom.io/events with a user or lead identifier along with a type parameter. The identifier parameter can be one of user_id, email or intercom_user_id. The type parameter value must be user.

+ *
    + *
  • https://api.intercom.io/events?type=user&user_id={user_id}
  • + *
  • https://api.intercom.io/events?type=user&email={email}
  • + *
  • https://api.intercom.io/events?type=user&intercom_user_id={id} (this call can be used to list leads)
  • + *
+ *

The email parameter value should be url encoded when sending.

+ *

You can optionally define the result page size as well with the per_page parameter.

+ */ + public IntercomHttpResponse lisDataEvents( + LisDataEventsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events"); + QueryStringMapper.addQueryParameter( + httpUrl, "filter", request.getFilter().toString(), false); + QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType(), false); + if (request.getSummary().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "summary", request.getSummary().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataEventSummary.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public IntercomHttpResponse createDataEvent(Object request) { + return createDataEvent(request, null); + } + + /** + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a Content-Type of application/json. + *

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

+ *

With the Ruby client you pass a hash describing the event to Intercom::Event.create, or call the track_user method directly on the current user object (e.g. user.track_event).

+ *

NB: For the JSON object types, please note that we do not currently support nested JSON structure.

+ *

| Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | "source":"desktop" | + * | Number | The value is a JSON Number | "load": 3.67 | + * | Date | The key ends with the String _date and the value is a Unix timestamp, assumed to be in the UTC timezone. | "contact_date": 1392036272 | + * | Link | The value is a HTTP or HTTPS URI. | "article": "https://example.org/ab1de.html" | + * | Rich Link | The value is a JSON object that contains url and value keys. | "article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"} | + * | Monetary Amount | The value is a JSON object that contains amount and currency keys. The amount key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | "price": {"amount": 34999, "currency": "eur"} |

+ *

Lead Events

+ *

When submitting events for Leads, you will need to specify the Lead's id.

+ *

Metadata behaviour

+ *
    + *
  • We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
  • + *
  • It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
  • + *
  • There might be up to 24 hrs delay when you send a new metadata for an existing event.
  • + *
+ *

Event de-duplication

+ *

The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is strongly recommended to send a second granularity Unix timestamp in the created_at field.

+ *

Duplicated events are responded to using the normal 202 Accepted code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.

+ *

HTTP API Responses

+ *
    + *
  • Successful responses to submitted events return 202 Accepted with an empty body.
  • + *
  • Unauthorised access will be rejected with a 401 Unauthorized or 403 Forbidden response code.
  • + *
  • Events sent about users that cannot be found will return a 404 Not Found.
  • + *
  • Event lists containing duplicate events will have those duplicates ignored.
  • + *
  • Server errors will return a 500 response code and may contain an error message in the body.
  • + *
+ */ + public IntercomHttpResponse createDataEvent(Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public IntercomHttpResponse dataEventSummaries() { + return dataEventSummaries(CreateDataEventSummariesRequest.builder().build()); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public IntercomHttpResponse dataEventSummaries(CreateDataEventSummariesRequest request) { + return dataEventSummaries(request, null); + } + + /** + * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. + */ + public IntercomHttpResponse dataEventSummaries( + CreateDataEventSummariesRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("events/summaries") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/requests/CreateDataEventSummariesRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/requests/CreateDataEventSummariesRequest.java new file mode 100644 index 0000000..b0321de --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/requests/CreateDataEventSummariesRequest.java @@ -0,0 +1,307 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateDataEventSummariesRequest.Builder.class) +public final class CreateDataEventSummariesRequest { + private final Optional userId; + + private final Optional eventSummaries; + + private final Map additionalProperties; + + private CreateDataEventSummariesRequest( + Optional userId, + Optional eventSummaries, + Map additionalProperties) { + this.userId = userId; + this.eventSummaries = eventSummaries; + this.additionalProperties = additionalProperties; + } + + /** + * @return Your identifier for the user. + */ + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example updated-plan. + */ + @JsonProperty("event_summaries") + public Optional getEventSummaries() { + return eventSummaries; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateDataEventSummariesRequest && equalTo((CreateDataEventSummariesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateDataEventSummariesRequest other) { + return userId.equals(other.userId) && eventSummaries.equals(other.eventSummaries); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId, this.eventSummaries); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional userId = Optional.empty(); + + private Optional eventSummaries = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CreateDataEventSummariesRequest other) { + userId(other.getUserId()); + eventSummaries(other.getEventSummaries()); + return this; + } + + /** + *

Your identifier for the user.

+ */ + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public Builder userId(Optional userId) { + this.userId = userId; + return this; + } + + public Builder userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + /** + *

A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

+ */ + @JsonSetter(value = "event_summaries", nulls = Nulls.SKIP) + public Builder eventSummaries(Optional eventSummaries) { + this.eventSummaries = eventSummaries; + return this; + } + + public Builder eventSummaries(EventSummaries eventSummaries) { + this.eventSummaries = Optional.ofNullable(eventSummaries); + return this; + } + + public CreateDataEventSummariesRequest build() { + return new CreateDataEventSummariesRequest(userId, eventSummaries, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = EventSummaries.Builder.class) + public static final class EventSummaries { + private final Optional eventName; + + private final Optional count; + + private final Optional first; + + private final Optional last; + + private final Map additionalProperties; + + private EventSummaries( + Optional eventName, + Optional count, + Optional first, + Optional last, + Map additionalProperties) { + this.eventName = eventName; + this.count = count; + this.first = first; + this.last = last; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the event that occurred. A good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan. + */ + @JsonProperty("event_name") + public Optional getEventName() { + return eventName; + } + + /** + * @return The number of times the event occurred. + */ + @JsonProperty("count") + public Optional getCount() { + return count; + } + + /** + * @return The first time the event was sent + */ + @JsonProperty("first") + public Optional getFirst() { + return first; + } + + /** + * @return The last time the event was sent + */ + @JsonProperty("last") + public Optional getLast() { + return last; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EventSummaries && equalTo((EventSummaries) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EventSummaries other) { + return eventName.equals(other.eventName) + && count.equals(other.count) + && first.equals(other.first) + && last.equals(other.last); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.eventName, this.count, this.first, this.last); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional eventName = Optional.empty(); + + private Optional count = Optional.empty(); + + private Optional first = Optional.empty(); + + private Optional last = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(EventSummaries other) { + eventName(other.getEventName()); + count(other.getCount()); + first(other.getFirst()); + last(other.getLast()); + return this; + } + + /** + *

The name of the event that occurred. A good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

+ */ + @JsonSetter(value = "event_name", nulls = Nulls.SKIP) + public Builder eventName(Optional eventName) { + this.eventName = eventName; + return this; + } + + public Builder eventName(String eventName) { + this.eventName = Optional.ofNullable(eventName); + return this; + } + + /** + *

The number of times the event occurred.

+ */ + @JsonSetter(value = "count", nulls = Nulls.SKIP) + public Builder count(Optional count) { + this.count = count; + return this; + } + + public Builder count(Integer count) { + this.count = Optional.ofNullable(count); + return this; + } + + /** + *

The first time the event was sent

+ */ + @JsonSetter(value = "first", nulls = Nulls.SKIP) + public Builder first(Optional first) { + this.first = first; + return this; + } + + public Builder first(Integer first) { + this.first = Optional.ofNullable(first); + return this; + } + + /** + *

The last time the event was sent

+ */ + @JsonSetter(value = "last", nulls = Nulls.SKIP) + public Builder last(Optional last) { + this.last = last; + return this; + } + + public Builder last(Integer last) { + this.last = Optional.ofNullable(last); + return this; + } + + public EventSummaries build() { + return new EventSummaries(eventName, count, first, last, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/requests/LisDataEventsRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/requests/LisDataEventsRequest.java new file mode 100644 index 0000000..91cafe6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/requests/LisDataEventsRequest.java @@ -0,0 +1,182 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.dataevents.types.LisDataEventsRequestFilter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = LisDataEventsRequest.Builder.class) +public final class LisDataEventsRequest { + private final LisDataEventsRequestFilter filter; + + private final String type; + + private final Optional summary; + + private final Map additionalProperties; + + private LisDataEventsRequest( + LisDataEventsRequestFilter filter, + String type, + Optional summary, + Map additionalProperties) { + this.filter = filter; + this.type = type; + this.summary = summary; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("filter") + public LisDataEventsRequestFilter getFilter() { + return filter; + } + + /** + * @return The value must be user + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return summary flag + */ + @JsonProperty("summary") + public Optional getSummary() { + return summary; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LisDataEventsRequest && equalTo((LisDataEventsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(LisDataEventsRequest other) { + return filter.equals(other.filter) && type.equals(other.type) && summary.equals(other.summary); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.filter, this.type, this.summary); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static FilterStage builder() { + return new Builder(); + } + + public interface FilterStage { + TypeStage filter(@NotNull LisDataEventsRequestFilter filter); + + Builder from(LisDataEventsRequest other); + } + + public interface TypeStage { + /** + * The value must be user + */ + _FinalStage type(@NotNull String type); + } + + public interface _FinalStage { + LisDataEventsRequest build(); + + /** + *

summary flag

+ */ + _FinalStage summary(Optional summary); + + _FinalStage summary(Boolean summary); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements FilterStage, TypeStage, _FinalStage { + private LisDataEventsRequestFilter filter; + + private String type; + + private Optional summary = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(LisDataEventsRequest other) { + filter(other.getFilter()); + type(other.getType()); + summary(other.getSummary()); + return this; + } + + @java.lang.Override + @JsonSetter("filter") + public TypeStage filter(@NotNull LisDataEventsRequestFilter filter) { + this.filter = Objects.requireNonNull(filter, "filter must not be null"); + return this; + } + + /** + * The value must be user

The value must be user

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("type") + public _FinalStage type(@NotNull String type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + *

summary flag

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage summary(Boolean summary) { + this.summary = Optional.ofNullable(summary); + return this; + } + + /** + *

summary flag

+ */ + @java.lang.Override + @JsonSetter(value = "summary", nulls = Nulls.SKIP) + public _FinalStage summary(Optional summary) { + this.summary = summary; + return this; + } + + @java.lang.Override + public LisDataEventsRequest build() { + return new LisDataEventsRequest(filter, type, summary, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/types/DataEvent.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/types/DataEvent.java new file mode 100644 index 0000000..31c0e20 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/types/DataEvent.java @@ -0,0 +1,417 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DataEvent.Builder.class) +public final class DataEvent { + private final Optional type; + + private final String eventName; + + private final int createdAt; + + private final Optional userId; + + private final Optional id; + + private final Optional intercomUserId; + + private final Optional email; + + private final Optional> metadata; + + private final Map additionalProperties; + + private DataEvent( + Optional type, + String eventName, + int createdAt, + Optional userId, + Optional id, + Optional intercomUserId, + Optional email, + Optional> metadata, + Map additionalProperties) { + this.type = type; + this.eventName = eventName; + this.createdAt = createdAt; + this.userId = userId; + this.id = id; + this.intercomUserId = intercomUserId; + this.email = email; + this.metadata = metadata; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan. + */ + @JsonProperty("event_name") + public String getEventName() { + return eventName; + } + + /** + * @return The time the event occurred as a UTC Unix timestamp + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return Your identifier for the user. + */ + @JsonProperty("user_id") + public Optional getUserId() { + return userId; + } + + /** + * @return Your identifier for a lead or a user. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The Intercom identifier for the user. + */ + @JsonProperty("intercom_user_id") + public Optional getIntercomUserId() { + return intercomUserId; + } + + /** + * @return An email address for your user. An email should only be used where your application uses email to uniquely identify users. + */ + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + /** + * @return Optional metadata about the event. + */ + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataEvent && equalTo((DataEvent) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataEvent other) { + return type.equals(other.type) + && eventName.equals(other.eventName) + && createdAt == other.createdAt + && userId.equals(other.userId) + && id.equals(other.id) + && intercomUserId.equals(other.intercomUserId) + && email.equals(other.email) + && metadata.equals(other.metadata); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.eventName, + this.createdAt, + this.userId, + this.id, + this.intercomUserId, + this.email, + this.metadata); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EventNameStage builder() { + return new Builder(); + } + + public interface EventNameStage { + /** + * The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. + */ + CreatedAtStage eventName(@NotNull String eventName); + + Builder from(DataEvent other); + } + + public interface CreatedAtStage { + /** + * The time the event occurred as a UTC Unix timestamp + */ + _FinalStage createdAt(int createdAt); + } + + public interface _FinalStage { + DataEvent build(); + + /** + *

The type of the object

+ */ + _FinalStage type(Optional type); + + _FinalStage type(String type); + + /** + *

Your identifier for the user.

+ */ + _FinalStage userId(Optional userId); + + _FinalStage userId(String userId); + + /** + *

Your identifier for a lead or a user.

+ */ + _FinalStage id(Optional id); + + _FinalStage id(String id); + + /** + *

The Intercom identifier for the user.

+ */ + _FinalStage intercomUserId(Optional intercomUserId); + + _FinalStage intercomUserId(String intercomUserId); + + /** + *

An email address for your user. An email should only be used where your application uses email to uniquely identify users.

+ */ + _FinalStage email(Optional email); + + _FinalStage email(String email); + + /** + *

Optional metadata about the event.

+ */ + _FinalStage metadata(Optional> metadata); + + _FinalStage metadata(Map metadata); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EventNameStage, CreatedAtStage, _FinalStage { + private String eventName; + + private int createdAt; + + private Optional> metadata = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional intercomUserId = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional userId = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DataEvent other) { + type(other.getType()); + eventName(other.getEventName()); + createdAt(other.getCreatedAt()); + userId(other.getUserId()); + id(other.getId()); + intercomUserId(other.getIntercomUserId()); + email(other.getEmail()); + metadata(other.getMetadata()); + return this; + } + + /** + * The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`.

The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example updated-plan.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("event_name") + public CreatedAtStage eventName(@NotNull String eventName) { + this.eventName = Objects.requireNonNull(eventName, "eventName must not be null"); + return this; + } + + /** + * The time the event occurred as a UTC Unix timestamp

The time the event occurred as a UTC Unix timestamp

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public _FinalStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

Optional metadata about the event.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage metadata(Map metadata) { + this.metadata = Optional.ofNullable(metadata); + return this; + } + + /** + *

Optional metadata about the event.

+ */ + @java.lang.Override + @JsonSetter(value = "metadata", nulls = Nulls.SKIP) + public _FinalStage metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + /** + *

An email address for your user. An email should only be used where your application uses email to uniquely identify users.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage email(String email) { + this.email = Optional.ofNullable(email); + return this; + } + + /** + *

An email address for your user. An email should only be used where your application uses email to uniquely identify users.

+ */ + @java.lang.Override + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public _FinalStage email(Optional email) { + this.email = email; + return this; + } + + /** + *

The Intercom identifier for the user.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage intercomUserId(String intercomUserId) { + this.intercomUserId = Optional.ofNullable(intercomUserId); + return this; + } + + /** + *

The Intercom identifier for the user.

+ */ + @java.lang.Override + @JsonSetter(value = "intercom_user_id", nulls = Nulls.SKIP) + public _FinalStage intercomUserId(Optional intercomUserId) { + this.intercomUserId = intercomUserId; + return this; + } + + /** + *

Your identifier for a lead or a user.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

Your identifier for a lead or a user.

+ */ + @java.lang.Override + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public _FinalStage id(Optional id) { + this.id = id; + return this; + } + + /** + *

Your identifier for the user.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage userId(String userId) { + this.userId = Optional.ofNullable(userId); + return this; + } + + /** + *

Your identifier for the user.

+ */ + @java.lang.Override + @JsonSetter(value = "user_id", nulls = Nulls.SKIP) + public _FinalStage userId(Optional userId) { + this.userId = userId; + return this; + } + + /** + *

The type of the object

+ * @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; + } + + /** + *

The type of the object

+ */ + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public DataEvent build() { + return new DataEvent( + type, eventName, createdAt, userId, id, intercomUserId, email, metadata, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataevents/types/LisDataEventsRequestFilter.java b/src/main/java/com/intercom/api/resources/unstable/dataevents/types/LisDataEventsRequestFilter.java new file mode 100644 index 0000000..778caa9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataevents/types/LisDataEventsRequestFilter.java @@ -0,0 +1,371 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataevents.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +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.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonDeserialize(using = LisDataEventsRequestFilter.Deserializer.class) +public final class LisDataEventsRequestFilter { + private final Object value; + + private final int type; + + private LisDataEventsRequestFilter(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((UserId) this.value); + } else if (this.type == 1) { + return visitor.visit((IntercomUserId) this.value); + } else if (this.type == 2) { + return visitor.visit((Email) 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 LisDataEventsRequestFilter && equalTo((LisDataEventsRequestFilter) other); + } + + private boolean equalTo(LisDataEventsRequestFilter 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 LisDataEventsRequestFilter of(UserId value) { + return new LisDataEventsRequestFilter(value, 0); + } + + public static LisDataEventsRequestFilter of(IntercomUserId value) { + return new LisDataEventsRequestFilter(value, 1); + } + + public static LisDataEventsRequestFilter of(Email value) { + return new LisDataEventsRequestFilter(value, 2); + } + + public interface Visitor { + T visit(UserId value); + + T visit(IntercomUserId value); + + T visit(Email value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(LisDataEventsRequestFilter.class); + } + + @java.lang.Override + public LisDataEventsRequestFilter deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, UserId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, IntercomUserId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Email.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = IntercomUserId.Builder.class) + public static final class IntercomUserId { + private final String intercomUserId; + + private final Map additionalProperties; + + private IntercomUserId(String intercomUserId, Map additionalProperties) { + this.intercomUserId = intercomUserId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("intercom_user_id") + public String getIntercomUserId() { + return intercomUserId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof IntercomUserId && equalTo((IntercomUserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(IntercomUserId other) { + return intercomUserId.equals(other.intercomUserId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.intercomUserId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IntercomUserIdStage builder() { + return new Builder(); + } + + public interface IntercomUserIdStage { + _FinalStage intercomUserId(@NotNull String intercomUserId); + + Builder from(IntercomUserId other); + } + + public interface _FinalStage { + IntercomUserId build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IntercomUserIdStage, _FinalStage { + private String intercomUserId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(IntercomUserId other) { + intercomUserId(other.getIntercomUserId()); + return this; + } + + @java.lang.Override + @JsonSetter("intercom_user_id") + public _FinalStage intercomUserId(@NotNull String intercomUserId) { + this.intercomUserId = Objects.requireNonNull(intercomUserId, "intercomUserId must not be null"); + return this; + } + + @java.lang.Override + public IntercomUserId build() { + return new IntercomUserId(intercomUserId, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Email.Builder.class) + public static final class Email { + private final String email; + + private final Map additionalProperties; + + private Email(String email, Map additionalProperties) { + this.email = email; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("email") + public String getEmail() { + return email; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Email && equalTo((Email) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Email other) { + return email.equals(other.email); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.email); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EmailStage builder() { + return new Builder(); + } + + public interface EmailStage { + _FinalStage email(@NotNull String email); + + Builder from(Email other); + } + + public interface _FinalStage { + Email build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EmailStage, _FinalStage { + private String email; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Email other) { + email(other.getEmail()); + return this; + } + + @java.lang.Override + @JsonSetter("email") + public _FinalStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + public Email build() { + return new Email(email, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = UserId.Builder.class) + public static final class UserId { + private final String userId; + + private final Map additionalProperties; + + private UserId(String userId, Map additionalProperties) { + this.userId = userId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("user_id") + public String getUserId() { + return userId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserId && equalTo((UserId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UserId other) { + return userId.equals(other.userId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.userId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(@NotNull String userId); + + Builder from(UserId other); + } + + public interface _FinalStage { + UserId build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UserId other) { + userId(other.getUserId()); + return this; + } + + @java.lang.Override + @JsonSetter("user_id") + public _FinalStage userId(@NotNull String userId) { + this.userId = Objects.requireNonNull(userId, "userId must not be null"); + return this; + } + + @java.lang.Override + public UserId build() { + return new UserId(userId, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/AsyncDataExportClient.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/AsyncDataExportClient.java new file mode 100644 index 0000000..7906d72 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/AsyncDataExportClient.java @@ -0,0 +1,136 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataexport.requests.CancelDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.CreateDataExportsRequest; +import com.intercom.api.resources.unstable.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.GetDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.types.DataExport; +import java.util.concurrent.CompletableFuture; + +public class AsyncDataExportClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDataExportClient rawClient; + + public AsyncDataExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDataExportClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDataExportClient withRawResponse() { + return this.rawClient; + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public CompletableFuture createDataExport(CreateDataExportsRequest request) { + return this.rawClient.createDataExport(request).thenApply(response -> response.body()); + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public CompletableFuture createDataExport( + CreateDataExportsRequest request, RequestOptions requestOptions) { + return this.rawClient.createDataExport(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public CompletableFuture getDataExport(GetDataExportRequest request) { + return this.rawClient.getDataExport(request).thenApply(response -> response.body()); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public CompletableFuture getDataExport(GetDataExportRequest request, RequestOptions requestOptions) { + return this.rawClient.getDataExport(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can cancel your job + */ + public CompletableFuture cancelDataExport(CancelDataExportRequest request) { + return this.rawClient.cancelDataExport(request).thenApply(response -> response.body()); + } + + /** + * You can cancel your job + */ + public CompletableFuture cancelDataExport( + CancelDataExportRequest request, RequestOptions requestOptions) { + return this.rawClient.cancelDataExport(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public CompletableFuture downloadDataExport(DownloadDataExportRequest request) { + return this.rawClient.downloadDataExport(request).thenApply(response -> response.body()); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public CompletableFuture downloadDataExport( + DownloadDataExportRequest request, RequestOptions requestOptions) { + return this.rawClient.downloadDataExport(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/AsyncRawDataExportClient.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/AsyncRawDataExportClient.java new file mode 100644 index 0000000..874b1db --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/AsyncRawDataExportClient.java @@ -0,0 +1,322 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataexport.requests.CancelDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.CreateDataExportsRequest; +import com.intercom.api.resources.unstable.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.GetDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.types.DataExport; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDataExportClient { + protected final ClientOptions clientOptions; + + public AsyncRawDataExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public CompletableFuture> createDataExport(CreateDataExportsRequest request) { + return createDataExport(request, null); + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public CompletableFuture> createDataExport( + CreateDataExportsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DataExport.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public CompletableFuture> getDataExport(GetDataExportRequest request) { + return getDataExport(request, null); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public CompletableFuture> getDataExport( + GetDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DataExport.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can cancel your job + */ + public CompletableFuture> cancelDataExport(CancelDataExportRequest request) { + return cancelDataExport(request, null); + } + + /** + * You can cancel your job + */ + public CompletableFuture> cancelDataExport( + CancelDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/cancel") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DataExport.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public CompletableFuture> downloadDataExport(DownloadDataExportRequest request) { + return downloadDataExport(request, null); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public CompletableFuture> downloadDataExport( + DownloadDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/content/data") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/DataExportClient.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/DataExportClient.java new file mode 100644 index 0000000..e1489bf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/DataExportClient.java @@ -0,0 +1,132 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataexport.requests.CancelDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.CreateDataExportsRequest; +import com.intercom.api.resources.unstable.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.GetDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.types.DataExport; + +public class DataExportClient { + protected final ClientOptions clientOptions; + + private final RawDataExportClient rawClient; + + public DataExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawDataExportClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDataExportClient withRawResponse() { + return this.rawClient; + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public DataExport createDataExport(CreateDataExportsRequest request) { + return this.rawClient.createDataExport(request).body(); + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public DataExport createDataExport(CreateDataExportsRequest request, RequestOptions requestOptions) { + return this.rawClient.createDataExport(request, requestOptions).body(); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public DataExport getDataExport(GetDataExportRequest request) { + return this.rawClient.getDataExport(request).body(); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public DataExport getDataExport(GetDataExportRequest request, RequestOptions requestOptions) { + return this.rawClient.getDataExport(request, requestOptions).body(); + } + + /** + * You can cancel your job + */ + public DataExport cancelDataExport(CancelDataExportRequest request) { + return this.rawClient.cancelDataExport(request).body(); + } + + /** + * You can cancel your job + */ + public DataExport cancelDataExport(CancelDataExportRequest request, RequestOptions requestOptions) { + return this.rawClient.cancelDataExport(request, requestOptions).body(); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public void downloadDataExport(DownloadDataExportRequest request) { + this.rawClient.downloadDataExport(request).body(); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public void downloadDataExport(DownloadDataExportRequest request, RequestOptions requestOptions) { + this.rawClient.downloadDataExport(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/RawDataExportClient.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/RawDataExportClient.java new file mode 100644 index 0000000..06d1b88 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/RawDataExportClient.java @@ -0,0 +1,262 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.dataexport.requests.CancelDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.CreateDataExportsRequest; +import com.intercom.api.resources.unstable.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.requests.GetDataExportRequest; +import com.intercom.api.resources.unstable.dataexport.types.DataExport; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDataExportClient { + protected final ClientOptions clientOptions; + + public RawDataExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public IntercomHttpResponse createDataExport(CreateDataExportsRequest request) { + return createDataExport(request, null); + } + + /** + * To create your export job, you need to send a POST request to the export endpoint https://api.intercom.io/export/content/data. + *

The only parameters you need to provide are the range of dates that you want exported.

+ *
+ *

🚧 Limit of one active job

+ *

You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.

+ *
+ *
+ *

❗️ Updated_at not included

+ *

It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.

+ *
+ *
+ *

📘 Date ranges are inclusive

+ *

Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.

+ *
+ */ + public IntercomHttpResponse createDataExport( + CreateDataExportsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public IntercomHttpResponse getDataExport(GetDataExportRequest request) { + return getDataExport(request, null); + } + + /** + * You can view the status of your job by sending a GET request to the URL + * https://api.intercom.io/export/content/data/{job_identifier} - the {job_identifier} is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + *
+ *

🚧 Jobs expire after two days + * All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.

+ *
+ */ + public IntercomHttpResponse getDataExport(GetDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/content/data") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can cancel your job + */ + public IntercomHttpResponse cancelDataExport(CancelDataExportRequest request) { + return cancelDataExport(request, null); + } + + /** + * You can cancel your job + */ + public IntercomHttpResponse cancelDataExport( + CancelDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/cancel") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public IntercomHttpResponse downloadDataExport(DownloadDataExportRequest request) { + return downloadDataExport(request, null); + } + + /** + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + *

Your exported message data will be streamed continuously back down to you in a gzipped CSV format.

+ *
+ *

📘 Octet header required

+ *

You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

+ *
+ */ + public IntercomHttpResponse downloadDataExport( + DownloadDataExportRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/content/data") + .addPathSegment(request.getJobIdentifier()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/CancelDataExportRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/CancelDataExportRequest.java new file mode 100644 index 0000000..a219ccd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/CancelDataExportRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CancelDataExportRequest.Builder.class) +public final class CancelDataExportRequest { + private final String jobIdentifier; + + private final Map additionalProperties; + + private CancelDataExportRequest(String jobIdentifier, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.additionalProperties = additionalProperties; + } + + /** + * @return job_identifier + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CancelDataExportRequest && equalTo((CancelDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CancelDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + /** + * job_identifier + */ + _FinalStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(CancelDataExportRequest other); + } + + public interface _FinalStage { + CancelDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, _FinalStage { + private String jobIdentifier; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CancelDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + return this; + } + + /** + * job_identifier

job_identifier

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public _FinalStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + public CancelDataExportRequest build() { + return new CancelDataExportRequest(jobIdentifier, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/CreateDataExportsRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/CreateDataExportsRequest.java new file mode 100644 index 0000000..d7bbbaf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/CreateDataExportsRequest.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateDataExportsRequest.Builder.class) +public final class CreateDataExportsRequest { + private final int createdAtAfter; + + private final int createdAtBefore; + + private final Map additionalProperties; + + private CreateDataExportsRequest( + int createdAtAfter, int createdAtBefore, Map additionalProperties) { + this.createdAtAfter = createdAtAfter; + this.createdAtBefore = createdAtBefore; + this.additionalProperties = additionalProperties; + } + + /** + * @return The start date that you request data for. It must be formatted as a unix timestamp. + */ + @JsonProperty("created_at_after") + public int getCreatedAtAfter() { + return createdAtAfter; + } + + /** + * @return The end date that you request data for. It must be formatted as a unix timestamp. + */ + @JsonProperty("created_at_before") + public int getCreatedAtBefore() { + return createdAtBefore; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateDataExportsRequest && equalTo((CreateDataExportsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateDataExportsRequest other) { + return createdAtAfter == other.createdAtAfter && createdAtBefore == other.createdAtBefore; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.createdAtAfter, this.createdAtBefore); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CreatedAtAfterStage builder() { + return new Builder(); + } + + public interface CreatedAtAfterStage { + /** + * The start date that you request data for. It must be formatted as a unix timestamp. + */ + CreatedAtBeforeStage createdAtAfter(int createdAtAfter); + + Builder from(CreateDataExportsRequest other); + } + + public interface CreatedAtBeforeStage { + /** + * The end date that you request data for. It must be formatted as a unix timestamp. + */ + _FinalStage createdAtBefore(int createdAtBefore); + } + + public interface _FinalStage { + CreateDataExportsRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CreatedAtAfterStage, CreatedAtBeforeStage, _FinalStage { + private int createdAtAfter; + + private int createdAtBefore; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateDataExportsRequest other) { + createdAtAfter(other.getCreatedAtAfter()); + createdAtBefore(other.getCreatedAtBefore()); + return this; + } + + /** + * The start date that you request data for. It must be formatted as a unix timestamp.

The start date that you request data for. It must be formatted as a unix timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at_after") + public CreatedAtBeforeStage createdAtAfter(int createdAtAfter) { + this.createdAtAfter = createdAtAfter; + return this; + } + + /** + * The end date that you request data for. It must be formatted as a unix timestamp.

The end date that you request data for. It must be formatted as a unix timestamp.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at_before") + public _FinalStage createdAtBefore(int createdAtBefore) { + this.createdAtBefore = createdAtBefore; + return this; + } + + @java.lang.Override + public CreateDataExportsRequest build() { + return new CreateDataExportsRequest(createdAtAfter, createdAtBefore, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/DownloadDataExportRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/DownloadDataExportRequest.java new file mode 100644 index 0000000..415c9b2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/DownloadDataExportRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DownloadDataExportRequest.Builder.class) +public final class DownloadDataExportRequest { + private final String jobIdentifier; + + private final Map additionalProperties; + + private DownloadDataExportRequest(String jobIdentifier, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.additionalProperties = additionalProperties; + } + + /** + * @return job_identifier + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DownloadDataExportRequest && equalTo((DownloadDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DownloadDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + /** + * job_identifier + */ + _FinalStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(DownloadDataExportRequest other); + } + + public interface _FinalStage { + DownloadDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, _FinalStage { + private String jobIdentifier; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DownloadDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + return this; + } + + /** + * job_identifier

job_identifier

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public _FinalStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + public DownloadDataExportRequest build() { + return new DownloadDataExportRequest(jobIdentifier, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/GetDataExportRequest.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/GetDataExportRequest.java new file mode 100644 index 0000000..7e6e0ff --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/requests/GetDataExportRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetDataExportRequest.Builder.class) +public final class GetDataExportRequest { + private final String jobIdentifier; + + private final Map additionalProperties; + + private GetDataExportRequest(String jobIdentifier, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.additionalProperties = additionalProperties; + } + + /** + * @return job_identifier + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetDataExportRequest && equalTo((GetDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + /** + * job_identifier + */ + _FinalStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(GetDataExportRequest other); + } + + public interface _FinalStage { + GetDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, _FinalStage { + private String jobIdentifier; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + return this; + } + + /** + * job_identifier

job_identifier

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public _FinalStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + public GetDataExportRequest build() { + return new GetDataExportRequest(jobIdentifier, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/dataexport/types/DataExport.java b/src/main/java/com/intercom/api/resources/unstable/dataexport/types/DataExport.java new file mode 100644 index 0000000..3d414b1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/dataexport/types/DataExport.java @@ -0,0 +1,310 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.dataexport.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DataExport.Builder.class) +public final class DataExport { + private final Optional jobIdentfier; + + private final Optional status; + + private final Optional downloadExpiresAt; + + private final Optional downloadUrl; + + private final Map additionalProperties; + + private DataExport( + Optional jobIdentfier, + Optional status, + Optional downloadExpiresAt, + Optional downloadUrl, + Map additionalProperties) { + this.jobIdentfier = jobIdentfier; + this.status = status; + this.downloadExpiresAt = downloadExpiresAt; + this.downloadUrl = downloadUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for your job. + */ + @JsonProperty("job_identfier") + public Optional getJobIdentfier() { + return jobIdentfier; + } + + /** + * @return The current state of your job. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The time after which you will not be able to access the data. + */ + @JsonProperty("download_expires_at") + public Optional getDownloadExpiresAt() { + return downloadExpiresAt; + } + + /** + * @return The location where you can download your data. + */ + @JsonProperty("download_url") + public Optional getDownloadUrl() { + return downloadUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataExport && equalTo((DataExport) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataExport other) { + return jobIdentfier.equals(other.jobIdentfier) + && status.equals(other.status) + && downloadExpiresAt.equals(other.downloadExpiresAt) + && downloadUrl.equals(other.downloadUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentfier, this.status, this.downloadExpiresAt, this.downloadUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional jobIdentfier = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional downloadExpiresAt = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DataExport other) { + jobIdentfier(other.getJobIdentfier()); + status(other.getStatus()); + downloadExpiresAt(other.getDownloadExpiresAt()); + downloadUrl(other.getDownloadUrl()); + return this; + } + + /** + *

The identifier for your job.

+ */ + @JsonSetter(value = "job_identfier", nulls = Nulls.SKIP) + public Builder jobIdentfier(Optional jobIdentfier) { + this.jobIdentfier = jobIdentfier; + return this; + } + + public Builder jobIdentfier(String jobIdentfier) { + this.jobIdentfier = Optional.ofNullable(jobIdentfier); + return this; + } + + /** + *

The current state of your job.

+ */ + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(Status status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

The time after which you will not be able to access the data.

+ */ + @JsonSetter(value = "download_expires_at", nulls = Nulls.SKIP) + public Builder downloadExpiresAt(Optional downloadExpiresAt) { + this.downloadExpiresAt = downloadExpiresAt; + return this; + } + + public Builder downloadExpiresAt(String downloadExpiresAt) { + this.downloadExpiresAt = Optional.ofNullable(downloadExpiresAt); + return this; + } + + /** + *

The location where you can download your data.

+ */ + @JsonSetter(value = "download_url", nulls = Nulls.SKIP) + public Builder downloadUrl(Optional downloadUrl) { + this.downloadUrl = downloadUrl; + return this; + } + + public Builder downloadUrl(String downloadUrl) { + this.downloadUrl = Optional.ofNullable(downloadUrl); + return this; + } + + public DataExport build() { + return new DataExport(jobIdentfier, status, downloadExpiresAt, downloadUrl, additionalProperties); + } + } + + public static final class Status { + public static final Status FAILED = new Status(Value.FAILED, "failed"); + + public static final Status COMPLETED = new Status(Value.COMPLETED, "completed"); + + public static final Status NO_DATA = new Status(Value.NO_DATA, "no_data"); + + public static final Status PENDING = new Status(Value.PENDING, "pending"); + + public static final Status IN_PROGRESS = new Status(Value.IN_PROGRESS, "in_progress"); + + public static final Status CANCELED = new Status(Value.CANCELED, "canceled"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FAILED: + return visitor.visitFailed(); + case COMPLETED: + return visitor.visitCompleted(); + case NO_DATA: + return visitor.visitNoData(); + case PENDING: + return visitor.visitPending(); + case IN_PROGRESS: + return visitor.visitInProgress(); + case CANCELED: + return visitor.visitCanceled(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "failed": + return FAILED; + case "completed": + return COMPLETED; + case "no_data": + return NO_DATA; + case "pending": + return PENDING; + case "in_progress": + return IN_PROGRESS; + case "canceled": + return CANCELED; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + PENDING, + + IN_PROGRESS, + + FAILED, + + COMPLETED, + + NO_DATA, + + CANCELED, + + UNKNOWN + } + + public interface Visitor { + T visitPending(); + + T visitInProgress(); + + T visitFailed(); + + T visitCompleted(); + + T visitNoData(); + + T visitCanceled(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/errors/BadRequestError.java b/src/main/java/com/intercom/api/resources/unstable/errors/BadRequestError.java new file mode 100644 index 0000000..df7dee0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/errors/BadRequestError.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.errors; + +import com.intercom.api.core.IntercomApiException; +import okhttp3.Response; + +public final class BadRequestError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public BadRequestError(Object body) { + super("BadRequestError", 400, body); + this.body = body; + } + + public BadRequestError(Object body, Response rawResponse) { + super("BadRequestError", 400, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/errors/ForbiddenError.java b/src/main/java/com/intercom/api/resources/unstable/errors/ForbiddenError.java new file mode 100644 index 0000000..2a2e184 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/errors/ForbiddenError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.errors; + +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.resources.unstable.types.Error; +import okhttp3.Response; + +public final class ForbiddenError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public ForbiddenError(Error body) { + super("ForbiddenError", 403, body); + this.body = body; + } + + public ForbiddenError(Error body, Response rawResponse) { + super("ForbiddenError", 403, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/errors/InternalServerError.java b/src/main/java/com/intercom/api/resources/unstable/errors/InternalServerError.java new file mode 100644 index 0000000..a6a55ba --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/errors/InternalServerError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.errors; + +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.resources.unstable.types.Error; +import okhttp3.Response; + +public final class InternalServerError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public InternalServerError(Error body) { + super("InternalServerError", 500, body); + this.body = body; + } + + public InternalServerError(Error body, Response rawResponse) { + super("InternalServerError", 500, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/errors/NotFoundError.java b/src/main/java/com/intercom/api/resources/unstable/errors/NotFoundError.java new file mode 100644 index 0000000..395344f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/errors/NotFoundError.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.errors; + +import com.intercom.api.core.IntercomApiException; +import okhttp3.Response; + +public final class NotFoundError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public NotFoundError(Object body) { + super("NotFoundError", 404, body); + this.body = body; + } + + public NotFoundError(Object body, Response rawResponse) { + super("NotFoundError", 404, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/errors/TooManyRequestsError.java b/src/main/java/com/intercom/api/resources/unstable/errors/TooManyRequestsError.java new file mode 100644 index 0000000..c812cc0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/errors/TooManyRequestsError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.errors; + +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.resources.unstable.types.Error; +import okhttp3.Response; + +public final class TooManyRequestsError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public TooManyRequestsError(Error body) { + super("TooManyRequestsError", 429, body); + this.body = body; + } + + public TooManyRequestsError(Error body, Response rawResponse) { + super("TooManyRequestsError", 429, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/errors/UnauthorizedError.java b/src/main/java/com/intercom/api/resources/unstable/errors/UnauthorizedError.java new file mode 100644 index 0000000..a81641b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/errors/UnauthorizedError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.errors; + +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.resources.unstable.types.Error; +import okhttp3.Response; + +public final class UnauthorizedError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Error body; + + public UnauthorizedError(Error body) { + super("UnauthorizedError", 401, body); + this.body = body; + } + + public UnauthorizedError(Error body, Response rawResponse) { + super("UnauthorizedError", 401, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Error body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/errors/UnprocessableEntityError.java b/src/main/java/com/intercom/api/resources/unstable/errors/UnprocessableEntityError.java new file mode 100644 index 0000000..d96c967 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/errors/UnprocessableEntityError.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.errors; + +import com.intercom.api.core.IntercomApiException; +import okhttp3.Response; + +public final class UnprocessableEntityError extends IntercomApiException { + /** + * The body of the response that triggered the exception. + */ + private final Object body; + + public UnprocessableEntityError(Object body) { + super("UnprocessableEntityError", 422, body); + this.body = body; + } + + public UnprocessableEntityError(Object body, Response rawResponse) { + super("UnprocessableEntityError", 422, body, rawResponse); + this.body = body; + } + + /** + * @return the body + */ + @java.lang.Override + public Object body() { + return this.body; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/export/AsyncExportClient.java b/src/main/java/com/intercom/api/resources/unstable/export/AsyncExportClient.java new file mode 100644 index 0000000..1fdc889 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/export/AsyncExportClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.export; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.unstable.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.unstable.export.types.PostExportReportingDataEnqueueResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncExportClient { + protected final ClientOptions clientOptions; + + private final AsyncRawExportClient rawClient; + + public AsyncExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawExportClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawExportClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request) { + return this.rawClient.enqueueANewReportingDataExportJob(request).thenApply(response -> response.body()); + } + + public CompletableFuture enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + return this.rawClient + .enqueueANewReportingDataExportJob(request, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture listAvailableDatasetsAndAttributes() { + return this.rawClient.listAvailableDatasetsAndAttributes().thenApply(response -> response.body()); + } + + public CompletableFuture listAvailableDatasetsAndAttributes( + RequestOptions requestOptions) { + return this.rawClient.listAvailableDatasetsAndAttributes(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/export/AsyncRawExportClient.java b/src/main/java/com/intercom/api/resources/unstable/export/AsyncRawExportClient.java new file mode 100644 index 0000000..500c6c2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/export/AsyncRawExportClient.java @@ -0,0 +1,179 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.export; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.TooManyRequestsError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.unstable.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.unstable.export.types.PostExportReportingDataEnqueueResponse; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawExportClient { + protected final ClientOptions clientOptions; + + public AsyncRawExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> + enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest request) { + return enqueueANewReportingDataExportJob(request, null); + } + + public CompletableFuture> + enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), PostExportReportingDataEnqueueResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 429: + future.completeExceptionally(new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> + listAvailableDatasetsAndAttributes() { + return listAvailableDatasetsAndAttributes(null); + } + + public CompletableFuture> + listAvailableDatasetsAndAttributes(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/get_datasets") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), GetExportReportingDataGetDatasetsResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/export/ExportClient.java b/src/main/java/com/intercom/api/resources/unstable/export/ExportClient.java new file mode 100644 index 0000000..86411ea --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/export/ExportClient.java @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.export; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.unstable.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.unstable.export.types.PostExportReportingDataEnqueueResponse; + +public class ExportClient { + protected final ClientOptions clientOptions; + + private final RawExportClient rawClient; + + public ExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawExportClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawExportClient withRawResponse() { + return this.rawClient; + } + + public PostExportReportingDataEnqueueResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request) { + return this.rawClient.enqueueANewReportingDataExportJob(request).body(); + } + + public PostExportReportingDataEnqueueResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + return this.rawClient + .enqueueANewReportingDataExportJob(request, requestOptions) + .body(); + } + + public GetExportReportingDataGetDatasetsResponse listAvailableDatasetsAndAttributes() { + return this.rawClient.listAvailableDatasetsAndAttributes().body(); + } + + public GetExportReportingDataGetDatasetsResponse listAvailableDatasetsAndAttributes(RequestOptions requestOptions) { + return this.rawClient.listAvailableDatasetsAndAttributes(requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/export/RawExportClient.java b/src/main/java/com/intercom/api/resources/unstable/export/RawExportClient.java new file mode 100644 index 0000000..062c0e1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/export/RawExportClient.java @@ -0,0 +1,139 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.export; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.TooManyRequestsError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.unstable.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.unstable.export.types.PostExportReportingDataEnqueueResponse; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawExportClient { + protected final ClientOptions clientOptions; + + public RawExportClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public IntercomHttpResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request) { + return enqueueANewReportingDataExportJob(request, null); + } + + public IntercomHttpResponse enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PostExportReportingDataEnqueueResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 429: + throw new TooManyRequestsError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public IntercomHttpResponse listAvailableDatasetsAndAttributes() { + return listAvailableDatasetsAndAttributes(null); + } + + public IntercomHttpResponse listAvailableDatasetsAndAttributes( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data/get_datasets") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GetExportReportingDataGetDatasetsResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/export/requests/PostExportReportingDataEnqueueRequest.java b/src/main/java/com/intercom/api/resources/unstable/export/requests/PostExportReportingDataEnqueueRequest.java new file mode 100644 index 0000000..4b8d510 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/export/requests/PostExportReportingDataEnqueueRequest.java @@ -0,0 +1,196 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.export.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PostExportReportingDataEnqueueRequest.Builder.class) +public final class PostExportReportingDataEnqueueRequest { + private final String datasetId; + + private final List attributeIds; + + private final long startTime; + + private final long endTime; + + private final Map additionalProperties; + + private PostExportReportingDataEnqueueRequest( + String datasetId, + List attributeIds, + long startTime, + long endTime, + Map additionalProperties) { + this.datasetId = datasetId; + this.attributeIds = attributeIds; + this.startTime = startTime; + this.endTime = endTime; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("dataset_id") + public String getDatasetId() { + return datasetId; + } + + @JsonProperty("attribute_ids") + public List getAttributeIds() { + return attributeIds; + } + + @JsonProperty("start_time") + public long getStartTime() { + return startTime; + } + + @JsonProperty("end_time") + public long getEndTime() { + return endTime; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PostExportReportingDataEnqueueRequest + && equalTo((PostExportReportingDataEnqueueRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PostExportReportingDataEnqueueRequest other) { + return datasetId.equals(other.datasetId) + && attributeIds.equals(other.attributeIds) + && startTime == other.startTime + && endTime == other.endTime; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.datasetId, this.attributeIds, this.startTime, this.endTime); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DatasetIdStage builder() { + return new Builder(); + } + + public interface DatasetIdStage { + StartTimeStage datasetId(@NotNull String datasetId); + + Builder from(PostExportReportingDataEnqueueRequest other); + } + + public interface StartTimeStage { + EndTimeStage startTime(long startTime); + } + + public interface EndTimeStage { + _FinalStage endTime(long endTime); + } + + public interface _FinalStage { + PostExportReportingDataEnqueueRequest build(); + + _FinalStage attributeIds(List attributeIds); + + _FinalStage addAttributeIds(String attributeIds); + + _FinalStage addAllAttributeIds(List attributeIds); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DatasetIdStage, StartTimeStage, EndTimeStage, _FinalStage { + private String datasetId; + + private long startTime; + + private long endTime; + + private List attributeIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PostExportReportingDataEnqueueRequest other) { + datasetId(other.getDatasetId()); + attributeIds(other.getAttributeIds()); + startTime(other.getStartTime()); + endTime(other.getEndTime()); + return this; + } + + @java.lang.Override + @JsonSetter("dataset_id") + public StartTimeStage datasetId(@NotNull String datasetId) { + this.datasetId = Objects.requireNonNull(datasetId, "datasetId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("start_time") + public EndTimeStage startTime(long startTime) { + this.startTime = startTime; + return this; + } + + @java.lang.Override + @JsonSetter("end_time") + public _FinalStage endTime(long endTime) { + this.endTime = endTime; + return this; + } + + @java.lang.Override + public _FinalStage addAllAttributeIds(List attributeIds) { + this.attributeIds.addAll(attributeIds); + return this; + } + + @java.lang.Override + public _FinalStage addAttributeIds(String attributeIds) { + this.attributeIds.add(attributeIds); + return this; + } + + @java.lang.Override + @JsonSetter(value = "attribute_ids", nulls = Nulls.SKIP) + public _FinalStage attributeIds(List attributeIds) { + this.attributeIds.clear(); + this.attributeIds.addAll(attributeIds); + return this; + } + + @java.lang.Override + public PostExportReportingDataEnqueueRequest build() { + return new PostExportReportingDataEnqueueRequest( + datasetId, attributeIds, startTime, endTime, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/export/types/GetExportReportingDataGetDatasetsResponse.java b/src/main/java/com/intercom/api/resources/unstable/export/types/GetExportReportingDataGetDatasetsResponse.java new file mode 100644 index 0000000..22819b7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/export/types/GetExportReportingDataGetDatasetsResponse.java @@ -0,0 +1,395 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.export.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetExportReportingDataGetDatasetsResponse.Builder.class) +public final class GetExportReportingDataGetDatasetsResponse { + private final Optional type; + + private final Optional> data; + + private final Map additionalProperties; + + private GetExportReportingDataGetDatasetsResponse( + Optional type, Optional> data, Map additionalProperties) { + this.type = type; + this.data = data; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetExportReportingDataGetDatasetsResponse + && equalTo((GetExportReportingDataGetDatasetsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetExportReportingDataGetDatasetsResponse other) { + return type.equals(other.type) && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(GetExportReportingDataGetDatasetsResponse other) { + type(other.getType()); + data(other.getData()); + return this; + } + + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public GetExportReportingDataGetDatasetsResponse build() { + return new GetExportReportingDataGetDatasetsResponse(type, data, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = DataItem.Builder.class) + public static final class DataItem { + private final Optional id; + + private final Optional name; + + private final Optional description; + + private final Optional defaultTimeAttributeId; + + private final Optional> attributes; + + private final Map additionalProperties; + + private DataItem( + Optional id, + Optional name, + Optional description, + Optional defaultTimeAttributeId, + Optional> attributes, + Map additionalProperties) { + this.id = id; + this.name = name; + this.description = description; + this.defaultTimeAttributeId = defaultTimeAttributeId; + this.attributes = attributes; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("default_time_attribute_id") + public Optional getDefaultTimeAttributeId() { + return defaultTimeAttributeId; + } + + @JsonProperty("attributes") + public Optional> getAttributes() { + return attributes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DataItem && equalTo((DataItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataItem other) { + return id.equals(other.id) + && name.equals(other.name) + && description.equals(other.description) + && defaultTimeAttributeId.equals(other.defaultTimeAttributeId) + && attributes.equals(other.attributes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.description, this.defaultTimeAttributeId, this.attributes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional defaultTimeAttributeId = Optional.empty(); + + private Optional> attributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DataItem other) { + id(other.getId()); + name(other.getName()); + description(other.getDescription()); + defaultTimeAttributeId(other.getDefaultTimeAttributeId()); + attributes(other.getAttributes()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + @JsonSetter(value = "default_time_attribute_id", nulls = Nulls.SKIP) + public Builder defaultTimeAttributeId(Optional defaultTimeAttributeId) { + this.defaultTimeAttributeId = defaultTimeAttributeId; + return this; + } + + public Builder defaultTimeAttributeId(String defaultTimeAttributeId) { + this.defaultTimeAttributeId = Optional.ofNullable(defaultTimeAttributeId); + return this; + } + + @JsonSetter(value = "attributes", nulls = Nulls.SKIP) + public Builder attributes(Optional> attributes) { + this.attributes = attributes; + return this; + } + + public Builder attributes(List attributes) { + this.attributes = Optional.ofNullable(attributes); + return this; + } + + public DataItem build() { + return new DataItem(id, name, description, defaultTimeAttributeId, attributes, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = AttributesItem.Builder.class) + public static final class AttributesItem { + private final Optional id; + + private final Optional name; + + private final Map additionalProperties; + + private AttributesItem( + Optional id, Optional name, Map additionalProperties) { + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttributesItem && equalTo((AttributesItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttributesItem other) { + return id.equals(other.id) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AttributesItem other) { + id(other.getId()); + name(other.getName()); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + public AttributesItem build() { + return new AttributesItem(id, name, additionalProperties); + } + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/export/types/PostExportReportingDataEnqueueResponse.java b/src/main/java/com/intercom/api/resources/unstable/export/types/PostExportReportingDataEnqueueResponse.java new file mode 100644 index 0000000..8f255b4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/export/types/PostExportReportingDataEnqueueResponse.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.export.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PostExportReportingDataEnqueueResponse.Builder.class) +public final class PostExportReportingDataEnqueueResponse { + private final Optional jobIdentifier; + + private final Optional status; + + private final Optional downloadUrl; + + private final Optional downloadExpiresAt; + + private final Map additionalProperties; + + private PostExportReportingDataEnqueueResponse( + Optional jobIdentifier, + Optional status, + Optional downloadUrl, + Optional downloadExpiresAt, + Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.status = status; + this.downloadUrl = downloadUrl; + this.downloadExpiresAt = downloadExpiresAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("job_identifier") + public Optional getJobIdentifier() { + return jobIdentifier; + } + + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + @JsonProperty("download_url") + public Optional getDownloadUrl() { + return downloadUrl; + } + + @JsonProperty("download_expires_at") + public Optional getDownloadExpiresAt() { + return downloadExpiresAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PostExportReportingDataEnqueueResponse + && equalTo((PostExportReportingDataEnqueueResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PostExportReportingDataEnqueueResponse other) { + return jobIdentifier.equals(other.jobIdentifier) + && status.equals(other.status) + && downloadUrl.equals(other.downloadUrl) + && downloadExpiresAt.equals(other.downloadExpiresAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.status, this.downloadUrl, this.downloadExpiresAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional jobIdentifier = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional downloadUrl = Optional.empty(); + + private Optional downloadExpiresAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PostExportReportingDataEnqueueResponse other) { + jobIdentifier(other.getJobIdentifier()); + status(other.getStatus()); + downloadUrl(other.getDownloadUrl()); + downloadExpiresAt(other.getDownloadExpiresAt()); + return this; + } + + @JsonSetter(value = "job_identifier", nulls = Nulls.SKIP) + public Builder jobIdentifier(Optional jobIdentifier) { + this.jobIdentifier = jobIdentifier; + return this; + } + + public Builder jobIdentifier(String jobIdentifier) { + this.jobIdentifier = Optional.ofNullable(jobIdentifier); + return this; + } + + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(String status) { + this.status = Optional.ofNullable(status); + return this; + } + + @JsonSetter(value = "download_url", nulls = Nulls.SKIP) + public Builder downloadUrl(Optional downloadUrl) { + this.downloadUrl = downloadUrl; + return this; + } + + public Builder downloadUrl(String downloadUrl) { + this.downloadUrl = Optional.ofNullable(downloadUrl); + return this; + } + + @JsonSetter(value = "download_expires_at", nulls = Nulls.SKIP) + public Builder downloadExpiresAt(Optional downloadExpiresAt) { + this.downloadExpiresAt = downloadExpiresAt; + return this; + } + + public Builder downloadExpiresAt(String downloadExpiresAt) { + this.downloadExpiresAt = Optional.ofNullable(downloadExpiresAt); + return this; + } + + public PostExportReportingDataEnqueueResponse build() { + return new PostExportReportingDataEnqueueResponse( + jobIdentifier, status, downloadUrl, downloadExpiresAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/AsyncHelpCenterClient.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/AsyncHelpCenterClient.java new file mode 100644 index 0000000..0539478 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/AsyncHelpCenterClient.java @@ -0,0 +1,141 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.helpcenter.requests.CreateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.DeleteCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveHelpCenterRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.UpdateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.types.Collection; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenter; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenterList; +import com.intercom.api.resources.unstable.types.CollectionList; +import com.intercom.api.resources.unstable.types.DeletedCollectionObject; +import java.util.concurrent.CompletableFuture; + +public class AsyncHelpCenterClient { + protected final ClientOptions clientOptions; + + private final AsyncRawHelpCenterClient rawClient; + + public AsyncHelpCenterClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawHelpCenterClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawHelpCenterClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CompletableFuture listAllCollections() { + return this.rawClient.listAllCollections().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CompletableFuture listAllCollections(RequestOptions requestOptions) { + return this.rawClient.listAllCollections(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public CompletableFuture createCollection(CreateCollectionRequest request) { + return this.rawClient.createCollection(request).thenApply(response -> response.body()); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public CompletableFuture createCollection( + CreateCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.createCollection(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public CompletableFuture retrieveCollection(RetrieveCollectionRequest request) { + return this.rawClient.retrieveCollection(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public CompletableFuture retrieveCollection( + RetrieveCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveCollection(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture updateCollection(UpdateCollectionRequest request) { + return this.rawClient.updateCollection(request).thenApply(response -> response.body()); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture updateCollection( + UpdateCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.updateCollection(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture deleteCollection(DeleteCollectionRequest request) { + return this.rawClient.deleteCollection(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture deleteCollection( + DeleteCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteCollection(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public CompletableFuture retrieveHelpCenter(RetrieveHelpCenterRequest request) { + return this.rawClient.retrieveHelpCenter(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public CompletableFuture retrieveHelpCenter( + RetrieveHelpCenterRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveHelpCenter(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public CompletableFuture listHelpCenters() { + return this.rawClient.listHelpCenters().thenApply(response -> response.body()); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public CompletableFuture listHelpCenters(RequestOptions requestOptions) { + return this.rawClient.listHelpCenters(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/AsyncRawHelpCenterClient.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/AsyncRawHelpCenterClient.java new file mode 100644 index 0000000..25c6cf7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/AsyncRawHelpCenterClient.java @@ -0,0 +1,571 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.helpcenter.requests.CreateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.DeleteCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveHelpCenterRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.UpdateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.types.Collection; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenter; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenterList; +import com.intercom.api.resources.unstable.types.CollectionList; +import com.intercom.api.resources.unstable.types.DeletedCollectionObject; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawHelpCenterClient { + protected final ClientOptions clientOptions; + + public AsyncRawHelpCenterClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CompletableFuture> listAllCollections() { + return listAllCollections(null); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CompletableFuture> listAllCollections(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), CollectionList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public CompletableFuture> createCollection(CreateCollectionRequest request) { + return createCollection(request, null); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public CompletableFuture> createCollection( + CreateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Collection.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public CompletableFuture> retrieveCollection(RetrieveCollectionRequest request) { + return retrieveCollection(request, null); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public CompletableFuture> retrieveCollection( + RetrieveCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Collection.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture> updateCollection(UpdateCollectionRequest request) { + return updateCollection(request, null); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture> updateCollection( + UpdateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(Integer.toString(request.getId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Collection.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture> deleteCollection( + DeleteCollectionRequest request) { + return deleteCollection(request, null); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public CompletableFuture> deleteCollection( + DeleteCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DeletedCollectionObject.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public CompletableFuture> retrieveHelpCenter(RetrieveHelpCenterRequest request) { + return retrieveHelpCenter(request, null); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public CompletableFuture> retrieveHelpCenter( + RetrieveHelpCenterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), HelpCenter.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public CompletableFuture> listHelpCenters() { + return listHelpCenters(null); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public CompletableFuture> listHelpCenters(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), HelpCenterList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/HelpCenterClient.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/HelpCenterClient.java new file mode 100644 index 0000000..3771cd9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/HelpCenterClient.java @@ -0,0 +1,135 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.helpcenter.requests.CreateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.DeleteCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveHelpCenterRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.UpdateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.types.Collection; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenter; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenterList; +import com.intercom.api.resources.unstable.types.CollectionList; +import com.intercom.api.resources.unstable.types.DeletedCollectionObject; + +public class HelpCenterClient { + protected final ClientOptions clientOptions; + + private final RawHelpCenterClient rawClient; + + public HelpCenterClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawHelpCenterClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawHelpCenterClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CollectionList listAllCollections() { + return this.rawClient.listAllCollections().body(); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public CollectionList listAllCollections(RequestOptions requestOptions) { + return this.rawClient.listAllCollections(requestOptions).body(); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public Collection createCollection(CreateCollectionRequest request) { + return this.rawClient.createCollection(request).body(); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public Collection createCollection(CreateCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.createCollection(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public Collection retrieveCollection(RetrieveCollectionRequest request) { + return this.rawClient.retrieveCollection(request).body(); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public Collection retrieveCollection(RetrieveCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveCollection(request, requestOptions).body(); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public Collection updateCollection(UpdateCollectionRequest request) { + return this.rawClient.updateCollection(request).body(); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public Collection updateCollection(UpdateCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.updateCollection(request, requestOptions).body(); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public DeletedCollectionObject deleteCollection(DeleteCollectionRequest request) { + return this.rawClient.deleteCollection(request).body(); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public DeletedCollectionObject deleteCollection(DeleteCollectionRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteCollection(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public HelpCenter retrieveHelpCenter(RetrieveHelpCenterRequest request) { + return this.rawClient.retrieveHelpCenter(request).body(); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public HelpCenter retrieveHelpCenter(RetrieveHelpCenterRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveHelpCenter(request, requestOptions).body(); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public HelpCenterList listHelpCenters() { + return this.rawClient.listHelpCenters().body(); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public HelpCenterList listHelpCenters(RequestOptions requestOptions) { + return this.rawClient.listHelpCenters(requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/RawHelpCenterClient.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/RawHelpCenterClient.java new file mode 100644 index 0000000..2395ab1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/RawHelpCenterClient.java @@ -0,0 +1,446 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.helpcenter.requests.CreateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.DeleteCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.RetrieveHelpCenterRequest; +import com.intercom.api.resources.unstable.helpcenter.requests.UpdateCollectionRequest; +import com.intercom.api.resources.unstable.helpcenter.types.Collection; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenter; +import com.intercom.api.resources.unstable.helpcenter.types.HelpCenterList; +import com.intercom.api.resources.unstable.types.CollectionList; +import com.intercom.api.resources.unstable.types.DeletedCollectionObject; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawHelpCenterClient { + protected final ClientOptions clientOptions; + + public RawHelpCenterClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public IntercomHttpResponse listAllCollections() { + return listAllCollections(null); + } + + /** + * You can fetch a list of all collections by making a GET request to https://api.intercom.io/help_center/collections. + *

Collections will be returned in descending order on the updated_at attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

+ */ + public IntercomHttpResponse listAllCollections(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CollectionList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public IntercomHttpResponse createCollection(CreateCollectionRequest request) { + return createCollection(request, null); + } + + /** + * You can create a new collection by making a POST request to https://api.intercom.io/help_center/collections. + */ + public IntercomHttpResponse createCollection( + CreateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public IntercomHttpResponse retrieveCollection(RetrieveCollectionRequest request) { + return retrieveCollection(request, null); + } + + /** + * You can fetch the details of a single collection by making a GET request to https://api.intercom.io/help_center/collections/<id>. + */ + public IntercomHttpResponse retrieveCollection( + RetrieveCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public IntercomHttpResponse updateCollection(UpdateCollectionRequest request) { + return updateCollection(request, null); + } + + /** + * You can update the details of a single collection by making a PUT request to https://api.intercom.io/collections/<id>. + */ + public IntercomHttpResponse updateCollection( + UpdateCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(Integer.toString(request.getId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public IntercomHttpResponse deleteCollection(DeleteCollectionRequest request) { + return deleteCollection(request, null); + } + + /** + * You can delete a single collection by making a DELETE request to https://api.intercom.io/collections/<id>. + */ + public IntercomHttpResponse deleteCollection( + DeleteCollectionRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/collections") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCollectionObject.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public IntercomHttpResponse retrieveHelpCenter(RetrieveHelpCenterRequest request) { + return retrieveHelpCenter(request, null); + } + + /** + * You can fetch the details of a single Help Center by making a GET request to https://api.intercom.io/help_center/help_center/<id>. + */ + public IntercomHttpResponse retrieveHelpCenter( + RetrieveHelpCenterRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenter.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public IntercomHttpResponse listHelpCenters() { + return listHelpCenters(null); + } + + /** + * You can list all Help Centers by making a GET request to https://api.intercom.io/help_center/help_centers. + */ + public IntercomHttpResponse listHelpCenters(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("help_center/help_centers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenterList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/CreateCollectionRequest.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/CreateCollectionRequest.java new file mode 100644 index 0000000..31d9258 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/CreateCollectionRequest.java @@ -0,0 +1,277 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.GroupTranslatedContent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateCollectionRequest.Builder.class) +public final class CreateCollectionRequest { + private final String name; + + private final Optional description; + + private final Optional translatedContent; + + private final Optional parentId; + + private final Optional helpCenterId; + + private final Map additionalProperties; + + private CreateCollectionRequest( + String name, + Optional description, + Optional translatedContent, + Optional parentId, + Optional helpCenterId, + Map additionalProperties) { + this.name = name; + this.description = description; + this.translatedContent = translatedContent; + this.parentId = parentId; + this.helpCenterId = helpCenterId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return The description of the collection. For multilingual collections, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + /** + * @return The id of the parent collection. If null then it will be created as the first level collection. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The id of the help center where the collection will be created. If null then it will be created in the default help center. + */ + @JsonProperty("help_center_id") + public Optional getHelpCenterId() { + return helpCenterId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateCollectionRequest && equalTo((CreateCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateCollectionRequest other) { + return name.equals(other.name) + && description.equals(other.description) + && translatedContent.equals(other.translatedContent) + && parentId.equals(other.parentId) + && helpCenterId.equals(other.helpCenterId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.name, this.description, this.translatedContent, this.parentId, this.helpCenterId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + /** + * The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ + _FinalStage name(@NotNull String name); + + Builder from(CreateCollectionRequest other); + } + + public interface _FinalStage { + CreateCollectionRequest build(); + + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(GroupTranslatedContent translatedContent); + + /** + *

The id of the parent collection. If null then it will be created as the first level collection.

+ */ + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(String parentId); + + /** + *

The id of the help center where the collection will be created. If null then it will be created in the default help center.

+ */ + _FinalStage helpCenterId(Optional helpCenterId); + + _FinalStage helpCenterId(Integer helpCenterId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private Optional helpCenterId = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + private Optional description = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateCollectionRequest other) { + name(other.getName()); + description(other.getDescription()); + translatedContent(other.getTranslatedContent()); + parentId(other.getParentId()); + helpCenterId(other.getHelpCenterId()); + return this; + } + + /** + * The name of the collection. For multilingual collections, this will be the name of the default language's content.

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = Objects.requireNonNull(name, "name must not be null"); + return this; + } + + /** + *

The id of the help center where the collection will be created. If null then it will be created in the default help center.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage helpCenterId(Integer helpCenterId) { + this.helpCenterId = Optional.ofNullable(helpCenterId); + return this; + } + + /** + *

The id of the help center where the collection will be created. If null then it will be created in the default help center.

+ */ + @java.lang.Override + @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) + public _FinalStage helpCenterId(Optional helpCenterId) { + this.helpCenterId = helpCenterId; + return this; + } + + /** + *

The id of the parent collection. If null then it will be created as the first level collection.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + /** + *

The id of the parent collection. If null then it will be created as the first level collection.

+ */ + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + @java.lang.Override + public _FinalStage translatedContent(GroupTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); + return this; + } + + @java.lang.Override + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public _FinalStage translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + @java.lang.Override + public CreateCollectionRequest build() { + return new CreateCollectionRequest( + name, description, translatedContent, parentId, helpCenterId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/DeleteCollectionRequest.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/DeleteCollectionRequest.java new file mode 100644 index 0000000..6fd733b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/DeleteCollectionRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteCollectionRequest.Builder.class) +public final class DeleteCollectionRequest { + private final int id; + + private final Map additionalProperties; + + private DeleteCollectionRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteCollectionRequest && equalTo((DeleteCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteCollectionRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(DeleteCollectionRequest other); + } + + public interface _FinalStage { + DeleteCollectionRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCollectionRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public DeleteCollectionRequest build() { + return new DeleteCollectionRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/RetrieveCollectionRequest.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/RetrieveCollectionRequest.java new file mode 100644 index 0000000..229ed0f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/RetrieveCollectionRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveCollectionRequest.Builder.class) +public final class RetrieveCollectionRequest { + private final int id; + + private final Map additionalProperties; + + private RetrieveCollectionRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveCollectionRequest && equalTo((RetrieveCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveCollectionRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(RetrieveCollectionRequest other); + } + + public interface _FinalStage { + RetrieveCollectionRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveCollectionRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public RetrieveCollectionRequest build() { + return new RetrieveCollectionRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/RetrieveHelpCenterRequest.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/RetrieveHelpCenterRequest.java new file mode 100644 index 0000000..5a25bb6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/RetrieveHelpCenterRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveHelpCenterRequest.Builder.class) +public final class RetrieveHelpCenterRequest { + private final int id; + + private final Map additionalProperties; + + private RetrieveHelpCenterRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveHelpCenterRequest && equalTo((RetrieveHelpCenterRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveHelpCenterRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(RetrieveHelpCenterRequest other); + } + + public interface _FinalStage { + RetrieveHelpCenterRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveHelpCenterRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public RetrieveHelpCenterRequest build() { + return new RetrieveHelpCenterRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/UpdateCollectionRequest.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/UpdateCollectionRequest.java new file mode 100644 index 0000000..390774e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/requests/UpdateCollectionRequest.java @@ -0,0 +1,276 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.GroupTranslatedContent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateCollectionRequest.Builder.class) +public final class UpdateCollectionRequest { + private final int id; + + private final Optional name; + + private final Optional description; + + private final Optional translatedContent; + + private final Optional parentId; + + private final Map additionalProperties; + + private UpdateCollectionRequest( + int id, + Optional name, + Optional description, + Optional translatedContent, + Optional parentId, + Map additionalProperties) { + this.id = id; + this.name = name; + this.description = description; + this.translatedContent = translatedContent; + this.parentId = parentId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The description of the collection. For multilingual collections, this will be the description of the default language's content. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + /** + * @return The id of the parent collection. If null then it will be updated as the first level collection. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateCollectionRequest && equalTo((UpdateCollectionRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateCollectionRequest other) { + return id == other.id + && name.equals(other.name) + && description.equals(other.description) + && translatedContent.equals(other.translatedContent) + && parentId.equals(other.parentId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.description, this.translatedContent, this.parentId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the collection which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(UpdateCollectionRequest other); + } + + public interface _FinalStage { + UpdateCollectionRequest build(); + + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ */ + _FinalStage name(Optional name); + + _FinalStage name(String name); + + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ + _FinalStage description(Optional description); + + _FinalStage description(String description); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(GroupTranslatedContent translatedContent); + + /** + *

The id of the parent collection. If null then it will be updated as the first level collection.

+ */ + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(String parentId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + private Optional parentId = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateCollectionRequest other) { + id(other.getId()); + name(other.getName()); + description(other.getDescription()); + translatedContent(other.getTranslatedContent()); + parentId(other.getParentId()); + return this; + } + + /** + * The unique identifier for the collection which is given by Intercom.

The unique identifier for the collection which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + /** + *

The id of the parent collection. If null then it will be updated as the first level collection.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + /** + *

The id of the parent collection. If null then it will be updated as the first level collection.

+ */ + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + @java.lang.Override + public _FinalStage translatedContent(GroupTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); + return this; + } + + @java.lang.Override + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public _FinalStage translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The description of the collection. For multilingual collections, this will be the description of the default language's content.

+ */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ */ + @java.lang.Override + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public _FinalStage name(Optional name) { + this.name = name; + return this; + } + + @java.lang.Override + public UpdateCollectionRequest build() { + return new UpdateCollectionRequest( + id, name, description, translatedContent, parentId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/Collection.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/Collection.java new file mode 100644 index 0000000..e19ed77 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/Collection.java @@ -0,0 +1,485 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.GroupTranslatedContent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Collection.Builder.class) +public final class Collection { + private final Optional id; + + private final Optional workspaceId; + + private final Optional name; + + private final Optional description; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional url; + + private final Optional icon; + + private final Optional order; + + private final Optional defaultLocale; + + private final Optional translatedContent; + + private final Optional parentId; + + private final Optional helpCenterId; + + private final Map additionalProperties; + + private Collection( + Optional id, + Optional workspaceId, + Optional name, + Optional description, + Optional createdAt, + Optional updatedAt, + Optional url, + Optional icon, + Optional order, + Optional defaultLocale, + Optional translatedContent, + Optional parentId, + Optional helpCenterId, + Map additionalProperties) { + this.id = id; + this.workspaceId = workspaceId; + this.name = name; + this.description = description; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.url = url; + this.icon = icon; + this.order = order; + this.defaultLocale = defaultLocale; + this.translatedContent = translatedContent; + this.parentId = parentId; + this.helpCenterId = helpCenterId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the collection which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the workspace which the collection belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The name of the collection. For multilingual collections, this will be the name of the default language's content. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The description of the collection. For multilingual help centers, this will be the description of the collection for the default language. + */ + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + /** + * @return The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The icon of the collection. + */ + @JsonProperty("icon") + public Optional getIcon() { + return icon; + } + + /** + * @return The order of the section in relation to others sections within a collection. Values go from 0 upwards. 0 is the default if there's no order. + */ + @JsonProperty("order") + public Optional getOrder() { + return order; + } + + /** + * @return The default locale of the help center. This field is only returned for multilingual help centers. + */ + @JsonProperty("default_locale") + public Optional getDefaultLocale() { + return defaultLocale; + } + + @JsonProperty("translated_content") + public Optional getTranslatedContent() { + return translatedContent; + } + + /** + * @return The id of the parent collection. If null then it is the first level collection. + */ + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + /** + * @return The id of the help center the collection is in. + */ + @JsonProperty("help_center_id") + public Optional getHelpCenterId() { + return helpCenterId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Collection && equalTo((Collection) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Collection other) { + return id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && name.equals(other.name) + && description.equals(other.description) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && url.equals(other.url) + && icon.equals(other.icon) + && order.equals(other.order) + && defaultLocale.equals(other.defaultLocale) + && translatedContent.equals(other.translatedContent) + && parentId.equals(other.parentId) + && helpCenterId.equals(other.helpCenterId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.workspaceId, + this.name, + this.description, + this.createdAt, + this.updatedAt, + this.url, + this.icon, + this.order, + this.defaultLocale, + this.translatedContent, + this.parentId, + this.helpCenterId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional icon = Optional.empty(); + + private Optional order = Optional.empty(); + + private Optional defaultLocale = Optional.empty(); + + private Optional translatedContent = Optional.empty(); + + private Optional parentId = Optional.empty(); + + private Optional helpCenterId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Collection other) { + id(other.getId()); + workspaceId(other.getWorkspaceId()); + name(other.getName()); + description(other.getDescription()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + url(other.getUrl()); + icon(other.getIcon()); + order(other.getOrder()); + defaultLocale(other.getDefaultLocale()); + translatedContent(other.getTranslatedContent()); + parentId(other.getParentId()); + helpCenterId(other.getHelpCenterId()); + return this; + } + + /** + *

The unique identifier for the collection which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id of the workspace which the collection belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The name of the collection. For multilingual collections, this will be the name of the default language's content.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The description of the collection. For multilingual help centers, this will be the description of the collection for the default language.

+ */ + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.ofNullable(description); + return this; + } + + /** + *

The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language.

+ */ + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public Builder url(Optional url) { + this.url = url; + return this; + } + + public Builder url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

The icon of the collection.

+ */ + @JsonSetter(value = "icon", nulls = Nulls.SKIP) + public Builder icon(Optional icon) { + this.icon = icon; + return this; + } + + public Builder icon(String icon) { + this.icon = Optional.ofNullable(icon); + return this; + } + + /** + *

The order of the section in relation to others sections within a collection. Values go from 0 upwards. 0 is the default if there's no order.

+ */ + @JsonSetter(value = "order", nulls = Nulls.SKIP) + public Builder order(Optional order) { + this.order = order; + return this; + } + + public Builder order(Integer order) { + this.order = Optional.ofNullable(order); + return this; + } + + /** + *

The default locale of the help center. This field is only returned for multilingual help centers.

+ */ + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public Builder defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; + return this; + } + + public Builder defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); + return this; + } + + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public Builder translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + + public Builder translatedContent(GroupTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); + return this; + } + + /** + *

The id of the parent collection. If null then it is the first level collection.

+ */ + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public Builder parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + public Builder parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + /** + *

The id of the help center the collection is in.

+ */ + @JsonSetter(value = "help_center_id", nulls = Nulls.SKIP) + public Builder helpCenterId(Optional helpCenterId) { + this.helpCenterId = helpCenterId; + return this; + } + + public Builder helpCenterId(Integer helpCenterId) { + this.helpCenterId = Optional.ofNullable(helpCenterId); + return this; + } + + public Collection build() { + return new Collection( + id, + workspaceId, + name, + description, + createdAt, + updatedAt, + url, + icon, + order, + defaultLocale, + translatedContent, + parentId, + helpCenterId, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/HelpCenter.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/HelpCenter.java new file mode 100644 index 0000000..6e4d499 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/HelpCenter.java @@ -0,0 +1,298 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = HelpCenter.Builder.class) +public final class HelpCenter { + private final Optional id; + + private final Optional workspaceId; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional identifier; + + private final Optional websiteTurnedOn; + + private final Optional displayName; + + private final Map additionalProperties; + + private HelpCenter( + Optional id, + Optional workspaceId, + Optional createdAt, + Optional updatedAt, + Optional identifier, + Optional websiteTurnedOn, + Optional displayName, + Map additionalProperties) { + this.id = id; + this.workspaceId = workspaceId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.identifier = identifier; + this.websiteTurnedOn = websiteTurnedOn; + this.displayName = displayName; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the Help Center which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the workspace which the Help Center belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The time when the Help Center was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the Help Center was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The identifier of the Help Center. This is used in the URL of the Help Center. + */ + @JsonProperty("identifier") + public Optional getIdentifier() { + return identifier; + } + + /** + * @return Whether the Help Center is turned on or not. This is controlled in your Help Center settings. + */ + @JsonProperty("website_turned_on") + public Optional getWebsiteTurnedOn() { + return websiteTurnedOn; + } + + /** + * @return The display name of the Help Center only seen by teammates. + */ + @JsonProperty("display_name") + public Optional getDisplayName() { + return displayName; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HelpCenter && equalTo((HelpCenter) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HelpCenter other) { + return id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && identifier.equals(other.identifier) + && websiteTurnedOn.equals(other.websiteTurnedOn) + && displayName.equals(other.displayName); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.workspaceId, + this.createdAt, + this.updatedAt, + this.identifier, + this.websiteTurnedOn, + this.displayName); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional identifier = Optional.empty(); + + private Optional websiteTurnedOn = Optional.empty(); + + private Optional displayName = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(HelpCenter other) { + id(other.getId()); + workspaceId(other.getWorkspaceId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + identifier(other.getIdentifier()); + websiteTurnedOn(other.getWebsiteTurnedOn()); + displayName(other.getDisplayName()); + return this; + } + + /** + *

The unique identifier for the Help Center which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id of the workspace which the Help Center belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The time when the Help Center was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time when the Help Center was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The identifier of the Help Center. This is used in the URL of the Help Center.

+ */ + @JsonSetter(value = "identifier", nulls = Nulls.SKIP) + public Builder identifier(Optional identifier) { + this.identifier = identifier; + return this; + } + + public Builder identifier(String identifier) { + this.identifier = Optional.ofNullable(identifier); + return this; + } + + /** + *

Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

+ */ + @JsonSetter(value = "website_turned_on", nulls = Nulls.SKIP) + public Builder websiteTurnedOn(Optional websiteTurnedOn) { + this.websiteTurnedOn = websiteTurnedOn; + return this; + } + + public Builder websiteTurnedOn(Boolean websiteTurnedOn) { + this.websiteTurnedOn = Optional.ofNullable(websiteTurnedOn); + return this; + } + + /** + *

The display name of the Help Center only seen by teammates.

+ */ + @JsonSetter(value = "display_name", nulls = Nulls.SKIP) + public Builder displayName(Optional displayName) { + this.displayName = displayName; + return this; + } + + public Builder displayName(String displayName) { + this.displayName = Optional.ofNullable(displayName); + return this; + } + + public HelpCenter build() { + return new HelpCenter( + id, + workspaceId, + createdAt, + updatedAt, + identifier, + websiteTurnedOn, + displayName, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/HelpCenterList.java b/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/HelpCenterList.java new file mode 100644 index 0000000..5f39c6e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/helpcenter/types/HelpCenterList.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.helpcenter.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = HelpCenterList.Builder.class) +public final class HelpCenterList { + private final Optional type; + + private final Optional> data; + + private final Map additionalProperties; + + private HelpCenterList( + Optional type, Optional> data, Map additionalProperties) { + this.type = type; + this.data = data; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - list. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return An array of Help Center objects + */ + @JsonProperty("data") + public Optional> getData() { + return data; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof HelpCenterList && equalTo((HelpCenterList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(HelpCenterList other) { + return type.equals(other.type) && data.equals(other.data); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.data); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional> data = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(HelpCenterList other) { + type(other.getType()); + data(other.getData()); + return this; + } + + /** + *

The type of the object - list.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

An array of Help Center objects

+ */ + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional> data) { + this.data = data; + return this; + } + + public Builder data(List data) { + this.data = Optional.ofNullable(data); + return this; + } + + public HelpCenterList build() { + return new HelpCenterList(type, data, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/jobs/AsyncJobsClient.java b/src/main/java/com/intercom/api/resources/unstable/jobs/AsyncJobsClient.java new file mode 100644 index 0000000..f9cd3b3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/jobs/AsyncJobsClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.jobs; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.unstable.jobs.types.Jobs; +import java.util.concurrent.CompletableFuture; + +public class AsyncJobsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawJobsClient rawClient; + + public AsyncJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawJobsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawJobsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture status(JobsStatusRequest request) { + return this.rawClient.status(request).thenApply(response -> response.body()); + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture status(JobsStatusRequest request, RequestOptions requestOptions) { + return this.rawClient.status(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/jobs/AsyncRawJobsClient.java b/src/main/java/com/intercom/api/resources/unstable/jobs/AsyncRawJobsClient.java new file mode 100644 index 0000000..8584579 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/jobs/AsyncRawJobsClient.java @@ -0,0 +1,110 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.jobs; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.unstable.jobs.types.Jobs; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawJobsClient { + protected final ClientOptions clientOptions; + + public AsyncRawJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture> status(JobsStatusRequest request) { + return status(request, null); + } + + /** + * Retrieve the status of job execution. + */ + public CompletableFuture> status( + JobsStatusRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("jobs/status") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Jobs.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/jobs/JobsClient.java b/src/main/java/com/intercom/api/resources/unstable/jobs/JobsClient.java new file mode 100644 index 0000000..7777a88 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/jobs/JobsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.jobs; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.unstable.jobs.types.Jobs; + +public class JobsClient { + protected final ClientOptions clientOptions; + + private final RawJobsClient rawClient; + + public JobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawJobsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawJobsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve the status of job execution. + */ + public Jobs status(JobsStatusRequest request) { + return this.rawClient.status(request).body(); + } + + /** + * Retrieve the status of job execution. + */ + public Jobs status(JobsStatusRequest request, RequestOptions requestOptions) { + return this.rawClient.status(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/jobs/RawJobsClient.java b/src/main/java/com/intercom/api/resources/unstable/jobs/RawJobsClient.java new file mode 100644 index 0000000..ac650e7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/jobs/RawJobsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.jobs; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.unstable.jobs.types.Jobs; +import com.intercom.api.resources.unstable.types.Error; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawJobsClient { + protected final ClientOptions clientOptions; + + public RawJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve the status of job execution. + */ + public IntercomHttpResponse status(JobsStatusRequest request) { + return status(request, null); + } + + /** + * Retrieve the status of job execution. + */ + public IntercomHttpResponse status(JobsStatusRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("jobs/status") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Jobs.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/jobs/requests/JobsStatusRequest.java b/src/main/java/com/intercom/api/resources/unstable/jobs/requests/JobsStatusRequest.java new file mode 100644 index 0000000..c0f4801 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/jobs/requests/JobsStatusRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.jobs.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = JobsStatusRequest.Builder.class) +public final class JobsStatusRequest { + private final String id; + + private final Map additionalProperties; + + private JobsStatusRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the job which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof JobsStatusRequest && equalTo((JobsStatusRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(JobsStatusRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the job which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(JobsStatusRequest other); + } + + public interface _FinalStage { + JobsStatusRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(JobsStatusRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the job which is given by Intercom

The unique identifier for the job which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public JobsStatusRequest build() { + return new JobsStatusRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/jobs/types/Jobs.java b/src/main/java/com/intercom/api/resources/unstable/jobs/types/Jobs.java new file mode 100644 index 0000000..217d223 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/jobs/types/Jobs.java @@ -0,0 +1,462 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.jobs.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Jobs.Builder.class) +public final class Jobs { + private final Optional type; + + private final String id; + + private final Optional url; + + private final Optional status; + + private final Optional resourceType; + + private final Optional resourceId; + + private final Optional resourceUrl; + + private final Map additionalProperties; + + private Jobs( + Optional type, + String id, + Optional url, + Optional status, + Optional resourceType, + Optional resourceId, + Optional resourceUrl, + Map additionalProperties) { + this.type = type; + this.id = id; + this.url = url; + this.status = status; + this.resourceType = resourceType; + this.resourceId = resourceId; + this.resourceUrl = resourceUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the job that's currently being processed or has completed. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return API endpoint URL to check the job status. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return The status of the job execution. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + + /** + * @return The type of resource created during job execution. + */ + @JsonProperty("resource_type") + public Optional getResourceType() { + return resourceType; + } + + /** + * @return The id of the resource created during job execution (e.g. ticket id) + */ + @JsonProperty("resource_id") + public Optional getResourceId() { + return resourceId; + } + + /** + * @return The url of the resource created during job exeuction. Use this url to fetch the resource. + */ + @JsonProperty("resource_url") + public Optional getResourceUrl() { + return resourceUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Jobs && equalTo((Jobs) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Jobs other) { + return type.equals(other.type) + && id.equals(other.id) + && url.equals(other.url) + && status.equals(other.status) + && resourceType.equals(other.resourceType) + && resourceId.equals(other.resourceId) + && resourceUrl.equals(other.resourceUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, this.id, this.url, this.status, this.resourceType, this.resourceId, this.resourceUrl); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The id of the job that's currently being processed or has completed. + */ + _FinalStage id(@NotNull String id); + + Builder from(Jobs other); + } + + public interface _FinalStage { + Jobs build(); + + /** + *

The type of the object

+ */ + _FinalStage type(Optional type); + + _FinalStage type(String type); + + /** + *

API endpoint URL to check the job status.

+ */ + _FinalStage url(Optional url); + + _FinalStage url(String url); + + /** + *

The status of the job execution.

+ */ + _FinalStage status(Optional status); + + _FinalStage status(Status status); + + /** + *

The type of resource created during job execution.

+ */ + _FinalStage resourceType(Optional resourceType); + + _FinalStage resourceType(String resourceType); + + /** + *

The id of the resource created during job execution (e.g. ticket id)

+ */ + _FinalStage resourceId(Optional resourceId); + + _FinalStage resourceId(String resourceId); + + /** + *

The url of the resource created during job exeuction. Use this url to fetch the resource.

+ */ + _FinalStage resourceUrl(Optional resourceUrl); + + _FinalStage resourceUrl(String resourceUrl); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional resourceUrl = Optional.empty(); + + private Optional resourceId = Optional.empty(); + + private Optional resourceType = Optional.empty(); + + private Optional status = Optional.empty(); + + private Optional url = Optional.empty(); + + private Optional type = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Jobs other) { + type(other.getType()); + id(other.getId()); + url(other.getUrl()); + status(other.getStatus()); + resourceType(other.getResourceType()); + resourceId(other.getResourceId()); + resourceUrl(other.getResourceUrl()); + return this; + } + + /** + * The id of the job that's currently being processed or has completed.

The id of the job that's currently being processed or has completed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + *

The url of the resource created during job exeuction. Use this url to fetch the resource.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resourceUrl(String resourceUrl) { + this.resourceUrl = Optional.ofNullable(resourceUrl); + return this; + } + + /** + *

The url of the resource created during job exeuction. Use this url to fetch the resource.

+ */ + @java.lang.Override + @JsonSetter(value = "resource_url", nulls = Nulls.SKIP) + public _FinalStage resourceUrl(Optional resourceUrl) { + this.resourceUrl = resourceUrl; + return this; + } + + /** + *

The id of the resource created during job execution (e.g. ticket id)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resourceId(String resourceId) { + this.resourceId = Optional.ofNullable(resourceId); + return this; + } + + /** + *

The id of the resource created during job execution (e.g. ticket id)

+ */ + @java.lang.Override + @JsonSetter(value = "resource_id", nulls = Nulls.SKIP) + public _FinalStage resourceId(Optional resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + *

The type of resource created during job execution.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage resourceType(String resourceType) { + this.resourceType = Optional.ofNullable(resourceType); + return this; + } + + /** + *

The type of resource created during job execution.

+ */ + @java.lang.Override + @JsonSetter(value = "resource_type", nulls = Nulls.SKIP) + public _FinalStage resourceType(Optional resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + *

The status of the job execution.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage status(Status status) { + this.status = Optional.ofNullable(status); + return this; + } + + /** + *

The status of the job execution.

+ */ + @java.lang.Override + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public _FinalStage status(Optional status) { + this.status = status; + return this; + } + + /** + *

API endpoint URL to check the job status.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage url(String url) { + this.url = Optional.ofNullable(url); + return this; + } + + /** + *

API endpoint URL to check the job status.

+ */ + @java.lang.Override + @JsonSetter(value = "url", nulls = Nulls.SKIP) + public _FinalStage url(Optional url) { + this.url = url; + return this; + } + + /** + *

The type of the object

+ * @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; + } + + /** + *

The type of the object

+ */ + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + + @java.lang.Override + public Jobs build() { + return new Jobs(type, id, url, status, resourceType, resourceId, resourceUrl, additionalProperties); + } + } + + public static final class Status { + public static final Status SUCCESS = new Status(Value.SUCCESS, "success"); + + public static final Status FAILED = new Status(Value.FAILED, "failed"); + + public static final Status PENDING = new Status(Value.PENDING, "pending"); + + private final Value value; + + private final String string; + + Status(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Status && this.string.equals(((Status) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case SUCCESS: + return visitor.visitSuccess(); + case FAILED: + return visitor.visitFailed(); + case PENDING: + return visitor.visitPending(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Status valueOf(String value) { + switch (value) { + case "success": + return SUCCESS; + case "failed": + return FAILED; + case "pending": + return PENDING; + default: + return new Status(Value.UNKNOWN, value); + } + } + + public enum Value { + PENDING, + + SUCCESS, + + FAILED, + + UNKNOWN + } + + public interface Visitor { + T visitPending(); + + T visitSuccess(); + + T visitFailed(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/messages/AsyncMessagesClient.java b/src/main/java/com/intercom/api/resources/unstable/messages/AsyncMessagesClient.java new file mode 100644 index 0000000..7d3afcf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/messages/AsyncMessagesClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.messages; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.messages.requests.GetWhatsAppMessageStatusRequest; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.types.WhatsappMessageStatusList; +import java.util.concurrent.CompletableFuture; + +public class AsyncMessagesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawMessagesClient rawClient; + + public AsyncMessagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawMessagesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawMessagesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public CompletableFuture createMessage(Object request) { + return this.rawClient.createMessage(request).thenApply(response -> response.body()); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public CompletableFuture createMessage(Object request, RequestOptions requestOptions) { + return this.rawClient.createMessage(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public CompletableFuture getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest request) { + return this.rawClient.getWhatsAppMessageStatus(request).thenApply(response -> response.body()); + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public CompletableFuture getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest request, RequestOptions requestOptions) { + return this.rawClient.getWhatsAppMessageStatus(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/messages/AsyncRawMessagesClient.java b/src/main/java/com/intercom/api/resources/unstable/messages/AsyncRawMessagesClient.java new file mode 100644 index 0000000..fdcefac --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/messages/AsyncRawMessagesClient.java @@ -0,0 +1,249 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.messages; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.ForbiddenError; +import com.intercom.api.resources.unstable.errors.InternalServerError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.messages.requests.GetWhatsAppMessageStatusRequest; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.WhatsappMessageStatusList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawMessagesClient { + protected final ClientOptions clientOptions; + + public AsyncRawMessagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public CompletableFuture> createMessage(Object request) { + return createMessage(request, null); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public CompletableFuture> createMessage( + Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("messages") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Message.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public CompletableFuture> getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest request) { + return getWhatsAppMessageStatus(request, null); + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public CompletableFuture> getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("messages/status"); + QueryStringMapper.addQueryParameter(httpUrl, "ruleset_id", request.getRulesetId(), false); + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), WhatsappMessageStatusList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 403: + future.completeExceptionally(new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 500: + future.completeExceptionally(new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/messages/MessagesClient.java b/src/main/java/com/intercom/api/resources/unstable/messages/MessagesClient.java new file mode 100644 index 0000000..85eb1d2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/messages/MessagesClient.java @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.messages; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.messages.requests.GetWhatsAppMessageStatusRequest; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.types.WhatsappMessageStatusList; + +public class MessagesClient { + protected final ClientOptions clientOptions; + + private final RawMessagesClient rawClient; + + public MessagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawMessagesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawMessagesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public Message createMessage(Object request) { + return this.rawClient.createMessage(request).body(); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public Message createMessage(Object request, RequestOptions requestOptions) { + return this.rawClient.createMessage(request, requestOptions).body(); + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public WhatsappMessageStatusList getWhatsAppMessageStatus(GetWhatsAppMessageStatusRequest request) { + return this.rawClient.getWhatsAppMessageStatus(request).body(); + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public WhatsappMessageStatusList getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest request, RequestOptions requestOptions) { + return this.rawClient.getWhatsAppMessageStatus(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/messages/RawMessagesClient.java b/src/main/java/com/intercom/api/resources/unstable/messages/RawMessagesClient.java new file mode 100644 index 0000000..a56f156 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/messages/RawMessagesClient.java @@ -0,0 +1,201 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.messages; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.ForbiddenError; +import com.intercom.api.resources.unstable.errors.InternalServerError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.messages.requests.GetWhatsAppMessageStatusRequest; +import com.intercom.api.resources.unstable.messages.types.Message; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.WhatsappMessageStatusList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawMessagesClient { + protected final ClientOptions clientOptions; + + public RawMessagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public IntercomHttpResponse createMessage(Object request) { + return createMessage(request, null); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + *
+ *

🚧 Sending for visitors

+ *

There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case.

+ *
+ *

This will return the Message model that has been created.

+ *
+ *

🚧 Retrieving Associated Conversations

+ *

As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message.

+ *
+ */ + public IntercomHttpResponse createMessage(Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("messages") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public IntercomHttpResponse getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest request) { + return getWhatsAppMessageStatus(request, null); + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + *

This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details.

+ */ + public IntercomHttpResponse getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("messages/status"); + QueryStringMapper.addQueryParameter(httpUrl, "ruleset_id", request.getRulesetId(), false); + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get().toString(), false); + } + if (request.getStartingAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "starting_after", request.getStartingAfter().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WhatsappMessageStatusList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 403: + throw new ForbiddenError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 500: + throw new InternalServerError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/messages/requests/GetWhatsAppMessageStatusRequest.java b/src/main/java/com/intercom/api/resources/unstable/messages/requests/GetWhatsAppMessageStatusRequest.java new file mode 100644 index 0000000..380da17 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/messages/requests/GetWhatsAppMessageStatusRequest.java @@ -0,0 +1,202 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.messages.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetWhatsAppMessageStatusRequest.Builder.class) +public final class GetWhatsAppMessageStatusRequest { + private final String rulesetId; + + private final Optional perPage; + + private final Optional startingAfter; + + private final Map additionalProperties; + + private GetWhatsAppMessageStatusRequest( + String rulesetId, + Optional perPage, + Optional startingAfter, + Map additionalProperties) { + this.rulesetId = rulesetId; + this.perPage = perPage; + this.startingAfter = startingAfter; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the set of messages to check status for + */ + @JsonProperty("ruleset_id") + public String getRulesetId() { + return rulesetId; + } + + /** + * @return Number of results per page (default 50, max 100) + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + /** + * @return Cursor for pagination, used to fetch the next page of results + */ + @JsonProperty("starting_after") + public Optional getStartingAfter() { + return startingAfter; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetWhatsAppMessageStatusRequest && equalTo((GetWhatsAppMessageStatusRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetWhatsAppMessageStatusRequest other) { + return rulesetId.equals(other.rulesetId) + && perPage.equals(other.perPage) + && startingAfter.equals(other.startingAfter); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.rulesetId, this.perPage, this.startingAfter); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static RulesetIdStage builder() { + return new Builder(); + } + + public interface RulesetIdStage { + /** + * The unique identifier for the set of messages to check status for + */ + _FinalStage rulesetId(@NotNull String rulesetId); + + Builder from(GetWhatsAppMessageStatusRequest other); + } + + public interface _FinalStage { + GetWhatsAppMessageStatusRequest build(); + + /** + *

Number of results per page (default 50, max 100)

+ */ + _FinalStage perPage(Optional perPage); + + _FinalStage perPage(Integer perPage); + + /** + *

Cursor for pagination, used to fetch the next page of results

+ */ + _FinalStage startingAfter(Optional startingAfter); + + _FinalStage startingAfter(String startingAfter); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements RulesetIdStage, _FinalStage { + private String rulesetId; + + private Optional startingAfter = Optional.empty(); + + private Optional perPage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetWhatsAppMessageStatusRequest other) { + rulesetId(other.getRulesetId()); + perPage(other.getPerPage()); + startingAfter(other.getStartingAfter()); + return this; + } + + /** + * The unique identifier for the set of messages to check status for

The unique identifier for the set of messages to check status for

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ruleset_id") + public _FinalStage rulesetId(@NotNull String rulesetId) { + this.rulesetId = Objects.requireNonNull(rulesetId, "rulesetId must not be null"); + return this; + } + + /** + *

Cursor for pagination, used to fetch the next page of results

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage startingAfter(String startingAfter) { + this.startingAfter = Optional.ofNullable(startingAfter); + return this; + } + + /** + *

Cursor for pagination, used to fetch the next page of results

+ */ + @java.lang.Override + @JsonSetter(value = "starting_after", nulls = Nulls.SKIP) + public _FinalStage startingAfter(Optional startingAfter) { + this.startingAfter = startingAfter; + return this; + } + + /** + *

Number of results per page (default 50, max 100)

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage perPage(Integer perPage) { + this.perPage = Optional.ofNullable(perPage); + return this; + } + + /** + *

Number of results per page (default 50, max 100)

+ */ + @java.lang.Override + @JsonSetter(value = "per_page", nulls = Nulls.SKIP) + public _FinalStage perPage(Optional perPage) { + this.perPage = perPage; + return this; + } + + @java.lang.Override + public GetWhatsAppMessageStatusRequest build() { + return new GetWhatsAppMessageStatusRequest(rulesetId, perPage, startingAfter, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/messages/types/Message.java b/src/main/java/com/intercom/api/resources/unstable/messages/types/Message.java new file mode 100644 index 0000000..35d5fe7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/messages/types/Message.java @@ -0,0 +1,448 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.messages.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Message.Builder.class) +public final class Message { + private final String type; + + private final String id; + + private final int createdAt; + + private final Optional subject; + + private final String body; + + private final MessageType messageType; + + private final Optional conversationId; + + private final Map additionalProperties; + + private Message( + String type, + String id, + int createdAt, + Optional subject, + String body, + MessageType messageType, + Optional conversationId, + Map additionalProperties) { + this.type = type; + this.id = id; + this.createdAt = createdAt; + this.subject = subject; + this.body = body; + this.messageType = messageType; + this.conversationId = conversationId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the message + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * @return The id representing the message. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The time the conversation was created. + */ + @JsonProperty("created_at") + public int getCreatedAt() { + return createdAt; + } + + /** + * @return The subject of the message. Only present if message_type: email. + */ + @JsonProperty("subject") + public Optional getSubject() { + return subject; + } + + /** + * @return The message body, which may contain HTML. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The type of message that was sent. Can be email, inapp, facebook ,twitter or sms. + */ + @JsonProperty("message_type") + public MessageType getMessageType() { + return messageType; + } + + /** + * @return The associated conversation_id + */ + @JsonProperty("conversation_id") + public Optional getConversationId() { + return conversationId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Message && equalTo((Message) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Message other) { + return type.equals(other.type) + && id.equals(other.id) + && createdAt == other.createdAt + && subject.equals(other.subject) + && body.equals(other.body) + && messageType.equals(other.messageType) + && conversationId.equals(other.conversationId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, this.id, this.createdAt, this.subject, this.body, this.messageType, this.conversationId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TypeStage builder() { + return new Builder(); + } + + public interface TypeStage { + /** + * The type of the message + */ + IdStage type(@NotNull String type); + + Builder from(Message other); + } + + public interface IdStage { + /** + * The id representing the message. + */ + CreatedAtStage id(@NotNull String id); + } + + public interface CreatedAtStage { + /** + * The time the conversation was created. + */ + BodyStage createdAt(int createdAt); + } + + public interface BodyStage { + /** + * The message body, which may contain HTML. + */ + MessageTypeStage body(@NotNull String body); + } + + public interface MessageTypeStage { + /** + * The type of message that was sent. Can be email, inapp, facebook ,twitter or sms. + */ + _FinalStage messageType(@NotNull MessageType messageType); + } + + public interface _FinalStage { + Message build(); + + /** + *

The subject of the message. Only present if message_type: email.

+ */ + _FinalStage subject(Optional subject); + + _FinalStage subject(String subject); + + /** + *

The associated conversation_id

+ */ + _FinalStage conversationId(Optional conversationId); + + _FinalStage conversationId(String conversationId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements TypeStage, IdStage, CreatedAtStage, BodyStage, MessageTypeStage, _FinalStage { + private String type; + + private String id; + + private int createdAt; + + private String body; + + private MessageType messageType; + + private Optional conversationId = Optional.empty(); + + private Optional subject = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Message other) { + type(other.getType()); + id(other.getId()); + createdAt(other.getCreatedAt()); + subject(other.getSubject()); + body(other.getBody()); + messageType(other.getMessageType()); + conversationId(other.getConversationId()); + return this; + } + + /** + * The type of the message

The type of the message

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("type") + public IdStage type(@NotNull String type) { + this.type = Objects.requireNonNull(type, "type must not be null"); + return this; + } + + /** + * The id representing the message.

The id representing the message.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public CreatedAtStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The time the conversation was created.

The time the conversation was created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("created_at") + public BodyStage createdAt(int createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The message body, which may contain HTML.

The message body, which may contain HTML.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("body") + public MessageTypeStage body(@NotNull String body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + /** + * The type of message that was sent. Can be email, inapp, facebook ,twitter or sms.

The type of message that was sent. Can be email, inapp, facebook ,twitter or sms.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("message_type") + public _FinalStage messageType(@NotNull MessageType messageType) { + this.messageType = Objects.requireNonNull(messageType, "messageType must not be null"); + return this; + } + + /** + *

The associated conversation_id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage conversationId(String conversationId) { + this.conversationId = Optional.ofNullable(conversationId); + return this; + } + + /** + *

The associated conversation_id

+ */ + @java.lang.Override + @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) + public _FinalStage conversationId(Optional conversationId) { + this.conversationId = conversationId; + return this; + } + + /** + *

The subject of the message. Only present if message_type: email.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage subject(String subject) { + this.subject = Optional.ofNullable(subject); + return this; + } + + /** + *

The subject of the message. Only present if message_type: email.

+ */ + @java.lang.Override + @JsonSetter(value = "subject", nulls = Nulls.SKIP) + public _FinalStage subject(Optional subject) { + this.subject = subject; + return this; + } + + @java.lang.Override + public Message build() { + return new Message(type, id, createdAt, subject, body, messageType, conversationId, additionalProperties); + } + } + + public static final class MessageType { + public static final MessageType EMAIL = new MessageType(Value.EMAIL, "email"); + + public static final MessageType FACEBOOK = new MessageType(Value.FACEBOOK, "facebook"); + + public static final MessageType INAPP = new MessageType(Value.INAPP, "inapp"); + + public static final MessageType SMS = new MessageType(Value.SMS, "sms"); + + public static final MessageType TWITTER = new MessageType(Value.TWITTER, "twitter"); + + private final Value value; + + private final String string; + + MessageType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof MessageType && this.string.equals(((MessageType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EMAIL: + return visitor.visitEmail(); + case FACEBOOK: + return visitor.visitFacebook(); + case INAPP: + return visitor.visitInapp(); + case SMS: + return visitor.visitSms(); + case TWITTER: + return visitor.visitTwitter(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static MessageType valueOf(String value) { + switch (value) { + case "email": + return EMAIL; + case "facebook": + return FACEBOOK; + case "inapp": + return INAPP; + case "sms": + return SMS; + case "twitter": + return TWITTER; + default: + return new MessageType(Value.UNKNOWN, value); + } + } + + public enum Value { + EMAIL, + + INAPP, + + FACEBOOK, + + TWITTER, + + SMS, + + UNKNOWN + } + + public interface Visitor { + T visitEmail(); + + T visitInapp(); + + T visitFacebook(); + + T visitTwitter(); + + T visitSms(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/AsyncNewsClient.java b/src/main/java/com/intercom/api/resources/unstable/news/AsyncNewsClient.java new file mode 100644 index 0000000..5bb58c1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/AsyncNewsClient.java @@ -0,0 +1,146 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.news.requests.DeleteNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.ListLiveNewsfeedItemsRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsfeedRequest; +import com.intercom.api.resources.unstable.news.requests.UpdateNewsItemRequest; +import com.intercom.api.resources.unstable.news.types.NewsItem; +import com.intercom.api.resources.unstable.news.types.Newsfeed; +import com.intercom.api.resources.unstable.types.DeletedObject; +import com.intercom.api.resources.unstable.types.NewsItemRequest; +import com.intercom.api.resources.unstable.types.PaginatedResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncNewsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawNewsClient rawClient; + + public AsyncNewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawNewsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawNewsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all news items + */ + public CompletableFuture listNewsItems() { + return this.rawClient.listNewsItems().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all news items + */ + public CompletableFuture listNewsItems(RequestOptions requestOptions) { + return this.rawClient.listNewsItems(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a news item + */ + public CompletableFuture createNewsItem(NewsItemRequest request) { + return this.rawClient.createNewsItem(request).thenApply(response -> response.body()); + } + + /** + * You can create a news item + */ + public CompletableFuture createNewsItem(NewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.createNewsItem(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single news item. + */ + public CompletableFuture retrieveNewsItem(RetrieveNewsItemRequest request) { + return this.rawClient.retrieveNewsItem(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single news item. + */ + public CompletableFuture retrieveNewsItem( + RetrieveNewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveNewsItem(request, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture updateNewsItem(UpdateNewsItemRequest request) { + return this.rawClient.updateNewsItem(request).thenApply(response -> response.body()); + } + + public CompletableFuture updateNewsItem(UpdateNewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.updateNewsItem(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single news item. + */ + public CompletableFuture deleteNewsItem(DeleteNewsItemRequest request) { + return this.rawClient.deleteNewsItem(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single news item. + */ + public CompletableFuture deleteNewsItem( + DeleteNewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteNewsItem(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public CompletableFuture listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest request) { + return this.rawClient.listLiveNewsfeedItems(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public CompletableFuture listLiveNewsfeedItems( + ListLiveNewsfeedItemsRequest request, RequestOptions requestOptions) { + return this.rawClient.listLiveNewsfeedItems(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all newsfeeds + */ + public CompletableFuture listNewsfeeds() { + return this.rawClient.listNewsfeeds().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all newsfeeds + */ + public CompletableFuture listNewsfeeds(RequestOptions requestOptions) { + return this.rawClient.listNewsfeeds(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single newsfeed + */ + public CompletableFuture retrieveNewsfeed(RetrieveNewsfeedRequest request) { + return this.rawClient.retrieveNewsfeed(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single newsfeed + */ + public CompletableFuture retrieveNewsfeed( + RetrieveNewsfeedRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveNewsfeed(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/AsyncRawNewsClient.java b/src/main/java/com/intercom/api/resources/unstable/news/AsyncRawNewsClient.java new file mode 100644 index 0000000..31b4476 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/AsyncRawNewsClient.java @@ -0,0 +1,612 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.news.requests.DeleteNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.ListLiveNewsfeedItemsRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsfeedRequest; +import com.intercom.api.resources.unstable.news.requests.UpdateNewsItemRequest; +import com.intercom.api.resources.unstable.news.types.NewsItem; +import com.intercom.api.resources.unstable.news.types.Newsfeed; +import com.intercom.api.resources.unstable.types.DeletedObject; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.NewsItemRequest; +import com.intercom.api.resources.unstable.types.PaginatedResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawNewsClient { + protected final ClientOptions clientOptions; + + public AsyncRawNewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all news items + */ + public CompletableFuture> listNewsItems() { + return listNewsItems(null); + } + + /** + * You can fetch a list of all news items + */ + public CompletableFuture> listNewsItems(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), PaginatedResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can create a news item + */ + public CompletableFuture> createNewsItem(NewsItemRequest request) { + return createNewsItem(request, null); + } + + /** + * You can create a news item + */ + public CompletableFuture> createNewsItem( + NewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), NewsItem.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single news item. + */ + public CompletableFuture> retrieveNewsItem(RetrieveNewsItemRequest request) { + return retrieveNewsItem(request, null); + } + + /** + * You can fetch the details of a single news item. + */ + public CompletableFuture> retrieveNewsItem( + RetrieveNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), NewsItem.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> updateNewsItem(UpdateNewsItemRequest request) { + return updateNewsItem(request, null); + } + + public CompletableFuture> updateNewsItem( + UpdateNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(Integer.toString(request.getId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), NewsItem.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a single news item. + */ + public CompletableFuture> deleteNewsItem(DeleteNewsItemRequest request) { + return deleteNewsItem(request, null); + } + + /** + * You can delete a single news item. + */ + public CompletableFuture> deleteNewsItem( + DeleteNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DeletedObject.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public CompletableFuture> listLiveNewsfeedItems( + ListLiveNewsfeedItemsRequest request) { + return listLiveNewsfeedItems(request, null); + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public CompletableFuture> listLiveNewsfeedItems( + ListLiveNewsfeedItemsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getId()) + .addPathSegments("items") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), PaginatedResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of all newsfeeds + */ + public CompletableFuture> listNewsfeeds() { + return listNewsfeeds(null); + } + + /** + * You can fetch a list of all newsfeeds + */ + public CompletableFuture> listNewsfeeds(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), PaginatedResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single newsfeed + */ + public CompletableFuture> retrieveNewsfeed(RetrieveNewsfeedRequest request) { + return retrieveNewsfeed(request, null); + } + + /** + * You can fetch the details of a single newsfeed + */ + public CompletableFuture> retrieveNewsfeed( + RetrieveNewsfeedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Newsfeed.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/NewsClient.java b/src/main/java/com/intercom/api/resources/unstable/news/NewsClient.java new file mode 100644 index 0000000..10740ef --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/NewsClient.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.news.requests.DeleteNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.ListLiveNewsfeedItemsRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsfeedRequest; +import com.intercom.api.resources.unstable.news.requests.UpdateNewsItemRequest; +import com.intercom.api.resources.unstable.news.types.NewsItem; +import com.intercom.api.resources.unstable.news.types.Newsfeed; +import com.intercom.api.resources.unstable.types.DeletedObject; +import com.intercom.api.resources.unstable.types.NewsItemRequest; +import com.intercom.api.resources.unstable.types.PaginatedResponse; + +public class NewsClient { + protected final ClientOptions clientOptions; + + private final RawNewsClient rawClient; + + public NewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawNewsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawNewsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all news items + */ + public PaginatedResponse listNewsItems() { + return this.rawClient.listNewsItems().body(); + } + + /** + * You can fetch a list of all news items + */ + public PaginatedResponse listNewsItems(RequestOptions requestOptions) { + return this.rawClient.listNewsItems(requestOptions).body(); + } + + /** + * You can create a news item + */ + public NewsItem createNewsItem(NewsItemRequest request) { + return this.rawClient.createNewsItem(request).body(); + } + + /** + * You can create a news item + */ + public NewsItem createNewsItem(NewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.createNewsItem(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single news item. + */ + public NewsItem retrieveNewsItem(RetrieveNewsItemRequest request) { + return this.rawClient.retrieveNewsItem(request).body(); + } + + /** + * You can fetch the details of a single news item. + */ + public NewsItem retrieveNewsItem(RetrieveNewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveNewsItem(request, requestOptions).body(); + } + + public NewsItem updateNewsItem(UpdateNewsItemRequest request) { + return this.rawClient.updateNewsItem(request).body(); + } + + public NewsItem updateNewsItem(UpdateNewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.updateNewsItem(request, requestOptions).body(); + } + + /** + * You can delete a single news item. + */ + public DeletedObject deleteNewsItem(DeleteNewsItemRequest request) { + return this.rawClient.deleteNewsItem(request).body(); + } + + /** + * You can delete a single news item. + */ + public DeletedObject deleteNewsItem(DeleteNewsItemRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteNewsItem(request, requestOptions).body(); + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public PaginatedResponse listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest request) { + return this.rawClient.listLiveNewsfeedItems(request).body(); + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public PaginatedResponse listLiveNewsfeedItems( + ListLiveNewsfeedItemsRequest request, RequestOptions requestOptions) { + return this.rawClient.listLiveNewsfeedItems(request, requestOptions).body(); + } + + /** + * You can fetch a list of all newsfeeds + */ + public PaginatedResponse listNewsfeeds() { + return this.rawClient.listNewsfeeds().body(); + } + + /** + * You can fetch a list of all newsfeeds + */ + public PaginatedResponse listNewsfeeds(RequestOptions requestOptions) { + return this.rawClient.listNewsfeeds(requestOptions).body(); + } + + /** + * You can fetch the details of a single newsfeed + */ + public Newsfeed retrieveNewsfeed(RetrieveNewsfeedRequest request) { + return this.rawClient.retrieveNewsfeed(request).body(); + } + + /** + * You can fetch the details of a single newsfeed + */ + public Newsfeed retrieveNewsfeed(RetrieveNewsfeedRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveNewsfeed(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/RawNewsClient.java b/src/main/java/com/intercom/api/resources/unstable/news/RawNewsClient.java new file mode 100644 index 0000000..1384d84 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/RawNewsClient.java @@ -0,0 +1,480 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.news.requests.DeleteNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.ListLiveNewsfeedItemsRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsItemRequest; +import com.intercom.api.resources.unstable.news.requests.RetrieveNewsfeedRequest; +import com.intercom.api.resources.unstable.news.requests.UpdateNewsItemRequest; +import com.intercom.api.resources.unstable.news.types.NewsItem; +import com.intercom.api.resources.unstable.news.types.Newsfeed; +import com.intercom.api.resources.unstable.types.DeletedObject; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.NewsItemRequest; +import com.intercom.api.resources.unstable.types.PaginatedResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawNewsClient { + protected final ClientOptions clientOptions; + + public RawNewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all news items + */ + public IntercomHttpResponse listNewsItems() { + return listNewsItems(null); + } + + /** + * You can fetch a list of all news items + */ + public IntercomHttpResponse listNewsItems(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a news item + */ + public IntercomHttpResponse createNewsItem(NewsItemRequest request) { + return createNewsItem(request, null); + } + + /** + * You can create a news item + */ + public IntercomHttpResponse createNewsItem(NewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single news item. + */ + public IntercomHttpResponse retrieveNewsItem(RetrieveNewsItemRequest request) { + return retrieveNewsItem(request, null); + } + + /** + * You can fetch the details of a single news item. + */ + public IntercomHttpResponse retrieveNewsItem( + RetrieveNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + public IntercomHttpResponse updateNewsItem(UpdateNewsItemRequest request) { + return updateNewsItem(request, null); + } + + public IntercomHttpResponse updateNewsItem(UpdateNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(Integer.toString(request.getId())) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single news item. + */ + public IntercomHttpResponse deleteNewsItem(DeleteNewsItemRequest request) { + return deleteNewsItem(request, null); + } + + /** + * You can delete a single news item. + */ + public IntercomHttpResponse deleteNewsItem( + DeleteNewsItemRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/news_items") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedObject.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public IntercomHttpResponse listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest request) { + return listLiveNewsfeedItems(request, null); + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + public IntercomHttpResponse listLiveNewsfeedItems( + ListLiveNewsfeedItemsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getId()) + .addPathSegments("items") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all newsfeeds + */ + public IntercomHttpResponse listNewsfeeds() { + return listNewsfeeds(null); + } + + /** + * You can fetch a list of all newsfeeds + */ + public IntercomHttpResponse listNewsfeeds(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single newsfeed + */ + public IntercomHttpResponse retrieveNewsfeed(RetrieveNewsfeedRequest request) { + return retrieveNewsfeed(request, null); + } + + /** + * You can fetch the details of a single newsfeed + */ + public IntercomHttpResponse retrieveNewsfeed( + RetrieveNewsfeedRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("news/newsfeeds") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Newsfeed.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/requests/DeleteNewsItemRequest.java b/src/main/java/com/intercom/api/resources/unstable/news/requests/DeleteNewsItemRequest.java new file mode 100644 index 0000000..5b1e166 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/requests/DeleteNewsItemRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteNewsItemRequest.Builder.class) +public final class DeleteNewsItemRequest { + private final int id; + + private final Map additionalProperties; + + private DeleteNewsItemRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news item which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteNewsItemRequest && equalTo((DeleteNewsItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteNewsItemRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the news item which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(DeleteNewsItemRequest other); + } + + public interface _FinalStage { + DeleteNewsItemRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteNewsItemRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the news item which is given by Intercom.

The unique identifier for the news item which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public DeleteNewsItemRequest build() { + return new DeleteNewsItemRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/requests/ListLiveNewsfeedItemsRequest.java b/src/main/java/com/intercom/api/resources/unstable/news/requests/ListLiveNewsfeedItemsRequest.java new file mode 100644 index 0000000..8f296c3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/requests/ListLiveNewsfeedItemsRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListLiveNewsfeedItemsRequest.Builder.class) +public final class ListLiveNewsfeedItemsRequest { + private final String id; + + private final Map additionalProperties; + + private ListLiveNewsfeedItemsRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news feed item which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListLiveNewsfeedItemsRequest && equalTo((ListLiveNewsfeedItemsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListLiveNewsfeedItemsRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the news feed item which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(ListLiveNewsfeedItemsRequest other); + } + + public interface _FinalStage { + ListLiveNewsfeedItemsRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListLiveNewsfeedItemsRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the news feed item which is given by Intercom.

The unique identifier for the news feed item which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public ListLiveNewsfeedItemsRequest build() { + return new ListLiveNewsfeedItemsRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/requests/RetrieveNewsItemRequest.java b/src/main/java/com/intercom/api/resources/unstable/news/requests/RetrieveNewsItemRequest.java new file mode 100644 index 0000000..4f48df4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/requests/RetrieveNewsItemRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveNewsItemRequest.Builder.class) +public final class RetrieveNewsItemRequest { + private final int id; + + private final Map additionalProperties; + + private RetrieveNewsItemRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news item which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveNewsItemRequest && equalTo((RetrieveNewsItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveNewsItemRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the news item which is given by Intercom. + */ + _FinalStage id(int id); + + Builder from(RetrieveNewsItemRequest other); + } + + public interface _FinalStage { + RetrieveNewsItemRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveNewsItemRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the news item which is given by Intercom.

The unique identifier for the news item which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public RetrieveNewsItemRequest build() { + return new RetrieveNewsItemRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/requests/RetrieveNewsfeedRequest.java b/src/main/java/com/intercom/api/resources/unstable/news/requests/RetrieveNewsfeedRequest.java new file mode 100644 index 0000000..d9757e7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/requests/RetrieveNewsfeedRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveNewsfeedRequest.Builder.class) +public final class RetrieveNewsfeedRequest { + private final String id; + + private final Map additionalProperties; + + private RetrieveNewsfeedRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news feed item which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveNewsfeedRequest && equalTo((RetrieveNewsfeedRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveNewsfeedRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the news feed item which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(RetrieveNewsfeedRequest other); + } + + public interface _FinalStage { + RetrieveNewsfeedRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveNewsfeedRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the news feed item which is given by Intercom.

The unique identifier for the news feed item which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public RetrieveNewsfeedRequest build() { + return new RetrieveNewsfeedRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/requests/UpdateNewsItemRequest.java b/src/main/java/com/intercom/api/resources/unstable/news/requests/UpdateNewsItemRequest.java new file mode 100644 index 0000000..77f55df --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/requests/UpdateNewsItemRequest.java @@ -0,0 +1,135 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.NewsItemRequest; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateNewsItemRequest.Builder.class) +public final class UpdateNewsItemRequest { + private final int id; + + private final NewsItemRequest body; + + private final Map additionalProperties; + + private UpdateNewsItemRequest(int id, NewsItemRequest body, Map additionalProperties) { + this.id = id; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news item which is given by Intercom. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @JsonProperty("body") + public NewsItemRequest getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateNewsItemRequest && equalTo((UpdateNewsItemRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateNewsItemRequest other) { + return id == other.id && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the news item which is given by Intercom. + */ + BodyStage id(int id); + + Builder from(UpdateNewsItemRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull NewsItemRequest body); + } + + public interface _FinalStage { + UpdateNewsItemRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, BodyStage, _FinalStage { + private int id; + + private NewsItemRequest body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateNewsItemRequest other) { + id(other.getId()); + body(other.getBody()); + return this; + } + + /** + * The unique identifier for the news item which is given by Intercom.

The unique identifier for the news item which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public BodyStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull NewsItemRequest body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public UpdateNewsItemRequest build() { + return new UpdateNewsItemRequest(id, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/types/NewsItem.java b/src/main/java/com/intercom/api/resources/unstable/news/types/NewsItem.java new file mode 100644 index 0000000..6f19ff7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/types/NewsItem.java @@ -0,0 +1,568 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NewsItem.Builder.class) +public final class NewsItem { + private final Optional id; + + private final Optional workspaceId; + + private final Optional title; + + private final Optional body; + + private final Optional senderId; + + private final Optional state; + + private final Optional> newsfeedAssignments; + + private final Optional>> labels; + + private final Optional coverImageUrl; + + private final Optional>> reactions; + + private final Optional deliverSilently; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private NewsItem( + Optional id, + Optional workspaceId, + Optional title, + Optional body, + Optional senderId, + Optional state, + Optional> newsfeedAssignments, + Optional>> labels, + Optional coverImageUrl, + Optional>> reactions, + Optional deliverSilently, + Optional createdAt, + Optional updatedAt, + Map additionalProperties) { + this.id = id; + this.workspaceId = workspaceId; + this.title = title; + this.body = body; + this.senderId = senderId; + this.state = state; + this.newsfeedAssignments = newsfeedAssignments; + this.labels = labels; + this.coverImageUrl = coverImageUrl; + this.reactions = reactions; + this.deliverSilently = deliverSilently; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the news item which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the workspace which the news item belongs to. + */ + @JsonProperty("workspace_id") + public Optional getWorkspaceId() { + return workspaceId; + } + + /** + * @return The title of the news item. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The news item body, which may contain HTML. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the sender of the news item. Must be a teammate on the workspace. + */ + @JsonProperty("sender_id") + public Optional getSenderId() { + return senderId; + } + + /** + * @return News items will not be visible to your users in the assigned newsfeeds until they are set live. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + /** + * @return A list of newsfeed_assignments to assign to the specified newsfeed. + */ + @JsonProperty("newsfeed_assignments") + public Optional> getNewsfeedAssignments() { + return newsfeedAssignments; + } + + /** + * @return Label names displayed to users to categorize the news item. + */ + @JsonProperty("labels") + public Optional>> getLabels() { + return labels; + } + + /** + * @return URL of the image used as cover. Must have .jpg or .png extension. + */ + @JsonProperty("cover_image_url") + public Optional getCoverImageUrl() { + return coverImageUrl; + } + + /** + * @return Ordered list of emoji reactions to the news item. When empty, reactions are disabled. + */ + @JsonProperty("reactions") + public Optional>> getReactions() { + return reactions; + } + + /** + * @return When set to true, the news item will appear in the messenger newsfeed without showing a notification badge. + */ + @JsonProperty("deliver_silently") + public Optional getDeliverSilently() { + return deliverSilently; + } + + /** + * @return Timestamp for when the news item was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp for when the news item was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NewsItem && equalTo((NewsItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NewsItem other) { + return id.equals(other.id) + && workspaceId.equals(other.workspaceId) + && title.equals(other.title) + && body.equals(other.body) + && senderId.equals(other.senderId) + && state.equals(other.state) + && newsfeedAssignments.equals(other.newsfeedAssignments) + && labels.equals(other.labels) + && coverImageUrl.equals(other.coverImageUrl) + && reactions.equals(other.reactions) + && deliverSilently.equals(other.deliverSilently) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.workspaceId, + this.title, + this.body, + this.senderId, + this.state, + this.newsfeedAssignments, + this.labels, + this.coverImageUrl, + this.reactions, + this.deliverSilently, + this.createdAt, + this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional workspaceId = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional senderId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional> newsfeedAssignments = Optional.empty(); + + private Optional>> labels = Optional.empty(); + + private Optional coverImageUrl = Optional.empty(); + + private Optional>> reactions = Optional.empty(); + + private Optional deliverSilently = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(NewsItem other) { + id(other.getId()); + workspaceId(other.getWorkspaceId()); + title(other.getTitle()); + body(other.getBody()); + senderId(other.getSenderId()); + state(other.getState()); + newsfeedAssignments(other.getNewsfeedAssignments()); + labels(other.getLabels()); + coverImageUrl(other.getCoverImageUrl()); + reactions(other.getReactions()); + deliverSilently(other.getDeliverSilently()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

The unique identifier for the news item which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The id of the workspace which the news item belongs to.

+ */ + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } + + /** + *

The title of the news item.

+ */ + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; + return this; + } + + public Builder title(String title) { + this.title = Optional.ofNullable(title); + return this; + } + + /** + *

The news item body, which may contain HTML.

+ */ + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + /** + *

The id of the sender of the news item. Must be a teammate on the workspace.

+ */ + @JsonSetter(value = "sender_id", nulls = Nulls.SKIP) + public Builder senderId(Optional senderId) { + this.senderId = senderId; + return this; + } + + public Builder senderId(Integer senderId) { + this.senderId = Optional.ofNullable(senderId); + return this; + } + + /** + *

News items will not be visible to your users in the assigned newsfeeds until they are set live.

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(State state) { + this.state = Optional.ofNullable(state); + return this; + } + + /** + *

A list of newsfeed_assignments to assign to the specified newsfeed.

+ */ + @JsonSetter(value = "newsfeed_assignments", nulls = Nulls.SKIP) + public Builder newsfeedAssignments(Optional> newsfeedAssignments) { + this.newsfeedAssignments = newsfeedAssignments; + return this; + } + + public Builder newsfeedAssignments(List newsfeedAssignments) { + this.newsfeedAssignments = Optional.ofNullable(newsfeedAssignments); + return this; + } + + /** + *

Label names displayed to users to categorize the news item.

+ */ + @JsonSetter(value = "labels", nulls = Nulls.SKIP) + public Builder labels(Optional>> labels) { + this.labels = labels; + return this; + } + + public Builder labels(List> labels) { + this.labels = Optional.ofNullable(labels); + return this; + } + + /** + *

URL of the image used as cover. Must have .jpg or .png extension.

+ */ + @JsonSetter(value = "cover_image_url", nulls = Nulls.SKIP) + public Builder coverImageUrl(Optional coverImageUrl) { + this.coverImageUrl = coverImageUrl; + return this; + } + + public Builder coverImageUrl(String coverImageUrl) { + this.coverImageUrl = Optional.ofNullable(coverImageUrl); + return this; + } + + /** + *

Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

+ */ + @JsonSetter(value = "reactions", nulls = Nulls.SKIP) + public Builder reactions(Optional>> reactions) { + this.reactions = reactions; + return this; + } + + public Builder reactions(List> reactions) { + this.reactions = Optional.ofNullable(reactions); + return this; + } + + /** + *

When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

+ */ + @JsonSetter(value = "deliver_silently", nulls = Nulls.SKIP) + public Builder deliverSilently(Optional deliverSilently) { + this.deliverSilently = deliverSilently; + return this; + } + + public Builder deliverSilently(Boolean deliverSilently) { + this.deliverSilently = Optional.ofNullable(deliverSilently); + return this; + } + + /** + *

Timestamp for when the news item was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

Timestamp for when the news item was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + public NewsItem build() { + return new NewsItem( + id, + workspaceId, + title, + body, + senderId, + state, + newsfeedAssignments, + labels, + coverImageUrl, + reactions, + deliverSilently, + createdAt, + updatedAt, + additionalProperties); + } + } + + public static final class State { + public static final State LIVE = new State(Value.LIVE, "live"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + private final Value value; + + private final String string; + + State(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof State && this.string.equals(((State) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case LIVE: + return visitor.visitLive(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "live": + return LIVE; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + DRAFT, + + LIVE, + + UNKNOWN + } + + public interface Visitor { + T visitDraft(); + + T visitLive(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/types/Newsfeed.java b/src/main/java/com/intercom/api/resources/unstable/news/types/Newsfeed.java new file mode 100644 index 0000000..8d1c6c6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/types/Newsfeed.java @@ -0,0 +1,193 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Newsfeed.Builder.class) +public final class Newsfeed { + private final Optional id; + + private final Optional name; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Map additionalProperties; + + private Newsfeed( + Optional id, + Optional name, + Optional createdAt, + Optional updatedAt, + Map additionalProperties) { + this.id = id; + this.name = name; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the newsfeed which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the newsfeed. This name will never be visible to your users. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return Timestamp for when the newsfeed was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Timestamp for when the newsfeed was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Newsfeed && equalTo((Newsfeed) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Newsfeed other) { + return id.equals(other.id) + && name.equals(other.name) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.createdAt, this.updatedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Newsfeed other) { + id(other.getId()); + name(other.getName()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + return this; + } + + /** + *

The unique identifier for the newsfeed which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the newsfeed. This name will never be visible to your users.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

Timestamp for when the newsfeed was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

Timestamp for when the newsfeed was last updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + public Newsfeed build() { + return new Newsfeed(id, name, createdAt, updatedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/news/types/NewsfeedAssignment.java b/src/main/java/com/intercom/api/resources/unstable/news/types/NewsfeedAssignment.java new file mode 100644 index 0000000..754bf99 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/news/types/NewsfeedAssignment.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.news.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = NewsfeedAssignment.Builder.class) +public final class NewsfeedAssignment { + private final Optional newsfeedId; + + private final Optional publishedAt; + + private final Map additionalProperties; + + private NewsfeedAssignment( + Optional newsfeedId, Optional publishedAt, Map additionalProperties) { + this.newsfeedId = newsfeedId; + this.publishedAt = publishedAt; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). + */ + @JsonProperty("newsfeed_id") + public Optional getNewsfeedId() { + return newsfeedId; + } + + /** + * @return Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". + */ + @JsonProperty("published_at") + public Optional getPublishedAt() { + return publishedAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof NewsfeedAssignment && equalTo((NewsfeedAssignment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(NewsfeedAssignment other) { + return newsfeedId.equals(other.newsfeedId) && publishedAt.equals(other.publishedAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.newsfeedId, this.publishedAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional newsfeedId = Optional.empty(); + + private Optional publishedAt = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(NewsfeedAssignment other) { + newsfeedId(other.getNewsfeedId()); + publishedAt(other.getPublishedAt()); + return this; + } + + /** + *

The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article).

+ */ + @JsonSetter(value = "newsfeed_id", nulls = Nulls.SKIP) + public Builder newsfeedId(Optional newsfeedId) { + this.newsfeedId = newsfeedId; + return this; + } + + public Builder newsfeedId(Integer newsfeedId) { + this.newsfeedId = Optional.ofNullable(newsfeedId); + return this; + } + + /** + *

Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft".

+ */ + @JsonSetter(value = "published_at", nulls = Nulls.SKIP) + public Builder publishedAt(Optional publishedAt) { + this.publishedAt = publishedAt; + return this; + } + + public Builder publishedAt(Integer publishedAt) { + this.publishedAt = Optional.ofNullable(publishedAt); + return this; + } + + public NewsfeedAssignment build() { + return new NewsfeedAssignment(newsfeedId, publishedAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/notes/AsyncNotesClient.java b/src/main/java/com/intercom/api/resources/unstable/notes/AsyncNotesClient.java new file mode 100644 index 0000000..771f62a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/notes/AsyncNotesClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.notes; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.notes.requests.CreateNoteRequest; +import com.intercom.api.resources.unstable.notes.requests.ListNotesRequest; +import com.intercom.api.resources.unstable.notes.requests.RetrieveNoteRequest; +import com.intercom.api.resources.unstable.notes.types.Note; +import com.intercom.api.resources.unstable.types.NoteList; +import java.util.concurrent.CompletableFuture; + +public class AsyncNotesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawNotesClient rawClient; + + public AsyncNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawNotesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawNotesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public CompletableFuture listNotes(ListNotesRequest request) { + return this.rawClient.listNotes(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public CompletableFuture listNotes(ListNotesRequest request, RequestOptions requestOptions) { + return this.rawClient.listNotes(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can add a note to a single contact. + */ + public CompletableFuture createNote(CreateNoteRequest request) { + return this.rawClient.createNote(request).thenApply(response -> response.body()); + } + + /** + * You can add a note to a single contact. + */ + public CompletableFuture createNote(CreateNoteRequest request, RequestOptions requestOptions) { + return this.rawClient.createNote(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single note. + */ + public CompletableFuture retrieveNote(RetrieveNoteRequest request) { + return this.rawClient.retrieveNote(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single note. + */ + public CompletableFuture retrieveNote(RetrieveNoteRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveNote(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/unstable/notes/AsyncRawNotesClient.java similarity index 51% rename from src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java rename to src/main/java/com/intercom/api/resources/unstable/notes/AsyncRawNotesClient.java index b4153df..344ad1d 100644 --- a/src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java +++ b/src/main/java/com/intercom/api/resources/unstable/notes/AsyncRawNotesClient.java @@ -1,14 +1,24 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.resources.customchannelevents; +package com.intercom.api.resources.unstable.notes; +import com.fasterxml.jackson.core.JsonProcessingException; import com.intercom.api.core.ClientOptions; import com.intercom.api.core.IntercomApiException; import com.intercom.api.core.IntercomException; import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; import com.intercom.api.core.ObjectMappers; import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.notes.requests.CreateNoteRequest; +import com.intercom.api.resources.unstable.notes.requests.ListNotesRequest; +import com.intercom.api.resources.unstable.notes.requests.RetrieveNoteRequest; +import com.intercom.api.resources.unstable.notes.types.Note; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.NoteList; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -22,88 +32,62 @@ import okhttp3.ResponseBody; import org.jetbrains.annotations.NotNull; -public class AsyncRawCustomChannelEventsClient { +public class AsyncRawNotesClient { protected final ClientOptions clientOptions; - public AsyncRawCustomChannelEventsClient(ClientOptions clientOptions) { + public AsyncRawNotesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } - public CompletableFuture> notifyAttributeCollected() { - return notifyAttributeCollected(null); + /** + * You can fetch a list of notes that are associated to a contact. + */ + public CompletableFuture> listNotes(ListNotesRequest request) { + return listNotes(request, null); } - public CompletableFuture> notifyAttributeCollected(RequestOptions requestOptions) { + /** + * You can fetch a list of notes that are associated to a contact. + */ + public CompletableFuture> listNotes( + ListNotesRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("custom_channel_events/notify_attribute_collected") + .addPathSegments("contacts") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("notes") .build(); - Request okhttpRequest = new Request.Builder() + Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) - .method("POST", RequestBody.create("", null)) + .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); OkHttpClient client = clientOptions.httpClient(); 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<>(null, response)); + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteList.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } catch (IOException e) { - future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); - } - }); - return future; - } - - public CompletableFuture> notifyNewMessage() { - return notifyNewMessage(null); - } - - public CompletableFuture> notifyNewMessage(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("custom_channel_events/notify_new_message") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - 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<>(null, response)); - return; + try { + if (response.code() == 404) { + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; future.completeExceptionally(new IntercomApiException( "Error with status code " + response.code(), response.code(), @@ -123,34 +107,62 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } - public CompletableFuture> notifyNewConversation() { - return notifyNewConversation(null); + /** + * You can add a note to a single contact. + */ + public CompletableFuture> createNote(CreateNoteRequest request) { + return createNote(request, null); } - public CompletableFuture> notifyNewConversation(RequestOptions requestOptions) { + /** + * You can add a note to a single contact. + */ + public CompletableFuture> createNote( + CreateNoteRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("custom_channel_events/notify_new_conversation") + .addPathSegments("contacts") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("notes") .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } Request okhttpRequest = new Request.Builder() .url(httpUrl) - .method("POST", RequestBody.create("", null)) + .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") .build(); OkHttpClient client = clientOptions.httpClient(); 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<>(null, response)); + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } future.completeExceptionally(new IntercomApiException( "Error with status code " + response.code(), response.code(), @@ -170,34 +182,61 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { return future; } - public CompletableFuture> notifyQuickReplySelected() { - return notifyQuickReplySelected(null); + /** + * You can fetch the details of a single note. + */ + public CompletableFuture> retrieveNote(RetrieveNoteRequest request) { + return retrieveNote(request, null); } - public CompletableFuture> notifyQuickReplySelected(RequestOptions requestOptions) { + /** + * You can fetch the details of a single note. + */ + public CompletableFuture> retrieveNote( + RetrieveNoteRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("custom_channel_events/notify_quick_reply_selected") + .addPathSegments("notes") + .addPathSegment(Integer.toString(request.getId())) .build(); - Request okhttpRequest = new Request.Builder() + Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl) - .method("POST", RequestBody.create("", null)) + .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); OkHttpClient client = clientOptions.httpClient(); 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<>(null, response)); + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response)); return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } future.completeExceptionally(new IntercomApiException( "Error with status code " + response.code(), response.code(), diff --git a/src/main/java/com/intercom/api/resources/unstable/notes/NotesClient.java b/src/main/java/com/intercom/api/resources/unstable/notes/NotesClient.java new file mode 100644 index 0000000..3a8bd5a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/notes/NotesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.notes; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.notes.requests.CreateNoteRequest; +import com.intercom.api.resources.unstable.notes.requests.ListNotesRequest; +import com.intercom.api.resources.unstable.notes.requests.RetrieveNoteRequest; +import com.intercom.api.resources.unstable.notes.types.Note; +import com.intercom.api.resources.unstable.types.NoteList; + +public class NotesClient { + protected final ClientOptions clientOptions; + + private final RawNotesClient rawClient; + + public NotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawNotesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawNotesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public NoteList listNotes(ListNotesRequest request) { + return this.rawClient.listNotes(request).body(); + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public NoteList listNotes(ListNotesRequest request, RequestOptions requestOptions) { + return this.rawClient.listNotes(request, requestOptions).body(); + } + + /** + * You can add a note to a single contact. + */ + public Note createNote(CreateNoteRequest request) { + return this.rawClient.createNote(request).body(); + } + + /** + * You can add a note to a single contact. + */ + public Note createNote(CreateNoteRequest request, RequestOptions requestOptions) { + return this.rawClient.createNote(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single note. + */ + public Note retrieveNote(RetrieveNoteRequest request) { + return this.rawClient.retrieveNote(request).body(); + } + + /** + * You can fetch the details of a single note. + */ + public Note retrieveNote(RetrieveNoteRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveNote(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/notes/RawNotesClient.java b/src/main/java/com/intercom/api/resources/unstable/notes/RawNotesClient.java new file mode 100644 index 0000000..1a8a002 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/notes/RawNotesClient.java @@ -0,0 +1,206 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.notes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.notes.requests.CreateNoteRequest; +import com.intercom.api.resources.unstable.notes.requests.ListNotesRequest; +import com.intercom.api.resources.unstable.notes.requests.RetrieveNoteRequest; +import com.intercom.api.resources.unstable.notes.types.Note; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.NoteList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawNotesClient { + protected final ClientOptions clientOptions; + + public RawNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public IntercomHttpResponse listNotes(ListNotesRequest request) { + return listNotes(request, null); + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + public IntercomHttpResponse listNotes(ListNotesRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("notes") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can add a note to a single contact. + */ + public IntercomHttpResponse createNote(CreateNoteRequest request) { + return createNote(request, null); + } + + /** + * You can add a note to a single contact. + */ + public IntercomHttpResponse createNote(CreateNoteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(Integer.toString(request.getId())) + .addPathSegments("notes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 404) { + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single note. + */ + public IntercomHttpResponse retrieveNote(RetrieveNoteRequest request) { + return retrieveNote(request, null); + } + + /** + * You can fetch the details of a single note. + */ + public IntercomHttpResponse retrieveNote(RetrieveNoteRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("notes") + .addPathSegment(Integer.toString(request.getId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/notes/requests/CreateNoteRequest.java b/src/main/java/com/intercom/api/resources/unstable/notes/requests/CreateNoteRequest.java new file mode 100644 index 0000000..f0df0e4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/notes/requests/CreateNoteRequest.java @@ -0,0 +1,236 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.notes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CreateNoteRequest.Builder.class) +public final class CreateNoteRequest { + private final int id; + + private final String body; + + private final Optional contactId; + + private final Optional adminId; + + private final Map additionalProperties; + + private CreateNoteRequest( + int id, + String body, + Optional contactId, + Optional adminId, + Map additionalProperties) { + this.id = id; + this.body = body; + this.contactId = contactId; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given contact. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + /** + * @return The text of the note. + */ + @JsonProperty("body") + public String getBody() { + return body; + } + + /** + * @return The unique identifier of a given contact. + */ + @JsonProperty("contact_id") + public Optional getContactId() { + return contactId; + } + + /** + * @return The unique identifier of a given admin. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CreateNoteRequest && equalTo((CreateNoteRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateNoteRequest other) { + return id == other.id + && body.equals(other.body) + && contactId.equals(other.contactId) + && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.body, this.contactId, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a given contact. + */ + BodyStage id(int id); + + Builder from(CreateNoteRequest other); + } + + public interface BodyStage { + /** + * The text of the note. + */ + _FinalStage body(@NotNull String body); + } + + public interface _FinalStage { + CreateNoteRequest build(); + + /** + *

The unique identifier of a given contact.

+ */ + _FinalStage contactId(Optional contactId); + + _FinalStage contactId(String contactId); + + /** + *

The unique identifier of a given admin.

+ */ + _FinalStage adminId(Optional adminId); + + _FinalStage adminId(String adminId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, BodyStage, _FinalStage { + private int id; + + private String body; + + private Optional adminId = Optional.empty(); + + private Optional contactId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(CreateNoteRequest other) { + id(other.getId()); + body(other.getBody()); + contactId(other.getContactId()); + adminId(other.getAdminId()); + return this; + } + + /** + * The unique identifier of a given contact.

The unique identifier of a given contact.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public BodyStage id(int id) { + this.id = id; + return this; + } + + /** + * The text of the note.

The text of the note.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull String body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + /** + *

The unique identifier of a given admin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage adminId(String adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + /** + *

The unique identifier of a given admin.

+ */ + @java.lang.Override + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + /** + *

The unique identifier of a given contact.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage contactId(String contactId) { + this.contactId = Optional.ofNullable(contactId); + return this; + } + + /** + *

The unique identifier of a given contact.

+ */ + @java.lang.Override + @JsonSetter(value = "contact_id", nulls = Nulls.SKIP) + public _FinalStage contactId(Optional contactId) { + this.contactId = contactId; + return this; + } + + @java.lang.Override + public CreateNoteRequest build() { + return new CreateNoteRequest(id, body, contactId, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/notes/requests/ListNotesRequest.java b/src/main/java/com/intercom/api/resources/unstable/notes/requests/ListNotesRequest.java new file mode 100644 index 0000000..43cb1e3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/notes/requests/ListNotesRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.notes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListNotesRequest.Builder.class) +public final class ListNotesRequest { + private final int id; + + private final Map additionalProperties; + + private ListNotesRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a contact. + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListNotesRequest && equalTo((ListNotesRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListNotesRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a contact. + */ + _FinalStage id(int id); + + Builder from(ListNotesRequest other); + } + + public interface _FinalStage { + ListNotesRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListNotesRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier of a contact.

The unique identifier of a contact.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public ListNotesRequest build() { + return new ListNotesRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/notes/requests/RetrieveNoteRequest.java b/src/main/java/com/intercom/api/resources/unstable/notes/requests/RetrieveNoteRequest.java new file mode 100644 index 0000000..475b27d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/notes/requests/RetrieveNoteRequest.java @@ -0,0 +1,111 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.notes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveNoteRequest.Builder.class) +public final class RetrieveNoteRequest { + private final int id; + + private final Map additionalProperties; + + private RetrieveNoteRequest(int id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given note + */ + @JsonProperty("id") + public int getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveNoteRequest && equalTo((RetrieveNoteRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveNoteRequest other) { + return id == other.id; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a given note + */ + _FinalStage id(int id); + + Builder from(RetrieveNoteRequest other); + } + + public interface _FinalStage { + RetrieveNoteRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private int id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveNoteRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier of a given note

The unique identifier of a given note

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(int id) { + this.id = id; + return this; + } + + @java.lang.Override + public RetrieveNoteRequest build() { + return new RetrieveNoteRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/notes/types/Note.java b/src/main/java/com/intercom/api/resources/unstable/notes/types/Note.java new file mode 100644 index 0000000..c193e6b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/notes/types/Note.java @@ -0,0 +1,365 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.notes.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.admins.types.Admin; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Note.Builder.class) +public final class Note { + private final Optional type; + + private final Optional id; + + private final Optional createdAt; + + private final Optional contact; + + private final Optional author; + + private final Optional body; + + private final Map additionalProperties; + + private Note( + Optional type, + Optional id, + Optional createdAt, + Optional contact, + Optional author, + Optional body, + Map additionalProperties) { + this.type = type; + this.id = id; + this.createdAt = createdAt; + this.contact = contact; + this.author = author; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value note. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the note. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The time the note was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return Represents the contact that the note was created about. + */ + @JsonProperty("contact") + public Optional getContact() { + return contact; + } + + /** + * @return Optional. Represents the Admin that created the note. + */ + @JsonProperty("author") + public Optional getAuthor() { + return author; + } + + /** + * @return The body text of the note. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Note && equalTo((Note) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Note other) { + return type.equals(other.type) + && id.equals(other.id) + && createdAt.equals(other.createdAt) + && contact.equals(other.contact) + && author.equals(other.author) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.createdAt, this.contact, this.author, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional contact = Optional.empty(); + + private Optional author = Optional.empty(); + + private Optional body = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Note other) { + type(other.getType()); + id(other.getId()); + createdAt(other.getCreatedAt()); + contact(other.getContact()); + author(other.getAuthor()); + body(other.getBody()); + return this; + } + + /** + *

String representing the object's type. Always has the value note.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the note.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The time the note was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

Represents the contact that the note was created about.

+ */ + @JsonSetter(value = "contact", nulls = Nulls.SKIP) + public Builder contact(Optional contact) { + this.contact = contact; + return this; + } + + public Builder contact(Contact contact) { + this.contact = Optional.ofNullable(contact); + return this; + } + + /** + *

Optional. Represents the Admin that created the note.

+ */ + @JsonSetter(value = "author", nulls = Nulls.SKIP) + public Builder author(Optional author) { + this.author = author; + return this; + } + + public Builder author(Admin author) { + this.author = Optional.ofNullable(author); + return this; + } + + /** + *

The body text of the note.

+ */ + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + public Note build() { + return new Note(type, id, createdAt, contact, author, body, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Contact.Builder.class) + public static final class Contact { + private final Optional type; + + private final Optional id; + + private final Map additionalProperties; + + private Contact(Optional type, Optional id, Map additionalProperties) { + this.type = type; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value contact. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the contact. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Contact && equalTo((Contact) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Contact other) { + return type.equals(other.type) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Contact other) { + type(other.getType()); + id(other.getId()); + return this; + } + + /** + *

String representing the object's type. Always has the value contact.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the contact.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + public Contact build() { + return new Contact(type, id, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/segments/AsyncRawSegmentsClient.java b/src/main/java/com/intercom/api/resources/unstable/segments/AsyncRawSegmentsClient.java new file mode 100644 index 0000000..5aac182 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/segments/AsyncRawSegmentsClient.java @@ -0,0 +1,190 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.segments; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.segments.requests.ListSegmentsRequest; +import com.intercom.api.resources.unstable.segments.requests.RetrieveSegmentRequest; +import com.intercom.api.resources.unstable.segments.types.Segment; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SegmentList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSegmentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawSegmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture> listSegments() { + return listSegments(ListSegmentsRequest.builder().build()); + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture> listSegments(ListSegmentsRequest request) { + return listSegments(request, null); + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture> listSegments( + ListSegmentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments"); + if (request.getIncludeCount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_count", request.getIncludeCount().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), SegmentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single segment. + */ + public CompletableFuture> retrieveSegment(RetrieveSegmentRequest request) { + return retrieveSegment(request, null); + } + + /** + * You can fetch the details of a single segment. + */ + public CompletableFuture> retrieveSegment( + RetrieveSegmentRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Segment.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/segments/AsyncSegmentsClient.java b/src/main/java/com/intercom/api/resources/unstable/segments/AsyncSegmentsClient.java new file mode 100644 index 0000000..5c22c4a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/segments/AsyncSegmentsClient.java @@ -0,0 +1,65 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.segments; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.segments.requests.ListSegmentsRequest; +import com.intercom.api.resources.unstable.segments.requests.RetrieveSegmentRequest; +import com.intercom.api.resources.unstable.segments.types.Segment; +import com.intercom.api.resources.unstable.types.SegmentList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSegmentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSegmentsClient rawClient; + + public AsyncSegmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSegmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSegmentsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture listSegments() { + return this.rawClient.listSegments().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture listSegments(ListSegmentsRequest request) { + return this.rawClient.listSegments(request).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all segments. + */ + public CompletableFuture listSegments(ListSegmentsRequest request, RequestOptions requestOptions) { + return this.rawClient.listSegments(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single segment. + */ + public CompletableFuture retrieveSegment(RetrieveSegmentRequest request) { + return this.rawClient.retrieveSegment(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single segment. + */ + public CompletableFuture retrieveSegment(RetrieveSegmentRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveSegment(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/segments/RawSegmentsClient.java b/src/main/java/com/intercom/api/resources/unstable/segments/RawSegmentsClient.java new file mode 100644 index 0000000..21bbc7b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/segments/RawSegmentsClient.java @@ -0,0 +1,153 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.segments; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.QueryStringMapper; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.segments.requests.ListSegmentsRequest; +import com.intercom.api.resources.unstable.segments.requests.RetrieveSegmentRequest; +import com.intercom.api.resources.unstable.segments.types.Segment; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SegmentList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSegmentsClient { + protected final ClientOptions clientOptions; + + public RawSegmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all segments. + */ + public IntercomHttpResponse listSegments() { + return listSegments(ListSegmentsRequest.builder().build()); + } + + /** + * You can fetch a list of all segments. + */ + public IntercomHttpResponse listSegments(ListSegmentsRequest request) { + return listSegments(request, null); + } + + /** + * You can fetch a list of all segments. + */ + public IntercomHttpResponse listSegments(ListSegmentsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments"); + if (request.getIncludeCount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_count", request.getIncludeCount().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SegmentList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single segment. + */ + public IntercomHttpResponse retrieveSegment(RetrieveSegmentRequest request) { + return retrieveSegment(request, null); + } + + /** + * You can fetch the details of a single segment. + */ + public IntercomHttpResponse retrieveSegment( + RetrieveSegmentRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("segments") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Segment.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/segments/SegmentsClient.java b/src/main/java/com/intercom/api/resources/unstable/segments/SegmentsClient.java new file mode 100644 index 0000000..2dddec3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/segments/SegmentsClient.java @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.segments; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.segments.requests.ListSegmentsRequest; +import com.intercom.api.resources.unstable.segments.requests.RetrieveSegmentRequest; +import com.intercom.api.resources.unstable.segments.types.Segment; +import com.intercom.api.resources.unstable.types.SegmentList; + +public class SegmentsClient { + protected final ClientOptions clientOptions; + + private final RawSegmentsClient rawClient; + + public SegmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawSegmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSegmentsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all segments. + */ + public SegmentList listSegments() { + return this.rawClient.listSegments().body(); + } + + /** + * You can fetch a list of all segments. + */ + public SegmentList listSegments(ListSegmentsRequest request) { + return this.rawClient.listSegments(request).body(); + } + + /** + * You can fetch a list of all segments. + */ + public SegmentList listSegments(ListSegmentsRequest request, RequestOptions requestOptions) { + return this.rawClient.listSegments(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single segment. + */ + public Segment retrieveSegment(RetrieveSegmentRequest request) { + return this.rawClient.retrieveSegment(request).body(); + } + + /** + * You can fetch the details of a single segment. + */ + public Segment retrieveSegment(RetrieveSegmentRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveSegment(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/segments/requests/ListSegmentsRequest.java b/src/main/java/com/intercom/api/resources/unstable/segments/requests/ListSegmentsRequest.java new file mode 100644 index 0000000..4b52410 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/segments/requests/ListSegmentsRequest.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.segments.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListSegmentsRequest.Builder.class) +public final class ListSegmentsRequest { + private final Optional includeCount; + + private final Map additionalProperties; + + private ListSegmentsRequest(Optional includeCount, Map additionalProperties) { + this.includeCount = includeCount; + this.additionalProperties = additionalProperties; + } + + /** + * @return It includes the count of contacts that belong to each segment. + */ + @JsonProperty("include_count") + public Optional getIncludeCount() { + return includeCount; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListSegmentsRequest && equalTo((ListSegmentsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListSegmentsRequest other) { + return includeCount.equals(other.includeCount); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.includeCount); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional includeCount = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListSegmentsRequest other) { + includeCount(other.getIncludeCount()); + return this; + } + + /** + *

It includes the count of contacts that belong to each segment.

+ */ + @JsonSetter(value = "include_count", nulls = Nulls.SKIP) + public Builder includeCount(Optional includeCount) { + this.includeCount = includeCount; + return this; + } + + public Builder includeCount(Boolean includeCount) { + this.includeCount = Optional.ofNullable(includeCount); + return this; + } + + public ListSegmentsRequest build() { + return new ListSegmentsRequest(includeCount, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/segments/requests/RetrieveSegmentRequest.java b/src/main/java/com/intercom/api/resources/unstable/segments/requests/RetrieveSegmentRequest.java new file mode 100644 index 0000000..4cb515d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/segments/requests/RetrieveSegmentRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.segments.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveSegmentRequest.Builder.class) +public final class RetrieveSegmentRequest { + private final String id; + + private final Map additionalProperties; + + private RetrieveSegmentRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identified of a given segment. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveSegmentRequest && equalTo((RetrieveSegmentRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveSegmentRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identified of a given segment. + */ + _FinalStage id(@NotNull String id); + + Builder from(RetrieveSegmentRequest other); + } + + public interface _FinalStage { + RetrieveSegmentRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveSegmentRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identified of a given segment.

The unique identified of a given segment.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public RetrieveSegmentRequest build() { + return new RetrieveSegmentRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/segments/types/Segment.java b/src/main/java/com/intercom/api/resources/unstable/segments/types/Segment.java new file mode 100644 index 0000000..181fbe2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/segments/types/Segment.java @@ -0,0 +1,360 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.segments.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Segment.Builder.class) +public final class Segment { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional personType; + + private final Optional count; + + private final Map additionalProperties; + + private Segment( + Optional type, + Optional id, + Optional name, + Optional createdAt, + Optional updatedAt, + Optional personType, + Optional count, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.personType = personType; + this.count = count; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier representing the segment. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the segment. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The time the segment was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time the segment was updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return Type of the contact: contact (lead) or user. + */ + @JsonProperty("person_type") + public Optional getPersonType() { + return personType; + } + + /** + * @return The number of items in the user segment. It's returned when include_count=true is included in the request. + */ + @JsonProperty("count") + public Optional getCount() { + return count; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Segment && equalTo((Segment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Segment other) { + return type.equals(other.type) + && id.equals(other.id) + && name.equals(other.name) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && personType.equals(other.personType) + && count.equals(other.count); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.name, this.createdAt, this.updatedAt, this.personType, this.count); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional personType = Optional.empty(); + + private Optional count = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Segment other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + personType(other.getPersonType()); + count(other.getCount()); + return this; + } + + /** + *

The type of object.

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier representing the segment.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the segment.

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The time the segment was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time the segment was updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

Type of the contact: contact (lead) or user.

+ */ + @JsonSetter(value = "person_type", nulls = Nulls.SKIP) + public Builder personType(Optional personType) { + this.personType = personType; + return this; + } + + public Builder personType(PersonType personType) { + this.personType = Optional.ofNullable(personType); + return this; + } + + /** + *

The number of items in the user segment. It's returned when include_count=true is included in the request.

+ */ + @JsonSetter(value = "count", nulls = Nulls.SKIP) + public Builder count(Optional count) { + this.count = count; + return this; + } + + public Builder count(Integer count) { + this.count = Optional.ofNullable(count); + return this; + } + + public Segment build() { + return new Segment(type, id, name, createdAt, updatedAt, personType, count, additionalProperties); + } + } + + public static final class PersonType { + public static final PersonType USER = new PersonType(Value.USER, "user"); + + public static final PersonType CONTACT = new PersonType(Value.CONTACT, "contact"); + + private final Value value; + + private final String string; + + PersonType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof PersonType && this.string.equals(((PersonType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case USER: + return visitor.visitUser(); + case CONTACT: + return visitor.visitContact(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static PersonType valueOf(String value) { + switch (value) { + case "user": + return USER; + case "contact": + return CONTACT; + default: + return new PersonType(Value.UNKNOWN, value); + } + } + + public enum Value { + CONTACT, + + USER, + + UNKNOWN + } + + public interface Visitor { + T visitContact(); + + T visitUser(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/AsyncRawSubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/AsyncRawSubscriptionTypesClient.java new file mode 100644 index 0000000..ee0669b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/AsyncRawSubscriptionTypesClient.java @@ -0,0 +1,275 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.subscriptiontypes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.AttachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.DetachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.types.SubscriptionType; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSubscriptionTypesClient { + protected final ClientOptions clientOptions; + + public AsyncRawSubscriptionTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public CompletableFuture> attachSubscriptionTypeToContact( + AttachSubscriptionTypeToContactRequest request) { + return attachSubscriptionTypeToContact(request, null); + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public CompletableFuture> attachSubscriptionTypeToContact( + AttachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), SubscriptionType.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public CompletableFuture> detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest request) { + return detachSubscriptionTypeToContact(request, null); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public CompletableFuture> detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), SubscriptionType.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public CompletableFuture> listSubscriptionTypes() { + return listSubscriptionTypes(null); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public CompletableFuture> listSubscriptionTypes( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("subscription_types") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), SubscriptionTypeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/AsyncSubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/AsyncSubscriptionTypesClient.java new file mode 100644 index 0000000..0b09116 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/AsyncSubscriptionTypesClient.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.subscriptiontypes; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.AttachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.DetachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.types.SubscriptionType; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSubscriptionTypesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSubscriptionTypesClient rawClient; + + public AsyncSubscriptionTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSubscriptionTypesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSubscriptionTypesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public CompletableFuture attachSubscriptionTypeToContact( + AttachSubscriptionTypeToContactRequest request) { + return this.rawClient.attachSubscriptionTypeToContact(request).thenApply(response -> response.body()); + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public CompletableFuture attachSubscriptionTypeToContact( + AttachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + return this.rawClient + .attachSubscriptionTypeToContact(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public CompletableFuture detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest request) { + return this.rawClient.detachSubscriptionTypeToContact(request).thenApply(response -> response.body()); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public CompletableFuture detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + return this.rawClient + .detachSubscriptionTypeToContact(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public CompletableFuture listSubscriptionTypes() { + return this.rawClient.listSubscriptionTypes().thenApply(response -> response.body()); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public CompletableFuture listSubscriptionTypes(RequestOptions requestOptions) { + return this.rawClient.listSubscriptionTypes(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/RawSubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/RawSubscriptionTypesClient.java new file mode 100644 index 0000000..8a3c81d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/RawSubscriptionTypesClient.java @@ -0,0 +1,220 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.subscriptiontypes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.AttachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.DetachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.types.SubscriptionType; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSubscriptionTypesClient { + protected final ClientOptions clientOptions; + + public RawSubscriptionTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public IntercomHttpResponse attachSubscriptionTypeToContact( + AttachSubscriptionTypeToContactRequest request) { + return attachSubscriptionTypeToContact(request, null); + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public IntercomHttpResponse attachSubscriptionTypeToContact( + AttachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public IntercomHttpResponse detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest request) { + return detachSubscriptionTypeToContact(request, null); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public IntercomHttpResponse detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("subscriptions") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public IntercomHttpResponse listSubscriptionTypes() { + return listSubscriptionTypes(null); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public IntercomHttpResponse listSubscriptionTypes(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("subscription_types") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/SubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/SubscriptionTypesClient.java new file mode 100644 index 0000000..997aaab --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/SubscriptionTypesClient.java @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.subscriptiontypes; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.AttachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.requests.DetachSubscriptionTypeToContactRequest; +import com.intercom.api.resources.unstable.subscriptiontypes.types.SubscriptionType; +import com.intercom.api.resources.unstable.types.SubscriptionTypeList; + +public class SubscriptionTypesClient { + protected final ClientOptions clientOptions; + + private final RawSubscriptionTypesClient rawClient; + + public SubscriptionTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawSubscriptionTypesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSubscriptionTypesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public SubscriptionType attachSubscriptionTypeToContact(AttachSubscriptionTypeToContactRequest request) { + return this.rawClient.attachSubscriptionTypeToContact(request).body(); + } + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + *

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

+ *

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

+ *

This will return a subscription type model for the subscription type that was added to the contact.

+ */ + public SubscriptionType attachSubscriptionTypeToContact( + AttachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + return this.rawClient + .attachSubscriptionTypeToContact(request, requestOptions) + .body(); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public SubscriptionType detachSubscriptionTypeToContact(DetachSubscriptionTypeToContactRequest request) { + return this.rawClient.detachSubscriptionTypeToContact(request).body(); + } + + /** + * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. + */ + public SubscriptionType detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest request, RequestOptions requestOptions) { + return this.rawClient + .detachSubscriptionTypeToContact(request, requestOptions) + .body(); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public SubscriptionTypeList listSubscriptionTypes() { + return this.rawClient.listSubscriptionTypes().body(); + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + */ + public SubscriptionTypeList listSubscriptionTypes(RequestOptions requestOptions) { + return this.rawClient.listSubscriptionTypes(requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/requests/AttachSubscriptionTypeToContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/requests/AttachSubscriptionTypeToContactRequest.java new file mode 100644 index 0000000..2ed7eda --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/requests/AttachSubscriptionTypeToContactRequest.java @@ -0,0 +1,178 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.subscriptiontypes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AttachSubscriptionTypeToContactRequest.Builder.class) +public final class AttachSubscriptionTypeToContactRequest { + private final String contactId; + + private final String id; + + private final String consentType; + + private final Map additionalProperties; + + private AttachSubscriptionTypeToContactRequest( + String contactId, String id, String consentType, Map additionalProperties) { + this.contactId = contactId; + this.id = id; + this.consentType = consentType; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the subscription which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The consent_type of a subscription, opt_out or opt_in. + */ + @JsonProperty("consent_type") + public String getConsentType() { + return consentType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachSubscriptionTypeToContactRequest + && equalTo((AttachSubscriptionTypeToContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachSubscriptionTypeToContactRequest other) { + return contactId.equals(other.contactId) && id.equals(other.id) && consentType.equals(other.consentType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.id, this.consentType); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + IdStage contactId(@NotNull String contactId); + + Builder from(AttachSubscriptionTypeToContactRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the subscription which is given by Intercom + */ + ConsentTypeStage id(@NotNull String id); + } + + public interface ConsentTypeStage { + /** + * The consent_type of a subscription, opt_out or opt_in. + */ + _FinalStage consentType(@NotNull String consentType); + } + + public interface _FinalStage { + AttachSubscriptionTypeToContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, IdStage, ConsentTypeStage, _FinalStage { + private String contactId; + + private String id; + + private String consentType; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachSubscriptionTypeToContactRequest other) { + contactId(other.getContactId()); + id(other.getId()); + consentType(other.getConsentType()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public IdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + * The unique identifier for the subscription which is given by Intercom

The unique identifier for the subscription which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public ConsentTypeStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The consent_type of a subscription, opt_out or opt_in.

The consent_type of a subscription, opt_out or opt_in.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("consent_type") + public _FinalStage consentType(@NotNull String consentType) { + this.consentType = Objects.requireNonNull(consentType, "consentType must not be null"); + return this; + } + + @java.lang.Override + public AttachSubscriptionTypeToContactRequest build() { + return new AttachSubscriptionTypeToContactRequest(contactId, id, consentType, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/requests/DetachSubscriptionTypeToContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/requests/DetachSubscriptionTypeToContactRequest.java new file mode 100644 index 0000000..5d273cb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/requests/DetachSubscriptionTypeToContactRequest.java @@ -0,0 +1,146 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.subscriptiontypes.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetachSubscriptionTypeToContactRequest.Builder.class) +public final class DetachSubscriptionTypeToContactRequest { + private final String contactId; + + private final String id; + + private final Map additionalProperties; + + private DetachSubscriptionTypeToContactRequest( + String contactId, String id, Map additionalProperties) { + this.contactId = contactId; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the subscription type which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachSubscriptionTypeToContactRequest + && equalTo((DetachSubscriptionTypeToContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachSubscriptionTypeToContactRequest other) { + return contactId.equals(other.contactId) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + IdStage contactId(@NotNull String contactId); + + Builder from(DetachSubscriptionTypeToContactRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the subscription type which is given by Intercom + */ + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + DetachSubscriptionTypeToContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, IdStage, _FinalStage { + private String contactId; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachSubscriptionTypeToContactRequest other) { + contactId(other.getContactId()); + id(other.getId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public IdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + * The unique identifier for the subscription type which is given by Intercom

The unique identifier for the subscription type which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DetachSubscriptionTypeToContactRequest build() { + return new DetachSubscriptionTypeToContactRequest(contactId, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/types/SubscriptionType.java b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/types/SubscriptionType.java new file mode 100644 index 0000000..0f6e7ad --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/subscriptiontypes/types/SubscriptionType.java @@ -0,0 +1,526 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.subscriptiontypes.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.Translation; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SubscriptionType.Builder.class) +public final class SubscriptionType { + private final Optional type; + + private final Optional id; + + private final Optional state; + + private final Optional defaultTranslation; + + private final Optional> translations; + + private final Optional consentType; + + private final Optional> contentTypes; + + private final Map additionalProperties; + + private SubscriptionType( + Optional type, + Optional id, + Optional state, + Optional defaultTranslation, + Optional> translations, + Optional consentType, + Optional> contentTypes, + Map additionalProperties) { + this.type = type; + this.id = id; + this.state = state; + this.defaultTranslation = defaultTranslation; + this.translations = translations; + this.consentType = consentType; + this.contentTypes = contentTypes; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object - subscription + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier representing the subscription type. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The state of the subscription type. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + @JsonProperty("default_translation") + public Optional getDefaultTranslation() { + return defaultTranslation; + } + + /** + * @return An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. + */ + @JsonProperty("translations") + public Optional> getTranslations() { + return translations; + } + + /** + * @return Describes the type of consent. + */ + @JsonProperty("consent_type") + public Optional getConsentType() { + return consentType; + } + + /** + * @return The message types that this subscription supports - can contain email or sms_message. + */ + @JsonProperty("content_types") + public Optional> getContentTypes() { + return contentTypes; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SubscriptionType && equalTo((SubscriptionType) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(SubscriptionType other) { + return type.equals(other.type) + && id.equals(other.id) + && state.equals(other.state) + && defaultTranslation.equals(other.defaultTranslation) + && translations.equals(other.translations) + && consentType.equals(other.consentType) + && contentTypes.equals(other.contentTypes); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.state, + this.defaultTranslation, + this.translations, + this.consentType, + this.contentTypes); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional defaultTranslation = Optional.empty(); + + private Optional> translations = Optional.empty(); + + private Optional consentType = Optional.empty(); + + private Optional> contentTypes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SubscriptionType other) { + type(other.getType()); + id(other.getId()); + state(other.getState()); + defaultTranslation(other.getDefaultTranslation()); + translations(other.getTranslations()); + consentType(other.getConsentType()); + contentTypes(other.getContentTypes()); + return this; + } + + /** + *

The type of the object - subscription

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier representing the subscription type.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The state of the subscription type.

+ */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(State state) { + this.state = Optional.ofNullable(state); + return this; + } + + @JsonSetter(value = "default_translation", nulls = Nulls.SKIP) + public Builder defaultTranslation(Optional defaultTranslation) { + this.defaultTranslation = defaultTranslation; + return this; + } + + public Builder defaultTranslation(Translation defaultTranslation) { + this.defaultTranslation = Optional.ofNullable(defaultTranslation); + return this; + } + + /** + *

An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

+ */ + @JsonSetter(value = "translations", nulls = Nulls.SKIP) + public Builder translations(Optional> translations) { + this.translations = translations; + return this; + } + + public Builder translations(List translations) { + this.translations = Optional.ofNullable(translations); + return this; + } + + /** + *

Describes the type of consent.

+ */ + @JsonSetter(value = "consent_type", nulls = Nulls.SKIP) + public Builder consentType(Optional consentType) { + this.consentType = consentType; + return this; + } + + public Builder consentType(ConsentType consentType) { + this.consentType = Optional.ofNullable(consentType); + return this; + } + + /** + *

The message types that this subscription supports - can contain email or sms_message.

+ */ + @JsonSetter(value = "content_types", nulls = Nulls.SKIP) + public Builder contentTypes(Optional> contentTypes) { + this.contentTypes = contentTypes; + return this; + } + + public Builder contentTypes(List contentTypes) { + this.contentTypes = Optional.ofNullable(contentTypes); + return this; + } + + public SubscriptionType build() { + return new SubscriptionType( + type, id, state, defaultTranslation, translations, consentType, contentTypes, additionalProperties); + } + } + + public static final class ConsentType { + public static final ConsentType OPT_IN = new ConsentType(Value.OPT_IN, "opt_in"); + + public static final ConsentType OPT_OUT = new ConsentType(Value.OPT_OUT, "opt_out"); + + private final Value value; + + private final String string; + + ConsentType(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ConsentType && this.string.equals(((ConsentType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case OPT_IN: + return visitor.visitOptIn(); + case OPT_OUT: + return visitor.visitOptOut(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ConsentType valueOf(String value) { + switch (value) { + case "opt_in": + return OPT_IN; + case "opt_out": + return OPT_OUT; + default: + return new ConsentType(Value.UNKNOWN, value); + } + } + + public enum Value { + OPT_OUT, + + OPT_IN, + + UNKNOWN + } + + public interface Visitor { + T visitOptOut(); + + T visitOptIn(); + + T visitUnknown(String unknownType); + } + } + + public static final class ContentTypesItem { + public static final ContentTypesItem EMAIL = new ContentTypesItem(Value.EMAIL, "email"); + + public static final ContentTypesItem SMS_MESSAGE = new ContentTypesItem(Value.SMS_MESSAGE, "sms_message"); + + private final Value value; + + private final String string; + + ContentTypesItem(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ContentTypesItem && this.string.equals(((ContentTypesItem) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case EMAIL: + return visitor.visitEmail(); + case SMS_MESSAGE: + return visitor.visitSmsMessage(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ContentTypesItem valueOf(String value) { + switch (value) { + case "email": + return EMAIL; + case "sms_message": + return SMS_MESSAGE; + default: + return new ContentTypesItem(Value.UNKNOWN, value); + } + } + + public enum Value { + EMAIL, + + SMS_MESSAGE, + + UNKNOWN + } + + public interface Visitor { + T visitEmail(); + + T visitSmsMessage(); + + T visitUnknown(String unknownType); + } + } + + public static final class State { + public static final State LIVE = new State(Value.LIVE, "live"); + + public static final State ARCHIVED = new State(Value.ARCHIVED, "archived"); + + public static final State DRAFT = new State(Value.DRAFT, "draft"); + + private final Value value; + + private final String string; + + State(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof State && this.string.equals(((State) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case LIVE: + return visitor.visitLive(); + case ARCHIVED: + return visitor.visitArchived(); + case DRAFT: + return visitor.visitDraft(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static State valueOf(String value) { + switch (value) { + case "live": + return LIVE; + case "archived": + return ARCHIVED; + case "draft": + return DRAFT; + default: + return new State(Value.UNKNOWN, value); + } + } + + public enum Value { + LIVE, + + DRAFT, + + ARCHIVED, + + UNKNOWN + } + + public interface Visitor { + T visitLive(); + + T visitDraft(); + + T visitArchived(); + + T visitUnknown(String unknownType); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/switch_/AsyncRawSwitchClient.java b/src/main/java/com/intercom/api/resources/unstable/switch_/AsyncRawSwitchClient.java new file mode 100644 index 0000000..23fdd0a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/switch_/AsyncRawSwitchClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.switch_; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.PhoneSwitch; +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSwitchClient { + protected final ClientOptions clientOptions; + + public AsyncRawSwitchClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public CompletableFuture>> createPhoneSwitch(Object request) { + return createPhoneSwitch(request, null); + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public CompletableFuture>> createPhoneSwitch( + Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("phone_call_redirects") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 422: + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/switch_/AsyncSwitchClient.java b/src/main/java/com/intercom/api/resources/unstable/switch_/AsyncSwitchClient.java new file mode 100644 index 0000000..9109bfb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/switch_/AsyncSwitchClient.java @@ -0,0 +1,46 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.switch_; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.types.PhoneSwitch; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncSwitchClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSwitchClient rawClient; + + public AsyncSwitchClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSwitchClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSwitchClient withRawResponse() { + return this.rawClient; + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public CompletableFuture> createPhoneSwitch(Object request) { + return this.rawClient.createPhoneSwitch(request).thenApply(response -> response.body()); + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public CompletableFuture> createPhoneSwitch(Object request, RequestOptions requestOptions) { + return this.rawClient.createPhoneSwitch(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/switch_/RawSwitchClient.java b/src/main/java/com/intercom/api/resources/unstable/switch_/RawSwitchClient.java new file mode 100644 index 0000000..c27f8f4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/switch_/RawSwitchClient.java @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.switch_; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.errors.UnprocessableEntityError; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.PhoneSwitch; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSwitchClient { + protected final ClientOptions clientOptions; + + public RawSwitchClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public IntercomHttpResponse> createPhoneSwitch(Object request) { + return createPhoneSwitch(request, null); + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public IntercomHttpResponse> createPhoneSwitch( + Object request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("phone_call_redirects") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 422: + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/switch_/SwitchClient.java b/src/main/java/com/intercom/api/resources/unstable/switch_/SwitchClient.java new file mode 100644 index 0000000..337a6fb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/switch_/SwitchClient.java @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.switch_; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.types.PhoneSwitch; +import java.util.Optional; + +public class SwitchClient { + protected final ClientOptions clientOptions; + + private final RawSwitchClient rawClient; + + public SwitchClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawSwitchClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSwitchClient withRawResponse() { + return this.rawClient; + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public Optional createPhoneSwitch(Object request) { + return this.rawClient.createPhoneSwitch(request).body(); + } + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + *

If custom attributes are specified, they will be added to the user or lead's custom data attributes.

+ */ + public Optional createPhoneSwitch(Object request, RequestOptions requestOptions) { + return this.rawClient.createPhoneSwitch(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/AsyncRawTagsClient.java b/src/main/java/com/intercom/api/resources/unstable/tags/AsyncRawTagsClient.java new file mode 100644 index 0000000..1b4cf9a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/AsyncRawTagsClient.java @@ -0,0 +1,852 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToContactRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.DeleteTagRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromContactRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.FindTagRequest; +import com.intercom.api.resources.unstable.tags.types.CreateTagRequestBody; +import com.intercom.api.resources.unstable.tags.types.Tag; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.TagList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTagsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public CompletableFuture> attachTagToContact(AttachTagToContactRequest request) { + return attachTagToContact(request, null); + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public CompletableFuture> attachTagToContact( + AttachTagToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public CompletableFuture> detachTagFromContact(DetachTagFromContactRequest request) { + return detachTagFromContact(request, null); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public CompletableFuture> detachTagFromContact( + DetachTagFromContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public CompletableFuture> attachTagToConversation( + AttachTagToConversationRequest request) { + return attachTagToConversation(request, null); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public CompletableFuture> attachTagToConversation( + AttachTagToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public CompletableFuture> detachTagFromConversation( + DetachTagFromConversationRequest request) { + return detachTagFromConversation(request, null); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public CompletableFuture> detachTagFromConversation( + DetachTagFromConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public CompletableFuture> listTags() { + return listTags(null); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public CompletableFuture> listTags(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), TagList.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public CompletableFuture> createTag(CreateTagRequestBody request) { + return createTag(request, null); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public CompletableFuture> createTag( + CreateTagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public CompletableFuture> findTag(FindTagRequest request) { + return findTag(request, null); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public CompletableFuture> findTag(FindTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public CompletableFuture> deleteTag(DeleteTagRequest request) { + return deleteTag(request, null); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public CompletableFuture> deleteTag( + DeleteTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public CompletableFuture> attachTagToTicket(AttachTagToTicketRequest request) { + return attachTagToTicket(request, null); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public CompletableFuture> attachTagToTicket( + AttachTagToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public CompletableFuture> detachTagFromTicket(DetachTagFromTicketRequest request) { + return detachTagFromTicket(request, null); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public CompletableFuture> detachTagFromTicket( + DetachTagFromTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/AsyncTagsClient.java b/src/main/java/com/intercom/api/resources/unstable/tags/AsyncTagsClient.java new file mode 100644 index 0000000..492107a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/AsyncTagsClient.java @@ -0,0 +1,195 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToContactRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.DeleteTagRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromContactRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.FindTagRequest; +import com.intercom.api.resources.unstable.tags.types.CreateTagRequestBody; +import com.intercom.api.resources.unstable.tags.types.Tag; +import com.intercom.api.resources.unstable.types.TagList; +import java.util.concurrent.CompletableFuture; + +public class AsyncTagsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTagsClient rawClient; + + public AsyncTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTagsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTagsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public CompletableFuture attachTagToContact(AttachTagToContactRequest request) { + return this.rawClient.attachTagToContact(request).thenApply(response -> response.body()); + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public CompletableFuture attachTagToContact(AttachTagToContactRequest request, RequestOptions requestOptions) { + return this.rawClient.attachTagToContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public CompletableFuture detachTagFromContact(DetachTagFromContactRequest request) { + return this.rawClient.detachTagFromContact(request).thenApply(response -> response.body()); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public CompletableFuture detachTagFromContact( + DetachTagFromContactRequest request, RequestOptions requestOptions) { + return this.rawClient.detachTagFromContact(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public CompletableFuture attachTagToConversation(AttachTagToConversationRequest request) { + return this.rawClient.attachTagToConversation(request).thenApply(response -> response.body()); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public CompletableFuture attachTagToConversation( + AttachTagToConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.attachTagToConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public CompletableFuture detachTagFromConversation(DetachTagFromConversationRequest request) { + return this.rawClient.detachTagFromConversation(request).thenApply(response -> response.body()); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public CompletableFuture detachTagFromConversation( + DetachTagFromConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.detachTagFromConversation(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public CompletableFuture listTags() { + return this.rawClient.listTags().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public CompletableFuture listTags(RequestOptions requestOptions) { + return this.rawClient.listTags(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public CompletableFuture createTag(CreateTagRequestBody request) { + return this.rawClient.createTag(request).thenApply(response -> response.body()); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public CompletableFuture createTag(CreateTagRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createTag(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public CompletableFuture findTag(FindTagRequest request) { + return this.rawClient.findTag(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public CompletableFuture findTag(FindTagRequest request, RequestOptions requestOptions) { + return this.rawClient.findTag(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public CompletableFuture deleteTag(DeleteTagRequest request) { + return this.rawClient.deleteTag(request).thenApply(response -> response.body()); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public CompletableFuture deleteTag(DeleteTagRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteTag(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public CompletableFuture attachTagToTicket(AttachTagToTicketRequest request) { + return this.rawClient.attachTagToTicket(request).thenApply(response -> response.body()); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public CompletableFuture attachTagToTicket(AttachTagToTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.attachTagToTicket(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public CompletableFuture detachTagFromTicket(DetachTagFromTicketRequest request) { + return this.rawClient.detachTagFromTicket(request).thenApply(response -> response.body()); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public CompletableFuture detachTagFromTicket( + DetachTagFromTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.detachTagFromTicket(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/RawTagsClient.java b/src/main/java/com/intercom/api/resources/unstable/tags/RawTagsClient.java new file mode 100644 index 0000000..700c5d3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/RawTagsClient.java @@ -0,0 +1,673 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToContactRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.DeleteTagRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromContactRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.FindTagRequest; +import com.intercom.api.resources.unstable.tags.types.CreateTagRequestBody; +import com.intercom.api.resources.unstable.tags.types.Tag; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.TagList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTagsClient { + protected final ClientOptions clientOptions; + + public RawTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public IntercomHttpResponse attachTagToContact(AttachTagToContactRequest request) { + return attachTagToContact(request, null); + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public IntercomHttpResponse attachTagToContact( + AttachTagToContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public IntercomHttpResponse detachTagFromContact(DetachTagFromContactRequest request) { + return detachTagFromContact(request, null); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public IntercomHttpResponse detachTagFromContact( + DetachTagFromContactRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("contacts") + .addPathSegment(request.getContactId()) + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public IntercomHttpResponse attachTagToConversation(AttachTagToConversationRequest request) { + return attachTagToConversation(request, null); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public IntercomHttpResponse attachTagToConversation( + AttachTagToConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public IntercomHttpResponse detachTagFromConversation(DetachTagFromConversationRequest request) { + return detachTagFromConversation(request, null); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public IntercomHttpResponse detachTagFromConversation( + DetachTagFromConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public IntercomHttpResponse listTags() { + return listTags(null); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public IntercomHttpResponse listTags(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public IntercomHttpResponse createTag(CreateTagRequestBody request) { + return createTag(request, null); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public IntercomHttpResponse createTag(CreateTagRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public IntercomHttpResponse findTag(FindTagRequest request) { + return findTag(request, null); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public IntercomHttpResponse findTag(FindTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public IntercomHttpResponse deleteTag(DeleteTagRequest request) { + return deleteTag(request, null); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public IntercomHttpResponse deleteTag(DeleteTagRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public IntercomHttpResponse attachTagToTicket(AttachTagToTicketRequest request) { + return attachTagToTicket(request, null); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public IntercomHttpResponse attachTagToTicket( + AttachTagToTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public IntercomHttpResponse detachTagFromTicket(DetachTagFromTicketRequest request) { + return detachTagFromTicket(request, null); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public IntercomHttpResponse detachTagFromTicket( + DetachTagFromTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getTicketId()) + .addPathSegments("tags") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/TagsClient.java b/src/main/java/com/intercom/api/resources/unstable/tags/TagsClient.java new file mode 100644 index 0000000..2461fe0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/TagsClient.java @@ -0,0 +1,190 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToContactRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.AttachTagToTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.DeleteTagRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromContactRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromConversationRequest; +import com.intercom.api.resources.unstable.tags.requests.DetachTagFromTicketRequest; +import com.intercom.api.resources.unstable.tags.requests.FindTagRequest; +import com.intercom.api.resources.unstable.tags.types.CreateTagRequestBody; +import com.intercom.api.resources.unstable.tags.types.Tag; +import com.intercom.api.resources.unstable.types.TagList; + +public class TagsClient { + protected final ClientOptions clientOptions; + + private final RawTagsClient rawClient; + + public TagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawTagsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTagsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public Tag attachTagToContact(AttachTagToContactRequest request) { + return this.rawClient.attachTagToContact(request).body(); + } + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + */ + public Tag attachTagToContact(AttachTagToContactRequest request, RequestOptions requestOptions) { + return this.rawClient.attachTagToContact(request, requestOptions).body(); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public Tag detachTagFromContact(DetachTagFromContactRequest request) { + return this.rawClient.detachTagFromContact(request).body(); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + */ + public Tag detachTagFromContact(DetachTagFromContactRequest request, RequestOptions requestOptions) { + return this.rawClient.detachTagFromContact(request, requestOptions).body(); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public Tag attachTagToConversation(AttachTagToConversationRequest request) { + return this.rawClient.attachTagToConversation(request).body(); + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + */ + public Tag attachTagToConversation(AttachTagToConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.attachTagToConversation(request, requestOptions).body(); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public Tag detachTagFromConversation(DetachTagFromConversationRequest request) { + return this.rawClient.detachTagFromConversation(request).body(); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + */ + public Tag detachTagFromConversation(DetachTagFromConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.detachTagFromConversation(request, requestOptions).body(); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public TagList listTags() { + return this.rawClient.listTags().body(); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + public TagList listTags(RequestOptions requestOptions) { + return this.rawClient.listTags(requestOptions).body(); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public Tag createTag(CreateTagRequestBody request) { + return this.rawClient.createTag(request).body(); + } + + /** + * You can use this endpoint to perform the following operations: + *

1. Create a new tag: You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below.

+ *

2. Update an existing tag: You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below.

+ *

3. Tag Companies: You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically.

+ *

4. Untag Companies: You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below.

+ *

5. Tag Multiple Users: You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below.

+ *

Each operation will return a tag object.

+ */ + public Tag createTag(CreateTagRequestBody request, RequestOptions requestOptions) { + return this.rawClient.createTag(request, requestOptions).body(); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public Tag findTag(FindTagRequest request) { + return this.rawClient.findTag(request).body(); + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + */ + public Tag findTag(FindTagRequest request, RequestOptions requestOptions) { + return this.rawClient.findTag(request, requestOptions).body(); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public void deleteTag(DeleteTagRequest request) { + this.rawClient.deleteTag(request).body(); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + */ + public void deleteTag(DeleteTagRequest request, RequestOptions requestOptions) { + this.rawClient.deleteTag(request, requestOptions).body(); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public Tag attachTagToTicket(AttachTagToTicketRequest request) { + return this.rawClient.attachTagToTicket(request).body(); + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + */ + public Tag attachTagToTicket(AttachTagToTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.attachTagToTicket(request, requestOptions).body(); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public Tag detachTagFromTicket(DetachTagFromTicketRequest request) { + return this.rawClient.detachTagFromTicket(request).body(); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + */ + public Tag detachTagFromTicket(DetachTagFromTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.detachTagFromTicket(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToContactRequest.java new file mode 100644 index 0000000..1bdb0d6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToContactRequest.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AttachTagToContactRequest.Builder.class) +public final class AttachTagToContactRequest { + private final String contactId; + + private final String id; + + private final Map additionalProperties; + + private AttachTagToContactRequest(String contactId, String id, Map additionalProperties) { + this.contactId = contactId; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachTagToContactRequest && equalTo((AttachTagToContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachTagToContactRequest other) { + return contactId.equals(other.contactId) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + IdStage contactId(@NotNull String contactId); + + Builder from(AttachTagToContactRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + AttachTagToContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, IdStage, _FinalStage { + private String contactId; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachTagToContactRequest other) { + contactId(other.getContactId()); + id(other.getId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public IdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public AttachTagToContactRequest build() { + return new AttachTagToContactRequest(contactId, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToConversationRequest.java new file mode 100644 index 0000000..00d84d9 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToConversationRequest.java @@ -0,0 +1,177 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AttachTagToConversationRequest.Builder.class) +public final class AttachTagToConversationRequest { + private final String conversationId; + + private final String id; + + private final String adminId; + + private final Map additionalProperties; + + private AttachTagToConversationRequest( + String conversationId, String id, String adminId, Map additionalProperties) { + this.conversationId = conversationId; + this.id = id; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return conversation_id + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachTagToConversationRequest && equalTo((AttachTagToConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachTagToConversationRequest other) { + return conversationId.equals(other.conversationId) && id.equals(other.id) && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.id, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + /** + * conversation_id + */ + IdStage conversationId(@NotNull String conversationId); + + Builder from(AttachTagToConversationRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ + AdminIdStage id(@NotNull String id); + } + + public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + AttachTagToConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, IdStage, AdminIdStage, _FinalStage { + private String conversationId; + + private String id; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachTagToConversationRequest other) { + conversationId(other.getConversationId()); + id(other.getId()); + adminId(other.getAdminId()); + return this; + } + + /** + * conversation_id

conversation_id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("conversation_id") + public IdStage conversationId(@NotNull String conversationId) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + /** + * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public AdminIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public AttachTagToConversationRequest build() { + return new AttachTagToConversationRequest(conversationId, id, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToTicketRequest.java new file mode 100644 index 0000000..e124d52 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/AttachTagToTicketRequest.java @@ -0,0 +1,177 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AttachTagToTicketRequest.Builder.class) +public final class AttachTagToTicketRequest { + private final String ticketId; + + private final String id; + + private final String adminId; + + private final Map additionalProperties; + + private AttachTagToTicketRequest( + String ticketId, String id, String adminId, Map additionalProperties) { + this.ticketId = ticketId; + this.id = id; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return ticket_id + */ + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AttachTagToTicketRequest && equalTo((AttachTagToTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AttachTagToTicketRequest other) { + return ticketId.equals(other.ticketId) && id.equals(other.id) && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketId, this.id, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + /** + * ticket_id + */ + IdStage ticketId(@NotNull String ticketId); + + Builder from(AttachTagToTicketRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ + AdminIdStage id(@NotNull String id); + } + + public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + AttachTagToTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, IdStage, AdminIdStage, _FinalStage { + private String ticketId; + + private String id; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AttachTagToTicketRequest other) { + ticketId(other.getTicketId()); + id(other.getId()); + adminId(other.getAdminId()); + return this; + } + + /** + * ticket_id

ticket_id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ticket_id") + public IdStage ticketId(@NotNull String ticketId) { + this.ticketId = Objects.requireNonNull(ticketId, "ticketId must not be null"); + return this; + } + + /** + * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public AdminIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public AttachTagToTicketRequest build() { + return new AttachTagToTicketRequest(ticketId, id, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/DeleteTagRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DeleteTagRequest.java new file mode 100644 index 0000000..c41a101 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DeleteTagRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteTagRequest.Builder.class) +public final class DeleteTagRequest { + private final String id; + + private final Map additionalProperties; + + private DeleteTagRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given tag + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTagRequest && equalTo((DeleteTagRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTagRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a given tag + */ + _FinalStage id(@NotNull String id); + + Builder from(DeleteTagRequest other); + } + + public interface _FinalStage { + DeleteTagRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteTagRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier of a given tag

The unique identifier of a given tag

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DeleteTagRequest build() { + return new DeleteTagRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromContactRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromContactRequest.java new file mode 100644 index 0000000..7c76057 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromContactRequest.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetachTagFromContactRequest.Builder.class) +public final class DetachTagFromContactRequest { + private final String contactId; + + private final String id; + + private final Map additionalProperties; + + private DetachTagFromContactRequest(String contactId, String id, Map additionalProperties) { + this.contactId = contactId; + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the contact which is given by Intercom + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachTagFromContactRequest && equalTo((DetachTagFromContactRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachTagFromContactRequest other) { + return contactId.equals(other.contactId) && id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.contactId, this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ContactIdStage builder() { + return new Builder(); + } + + public interface ContactIdStage { + /** + * The unique identifier for the contact which is given by Intercom + */ + IdStage contactId(@NotNull String contactId); + + Builder from(DetachTagFromContactRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ + _FinalStage id(@NotNull String id); + } + + public interface _FinalStage { + DetachTagFromContactRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ContactIdStage, IdStage, _FinalStage { + private String contactId; + + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachTagFromContactRequest other) { + contactId(other.getContactId()); + id(other.getId()); + return this; + } + + /** + * The unique identifier for the contact which is given by Intercom

The unique identifier for the contact which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("contact_id") + public IdStage contactId(@NotNull String contactId) { + this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + return this; + } + + /** + * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DetachTagFromContactRequest build() { + return new DetachTagFromContactRequest(contactId, id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromConversationRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromConversationRequest.java new file mode 100644 index 0000000..a090669 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromConversationRequest.java @@ -0,0 +1,177 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetachTagFromConversationRequest.Builder.class) +public final class DetachTagFromConversationRequest { + private final String conversationId; + + private final String id; + + private final String adminId; + + private final Map additionalProperties; + + private DetachTagFromConversationRequest( + String conversationId, String id, String adminId, Map additionalProperties) { + this.conversationId = conversationId; + this.id = id; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return conversation_id + */ + @JsonProperty("conversation_id") + public String getConversationId() { + return conversationId; + } + + /** + * @return id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachTagFromConversationRequest && equalTo((DetachTagFromConversationRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachTagFromConversationRequest other) { + return conversationId.equals(other.conversationId) && id.equals(other.id) && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId, this.id, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + /** + * conversation_id + */ + IdStage conversationId(@NotNull String conversationId); + + Builder from(DetachTagFromConversationRequest other); + } + + public interface IdStage { + /** + * id + */ + AdminIdStage id(@NotNull String id); + } + + public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + DetachTagFromConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, IdStage, AdminIdStage, _FinalStage { + private String conversationId; + + private String id; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachTagFromConversationRequest other) { + conversationId(other.getConversationId()); + id(other.getId()); + adminId(other.getAdminId()); + return this; + } + + /** + * conversation_id

conversation_id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("conversation_id") + public IdStage conversationId(@NotNull String conversationId) { + this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + return this; + } + + /** + * id

id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public AdminIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public DetachTagFromConversationRequest build() { + return new DetachTagFromConversationRequest(conversationId, id, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromTicketRequest.java new file mode 100644 index 0000000..3414783 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/DetachTagFromTicketRequest.java @@ -0,0 +1,177 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DetachTagFromTicketRequest.Builder.class) +public final class DetachTagFromTicketRequest { + private final String ticketId; + + private final String id; + + private final String adminId; + + private final Map additionalProperties; + + private DetachTagFromTicketRequest( + String ticketId, String id, String adminId, Map additionalProperties) { + this.ticketId = ticketId; + this.id = id; + this.adminId = adminId; + this.additionalProperties = additionalProperties; + } + + /** + * @return ticket_id + */ + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + /** + * @return The unique identifier for the tag which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The unique identifier for the admin which is given by Intercom. + */ + @JsonProperty("admin_id") + public String getAdminId() { + return adminId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DetachTagFromTicketRequest && equalTo((DetachTagFromTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DetachTagFromTicketRequest other) { + return ticketId.equals(other.ticketId) && id.equals(other.id) && adminId.equals(other.adminId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketId, this.id, this.adminId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + /** + * ticket_id + */ + IdStage ticketId(@NotNull String ticketId); + + Builder from(DetachTagFromTicketRequest other); + } + + public interface IdStage { + /** + * The unique identifier for the tag which is given by Intercom + */ + AdminIdStage id(@NotNull String id); + } + + public interface AdminIdStage { + /** + * The unique identifier for the admin which is given by Intercom. + */ + _FinalStage adminId(@NotNull String adminId); + } + + public interface _FinalStage { + DetachTagFromTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, IdStage, AdminIdStage, _FinalStage { + private String ticketId; + + private String id; + + private String adminId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DetachTagFromTicketRequest other) { + ticketId(other.getTicketId()); + id(other.getId()); + adminId(other.getAdminId()); + return this; + } + + /** + * ticket_id

ticket_id

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ticket_id") + public IdStage ticketId(@NotNull String ticketId) { + this.ticketId = Objects.requireNonNull(ticketId, "ticketId must not be null"); + return this; + } + + /** + * The unique identifier for the tag which is given by Intercom

The unique identifier for the tag which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public AdminIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + * The unique identifier for the admin which is given by Intercom.

The unique identifier for the admin which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("admin_id") + public _FinalStage adminId(@NotNull String adminId) { + this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + return this; + } + + @java.lang.Override + public DetachTagFromTicketRequest build() { + return new DetachTagFromTicketRequest(ticketId, id, adminId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/requests/FindTagRequest.java b/src/main/java/com/intercom/api/resources/unstable/tags/requests/FindTagRequest.java new file mode 100644 index 0000000..3bce1db --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/requests/FindTagRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = FindTagRequest.Builder.class) +public final class FindTagRequest { + private final String id; + + private final Map additionalProperties; + + private FindTagRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given tag + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FindTagRequest && equalTo((FindTagRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FindTagRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a given tag + */ + _FinalStage id(@NotNull String id); + + Builder from(FindTagRequest other); + } + + public interface _FinalStage { + FindTagRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(FindTagRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier of a given tag

The unique identifier of a given tag

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public FindTagRequest build() { + return new FindTagRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/types/CreateTagRequestBody.java b/src/main/java/com/intercom/api/resources/unstable/tags/types/CreateTagRequestBody.java new file mode 100644 index 0000000..b4b42fc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/types/CreateTagRequestBody.java @@ -0,0 +1,123 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +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.resources.unstable.types.CreateOrUpdateTagRequest; +import com.intercom.api.resources.unstable.types.TagCompanyRequest; +import com.intercom.api.resources.unstable.types.TagMultipleUsersRequest; +import com.intercom.api.resources.unstable.types.UntagCompanyRequest; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = CreateTagRequestBody.Deserializer.class) +public final class CreateTagRequestBody { + private final Object value; + + private final int type; + + private CreateTagRequestBody(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((CreateOrUpdateTagRequest) this.value); + } else if (this.type == 1) { + return visitor.visit((TagCompanyRequest) this.value); + } else if (this.type == 2) { + return visitor.visit((UntagCompanyRequest) this.value); + } else if (this.type == 3) { + return visitor.visit((TagMultipleUsersRequest) 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 CreateTagRequestBody && equalTo((CreateTagRequestBody) other); + } + + private boolean equalTo(CreateTagRequestBody 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 CreateTagRequestBody of(CreateOrUpdateTagRequest value) { + return new CreateTagRequestBody(value, 0); + } + + public static CreateTagRequestBody of(TagCompanyRequest value) { + return new CreateTagRequestBody(value, 1); + } + + public static CreateTagRequestBody of(UntagCompanyRequest value) { + return new CreateTagRequestBody(value, 2); + } + + public static CreateTagRequestBody of(TagMultipleUsersRequest value) { + return new CreateTagRequestBody(value, 3); + } + + public interface Visitor { + T visit(CreateOrUpdateTagRequest value); + + T visit(TagCompanyRequest value); + + T visit(UntagCompanyRequest value); + + T visit(TagMultipleUsersRequest value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(CreateTagRequestBody.class); + } + + @java.lang.Override + public CreateTagRequestBody deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CreateOrUpdateTagRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TagCompanyRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, UntagCompanyRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TagMultipleUsersRequest.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/types/Tag.java b/src/main/java/com/intercom/api/resources/unstable/tags/types/Tag.java new file mode 100644 index 0000000..d94bcec --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/types/Tag.java @@ -0,0 +1,218 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.Reference; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Tag.Builder.class) +public final class Tag { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Optional appliedAt; + + private final Optional appliedBy; + + private final Map additionalProperties; + + private Tag( + Optional type, + Optional id, + Optional name, + Optional appliedAt, + Optional appliedBy, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.appliedAt = appliedAt; + this.appliedBy = appliedBy; + this.additionalProperties = additionalProperties; + } + + /** + * @return value is "tag" + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the tag + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the tag + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The time when the tag was applied to the object + */ + @JsonProperty("applied_at") + public Optional getAppliedAt() { + return appliedAt; + } + + @JsonProperty("applied_by") + public Optional getAppliedBy() { + return appliedBy; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Tag && equalTo((Tag) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Tag other) { + return type.equals(other.type) + && id.equals(other.id) + && name.equals(other.name) + && appliedAt.equals(other.appliedAt) + && appliedBy.equals(other.appliedBy); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.name, this.appliedAt, this.appliedBy); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional appliedAt = Optional.empty(); + + private Optional appliedBy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Tag other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + appliedAt(other.getAppliedAt()); + appliedBy(other.getAppliedBy()); + return this; + } + + /** + *

value is "tag"

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the tag

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the tag

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The time when the tag was applied to the object

+ */ + @JsonSetter(value = "applied_at", nulls = Nulls.SKIP) + public Builder appliedAt(Optional appliedAt) { + this.appliedAt = appliedAt; + return this; + } + + public Builder appliedAt(Integer appliedAt) { + this.appliedAt = Optional.ofNullable(appliedAt); + return this; + } + + @JsonSetter(value = "applied_by", nulls = Nulls.SKIP) + public Builder appliedBy(Optional appliedBy) { + this.appliedBy = appliedBy; + return this; + } + + public Builder appliedBy(Reference appliedBy) { + this.appliedBy = Optional.ofNullable(appliedBy); + return this; + } + + public Tag build() { + return new Tag(type, id, name, appliedAt, appliedBy, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tags/types/TagBasic.java b/src/main/java/com/intercom/api/resources/unstable/tags/types/TagBasic.java new file mode 100644 index 0000000..75147b5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tags/types/TagBasic.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tags.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TagBasic.Builder.class) +public final class TagBasic { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Map additionalProperties; + + private TagBasic( + Optional type, + Optional id, + Optional name, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.additionalProperties = additionalProperties; + } + + /** + * @return value is "tag" + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the tag + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the tag + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TagBasic && equalTo((TagBasic) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TagBasic other) { + return type.equals(other.type) && id.equals(other.id) && name.equals(other.name); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.name); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TagBasic other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + return this; + } + + /** + *

value is "tag"

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the tag

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the tag

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + public TagBasic build() { + return new TagBasic(type, id, name, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/teams/AsyncRawTeamsClient.java b/src/main/java/com/intercom/api/resources/unstable/teams/AsyncRawTeamsClient.java new file mode 100644 index 0000000..d6ee083 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/teams/AsyncRawTeamsClient.java @@ -0,0 +1,176 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.teams; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.teams.requests.RetrieveTeamRequest; +import com.intercom.api.resources.unstable.teams.types.Team; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.TeamList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTeamsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * This will return a list of team objects for the App. + */ + public CompletableFuture> listTeams() { + return listTeams(null); + } + + /** + * This will return a list of team objects for the App. + */ + public CompletableFuture> listTeams(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), TeamList.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public CompletableFuture> retrieveTeam(RetrieveTeamRequest request) { + return retrieveTeam(request, null); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public CompletableFuture> retrieveTeam( + RetrieveTeamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Team.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/teams/AsyncTeamsClient.java b/src/main/java/com/intercom/api/resources/unstable/teams/AsyncTeamsClient.java new file mode 100644 index 0000000..aed73c3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/teams/AsyncTeamsClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.teams; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.teams.requests.RetrieveTeamRequest; +import com.intercom.api.resources.unstable.teams.types.Team; +import com.intercom.api.resources.unstable.types.TeamList; +import java.util.concurrent.CompletableFuture; + +public class AsyncTeamsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTeamsClient rawClient; + + public AsyncTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTeamsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTeamsClient withRawResponse() { + return this.rawClient; + } + + /** + * This will return a list of team objects for the App. + */ + public CompletableFuture listTeams() { + return this.rawClient.listTeams().thenApply(response -> response.body()); + } + + /** + * This will return a list of team objects for the App. + */ + public CompletableFuture listTeams(RequestOptions requestOptions) { + return this.rawClient.listTeams(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public CompletableFuture retrieveTeam(RetrieveTeamRequest request) { + return this.rawClient.retrieveTeam(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public CompletableFuture retrieveTeam(RetrieveTeamRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveTeam(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/teams/RawTeamsClient.java b/src/main/java/com/intercom/api/resources/unstable/teams/RawTeamsClient.java new file mode 100644 index 0000000..8bfdc58 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/teams/RawTeamsClient.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.teams; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.teams.requests.RetrieveTeamRequest; +import com.intercom.api.resources.unstable.teams.types.Team; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.TeamList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTeamsClient { + protected final ClientOptions clientOptions; + + public RawTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * This will return a list of team objects for the App. + */ + public IntercomHttpResponse listTeams() { + return listTeams(null); + } + + /** + * This will return a list of team objects for the App. + */ + public IntercomHttpResponse listTeams(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TeamList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public IntercomHttpResponse retrieveTeam(RetrieveTeamRequest request) { + return retrieveTeam(request, null); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public IntercomHttpResponse retrieveTeam(RetrieveTeamRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("teams") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/teams/TeamsClient.java b/src/main/java/com/intercom/api/resources/unstable/teams/TeamsClient.java new file mode 100644 index 0000000..f75dbb0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/teams/TeamsClient.java @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.teams; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.teams.requests.RetrieveTeamRequest; +import com.intercom.api.resources.unstable.teams.types.Team; +import com.intercom.api.resources.unstable.types.TeamList; + +public class TeamsClient { + protected final ClientOptions clientOptions; + + private final RawTeamsClient rawClient; + + public TeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawTeamsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTeamsClient withRawResponse() { + return this.rawClient; + } + + /** + * This will return a list of team objects for the App. + */ + public TeamList listTeams() { + return this.rawClient.listTeams().body(); + } + + /** + * This will return a list of team objects for the App. + */ + public TeamList listTeams(RequestOptions requestOptions) { + return this.rawClient.listTeams(requestOptions).body(); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public Team retrieveTeam(RetrieveTeamRequest request) { + return this.rawClient.retrieveTeam(request).body(); + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + */ + public Team retrieveTeam(RetrieveTeamRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveTeam(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/teams/requests/RetrieveTeamRequest.java b/src/main/java/com/intercom/api/resources/unstable/teams/requests/RetrieveTeamRequest.java new file mode 100644 index 0000000..8ededb7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/teams/requests/RetrieveTeamRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.teams.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = RetrieveTeamRequest.Builder.class) +public final class RetrieveTeamRequest { + private final String id; + + private final Map additionalProperties; + + private RetrieveTeamRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier of a given team. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveTeamRequest && equalTo((RetrieveTeamRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveTeamRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier of a given team. + */ + _FinalStage id(@NotNull String id); + + Builder from(RetrieveTeamRequest other); + } + + public interface _FinalStage { + RetrieveTeamRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveTeamRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier of a given team.

The unique identifier of a given team.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public RetrieveTeamRequest build() { + return new RetrieveTeamRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/teams/types/Team.java b/src/main/java/com/intercom/api/resources/unstable/teams/types/Team.java new file mode 100644 index 0000000..076ff0d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/teams/types/Team.java @@ -0,0 +1,219 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.teams.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.AdminPriorityLevel; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Team.Builder.class) +public final class Team { + private final Optional type; + + private final Optional id; + + private final Optional name; + + private final Optional> adminIds; + + private final Optional adminPriorityLevel; + + private final Map additionalProperties; + + private Team( + Optional type, + Optional id, + Optional name, + Optional> adminIds, + Optional adminPriorityLevel, + Map additionalProperties) { + this.type = type; + this.id = id; + this.name = name; + this.adminIds = adminIds; + this.adminPriorityLevel = adminPriorityLevel; + this.additionalProperties = additionalProperties; + } + + /** + * @return Value is always "team" + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the team + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The name of the team + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + + /** + * @return The list of admin IDs that are a part of the team. + */ + @JsonProperty("admin_ids") + public Optional> getAdminIds() { + return adminIds; + } + + @JsonProperty("admin_priority_level") + public Optional getAdminPriorityLevel() { + return adminPriorityLevel; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Team && equalTo((Team) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Team other) { + return type.equals(other.type) + && id.equals(other.id) + && name.equals(other.name) + && adminIds.equals(other.adminIds) + && adminPriorityLevel.equals(other.adminPriorityLevel); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.id, this.name, this.adminIds, this.adminPriorityLevel); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional> adminIds = Optional.empty(); + + private Optional adminPriorityLevel = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Team other) { + type(other.getType()); + id(other.getId()); + name(other.getName()); + adminIds(other.getAdminIds()); + adminPriorityLevel(other.getAdminPriorityLevel()); + return this; + } + + /** + *

Value is always "team"

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id of the team

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The name of the team

+ */ + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + /** + *

The list of admin IDs that are a part of the team.

+ */ + @JsonSetter(value = "admin_ids", nulls = Nulls.SKIP) + public Builder adminIds(Optional> adminIds) { + this.adminIds = adminIds; + return this; + } + + public Builder adminIds(List adminIds) { + this.adminIds = Optional.ofNullable(adminIds); + return this; + } + + @JsonSetter(value = "admin_priority_level", nulls = Nulls.SKIP) + public Builder adminPriorityLevel(Optional adminPriorityLevel) { + this.adminPriorityLevel = adminPriorityLevel; + return this; + } + + public Builder adminPriorityLevel(AdminPriorityLevel adminPriorityLevel) { + this.adminPriorityLevel = Optional.ofNullable(adminPriorityLevel); + return this; + } + + public Team build() { + return new Team(type, id, name, adminIds, adminPriorityLevel, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/AsyncRawTicketsClient.java b/src/main/java/com/intercom/api/resources/unstable/tickets/AsyncRawTicketsClient.java new file mode 100644 index 0000000..18b29f4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/AsyncRawTicketsClient.java @@ -0,0 +1,619 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.jobs.types.Jobs; +import com.intercom.api.resources.unstable.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.EnqueueCreateTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.GetTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.ReplyTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.unstable.tickets.types.DeleteTicketResponse; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.TicketList; +import com.intercom.api.resources.unstable.types.TicketReply; +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTicketsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture> replyTicket(ReplyTicketRequest request) { + return replyTicket(request, null); + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture> replyTicket( + ReplyTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), TicketReply.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public CompletableFuture> enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return enqueueCreateTicket(request, null); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public CompletableFuture> enqueueCreateTicket( + EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), Jobs.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can fetch the details of a single ticket. + */ + public CompletableFuture>> getTicket(GetTicketRequest request) { + return getTicket(request, null); + } + + /** + * You can fetch the details of a single ticket. + */ + public CompletableFuture>> getTicket( + GetTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can update a ticket. + */ + public CompletableFuture>> updateTicket(UpdateTicketRequest request) { + return updateTicket(request, null); + } + + /** + * You can update a ticket. + */ + public CompletableFuture>> updateTicket( + UpdateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + future.completeExceptionally(new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture> deleteTicket(DeleteTicketRequest request) { + return deleteTicket(request, null); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture> deleteTicket( + DeleteTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), DeleteTicketResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + future.completeExceptionally(new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), + response)); + return; + case 404: + future.completeExceptionally(new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> searchTickets(SearchRequest request) { + return searchTickets(request, null); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture> searchTickets( + SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + 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(), TicketList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/AsyncTicketsClient.java b/src/main/java/com/intercom/api/resources/unstable/tickets/AsyncTicketsClient.java new file mode 100644 index 0000000..8fbf27f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/AsyncTicketsClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.jobs.types.Jobs; +import com.intercom.api.resources.unstable.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.EnqueueCreateTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.GetTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.ReplyTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.unstable.tickets.types.DeleteTicketResponse; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.TicketList; +import com.intercom.api.resources.unstable.types.TicketReply; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncTicketsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTicketsClient rawClient; + + public AsyncTicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTicketsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTicketsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture replyTicket(ReplyTicketRequest request) { + return this.rawClient.replyTicket(request).thenApply(response -> response.body()); + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public CompletableFuture replyTicket(ReplyTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.replyTicket(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public CompletableFuture enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return this.rawClient.enqueueCreateTicket(request).thenApply(response -> response.body()); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public CompletableFuture enqueueCreateTicket( + EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.enqueueCreateTicket(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single ticket. + */ + public CompletableFuture> getTicket(GetTicketRequest request) { + return this.rawClient.getTicket(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single ticket. + */ + public CompletableFuture> getTicket(GetTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.getTicket(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update a ticket. + */ + public CompletableFuture> updateTicket(UpdateTicketRequest request) { + return this.rawClient.updateTicket(request).thenApply(response -> response.body()); + } + + /** + * You can update a ticket. + */ + public CompletableFuture> updateTicket( + UpdateTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.updateTicket(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture deleteTicket(DeleteTicketRequest request) { + return this.rawClient.deleteTicket(request).thenApply(response -> response.body()); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public CompletableFuture deleteTicket( + DeleteTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteTicket(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture searchTickets(SearchRequest request) { + return this.rawClient.searchTickets(request).thenApply(response -> response.body()); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public CompletableFuture searchTickets(SearchRequest request, RequestOptions requestOptions) { + return this.rawClient.searchTickets(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/RawTicketsClient.java b/src/main/java/com/intercom/api/resources/unstable/tickets/RawTicketsClient.java new file mode 100644 index 0000000..8651c8d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/RawTicketsClient.java @@ -0,0 +1,511 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.core.IntercomException; +import com.intercom.api.core.IntercomHttpResponse; +import com.intercom.api.core.MediaTypes; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.errors.BadRequestError; +import com.intercom.api.resources.unstable.errors.NotFoundError; +import com.intercom.api.resources.unstable.errors.UnauthorizedError; +import com.intercom.api.resources.unstable.jobs.types.Jobs; +import com.intercom.api.resources.unstable.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.EnqueueCreateTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.GetTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.ReplyTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.unstable.tickets.types.DeleteTicketResponse; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.Error; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.TicketList; +import com.intercom.api.resources.unstable.types.TicketReply; +import java.io.IOException; +import java.util.Optional; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTicketsClient { + protected final ClientOptions clientOptions; + + public RawTicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public IntercomHttpResponse replyTicket(ReplyTicketRequest request) { + return replyTicket(request, null); + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public IntercomHttpResponse replyTicket(ReplyTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .addPathSegments("reply") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketReply.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public IntercomHttpResponse enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return enqueueCreateTicket(request, null); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public IntercomHttpResponse enqueueCreateTicket( + EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/enqueue") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Jobs.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single ticket. + */ + public IntercomHttpResponse> getTicket(GetTicketRequest request) { + return getTicket(request, null); + } + + /** + * You can fetch the details of a single ticket. + */ + public IntercomHttpResponse> getTicket(GetTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 401) { + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update a ticket. + */ + public IntercomHttpResponse> updateTicket(UpdateTicketRequest request) { + return updateTicket(request, null); + } + + /** + * You can update a ticket. + */ + public IntercomHttpResponse> updateTicket( + UpdateTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PUT", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 400: + throw new BadRequestError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public IntercomHttpResponse deleteTicket(DeleteTicketRequest request) { + return deleteTicket(request, null); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public IntercomHttpResponse deleteTicket( + DeleteTicketRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets") + .addPathSegment(request.getId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteTicketResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + switch (response.code()) { + case 401: + throw new UnauthorizedError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); + case 404: + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public IntercomHttpResponse searchTickets(SearchRequest request) { + return searchTickets(request, null); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public IntercomHttpResponse searchTickets(SearchRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("tickets/search") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new IntercomApiException( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/TicketsClient.java b/src/main/java/com/intercom/api/resources/unstable/tickets/TicketsClient.java new file mode 100644 index 0000000..bfdc1aa --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/TicketsClient.java @@ -0,0 +1,225 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.unstable.jobs.types.Jobs; +import com.intercom.api.resources.unstable.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.EnqueueCreateTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.GetTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.ReplyTicketRequest; +import com.intercom.api.resources.unstable.tickets.requests.UpdateTicketRequest; +import com.intercom.api.resources.unstable.tickets.types.DeleteTicketResponse; +import com.intercom.api.resources.unstable.tickets.types.Ticket; +import com.intercom.api.resources.unstable.types.SearchRequest; +import com.intercom.api.resources.unstable.types.TicketList; +import com.intercom.api.resources.unstable.types.TicketReply; +import java.util.Optional; + +public class TicketsClient { + protected final ClientOptions clientOptions; + + private final RawTicketsClient rawClient; + + public TicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawTicketsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTicketsClient withRawResponse() { + return this.rawClient; + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public TicketReply replyTicket(ReplyTicketRequest request) { + return this.rawClient.replyTicket(request).body(); + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + */ + public TicketReply replyTicket(ReplyTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.replyTicket(request, requestOptions).body(); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public Jobs enqueueCreateTicket(EnqueueCreateTicketRequest request) { + return this.rawClient.enqueueCreateTicket(request).body(); + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + */ + public Jobs enqueueCreateTicket(EnqueueCreateTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.enqueueCreateTicket(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single ticket. + */ + public Optional getTicket(GetTicketRequest request) { + return this.rawClient.getTicket(request).body(); + } + + /** + * You can fetch the details of a single ticket. + */ + public Optional getTicket(GetTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.getTicket(request, requestOptions).body(); + } + + /** + * You can update a ticket. + */ + public Optional updateTicket(UpdateTicketRequest request) { + return this.rawClient.updateTicket(request).body(); + } + + /** + * You can update a ticket. + */ + public Optional updateTicket(UpdateTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.updateTicket(request, requestOptions).body(); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public DeleteTicketResponse deleteTicket(DeleteTicketRequest request) { + return this.rawClient.deleteTicket(request).body(); + } + + /** + * You can delete a ticket using the Intercom provided ID. + */ + public DeleteTicketResponse deleteTicket(DeleteTicketRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteTicket(request, requestOptions).body(); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public TicketList searchTickets(SearchRequest request) { + return this.rawClient.searchTickets(request).body(); + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + *

To search for tickets, you send a POST request to https://api.intercom.io/tickets/search.

+ *

This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the AND and OR operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is 20 results per page. + * See the pagination section for more details on how to use the starting_after param. + * {% /admonition %}

+ *

Nesting & Limitations

+ *

You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be:

+ *
    + *
  • There's a limit of max 2 nested filters
  • + *
  • There's a limit of max 15 filters for each AND or OR group
  • + *
+ *

Accepted Fields

+ *

Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as created_at accepts a date, the value cannot be a string such as "foobar"). + * The source.body field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a "I need support" body - the query should contain a = operator with the value "support" for such conversation to be returned. A query with a = operator and a "need support" value will not yield a result.

+ *

| Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | default_title | String | + * | default_description | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

+ *

Accepted Operators

+ *

{% admonition type="info" name="Searching based on created_at" %} + * You may use the <= or >= operators to search by created_at. + * {% /admonition %}

+ *

The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string ("="). The operator has to be compatible with the field's type (eg. you cannot search with > for a given string value as it's only compatible for integer's and dates).

+ *

| Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for OR queries Values most be in Array | + * | NIN | All | Not In Shortcut for OR ! queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With |

+ */ + public TicketList searchTickets(SearchRequest request, RequestOptions requestOptions) { + return this.rawClient.searchTickets(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/requests/DeleteTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/DeleteTicketRequest.java new file mode 100644 index 0000000..5810789 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/DeleteTicketRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteTicketRequest.Builder.class) +public final class DeleteTicketRequest { + private final String id; + + private final Map additionalProperties; + + private DeleteTicketRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTicketRequest && equalTo((DeleteTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTicketRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the ticket which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(DeleteTicketRequest other); + } + + public interface _FinalStage { + DeleteTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteTicketRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the ticket which is given by Intercom.

The unique identifier for the ticket which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public DeleteTicketRequest build() { + return new DeleteTicketRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/requests/EnqueueCreateTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/EnqueueCreateTicketRequest.java new file mode 100644 index 0000000..32c1457 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/EnqueueCreateTicketRequest.java @@ -0,0 +1,914 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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.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.resources.unstable.types.ICreateTicketRequestBody; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = EnqueueCreateTicketRequest.Builder.class) +public final class EnqueueCreateTicketRequest implements ICreateTicketRequestBody { + private final String ticketTypeId; + + private final List contacts; + + private final Optional conversationToLinkId; + + private final Optional companyId; + + private final Optional createdAt; + + private final Optional assignment; + + private final Optional skipNotifications; + + private final Map additionalProperties; + + private EnqueueCreateTicketRequest( + String ticketTypeId, + List contacts, + Optional conversationToLinkId, + Optional companyId, + Optional createdAt, + Optional assignment, + Optional skipNotifications, + Map additionalProperties) { + this.ticketTypeId = ticketTypeId; + this.contacts = contacts; + this.conversationToLinkId = conversationToLinkId; + this.companyId = companyId; + this.createdAt = createdAt; + this.assignment = assignment; + this.skipNotifications = skipNotifications; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the type of ticket you want to create + */ + @JsonProperty("ticket_type_id") + public String getTicketTypeId() { + return ticketTypeId; + } + + /** + * @return The list of contacts (users or leads) affected by this ticket. Currently only one is allowed + */ + @JsonProperty("contacts") + public List getContacts() { + return contacts; + } + + /** + * @return The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + *
    + *
  • conversation | back-office ticket
  • + *
  • customer tickets | non-shared back-office ticket
  • + *
  • conversation | tracker ticket
  • + *
  • customer ticket | tracker ticket
  • + *
+ */ + @JsonProperty("conversation_to_link_id") + public Optional getConversationToLinkId() { + return conversationToLinkId; + } + + /** + * @return The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return The time the ticket was created. If not provided, the current time will be used. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("assignment") + public Optional getAssignment() { + return assignment; + } + + /** + * @return Option to disable notifications when a Ticket is created. + */ + @JsonProperty("skip_notifications") + public Optional getSkipNotifications() { + return skipNotifications; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof EnqueueCreateTicketRequest && equalTo((EnqueueCreateTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(EnqueueCreateTicketRequest other) { + return ticketTypeId.equals(other.ticketTypeId) + && contacts.equals(other.contacts) + && conversationToLinkId.equals(other.conversationToLinkId) + && companyId.equals(other.companyId) + && createdAt.equals(other.createdAt) + && assignment.equals(other.assignment) + && skipNotifications.equals(other.skipNotifications); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.ticketTypeId, + this.contacts, + this.conversationToLinkId, + this.companyId, + this.createdAt, + this.assignment, + this.skipNotifications); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketTypeIdStage builder() { + return new Builder(); + } + + public interface TicketTypeIdStage { + /** + * The ID of the type of ticket you want to create + */ + _FinalStage ticketTypeId(@NotNull String ticketTypeId); + + Builder from(EnqueueCreateTicketRequest other); + } + + public interface _FinalStage { + EnqueueCreateTicketRequest build(); + + /** + *

The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

+ */ + _FinalStage contacts(List contacts); + + _FinalStage addContacts(ContactsItem contacts); + + _FinalStage addAllContacts(List contacts); + + /** + *

The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets:

+ *
    + *
  • conversation | back-office ticket
  • + *
  • customer tickets | non-shared back-office ticket
  • + *
  • conversation | tracker ticket
  • + *
  • customer ticket | tracker ticket
  • + *
+ */ + _FinalStage conversationToLinkId(Optional conversationToLinkId); + + _FinalStage conversationToLinkId(String conversationToLinkId); + + /** + *

The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

+ */ + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + /** + *

The time the ticket was created. If not provided, the current time will be used.

+ */ + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(Integer createdAt); + + _FinalStage assignment(Optional assignment); + + _FinalStage assignment(Assignment assignment); + + /** + *

Option to disable notifications when a Ticket is created.

+ */ + _FinalStage skipNotifications(Optional skipNotifications); + + _FinalStage skipNotifications(Boolean skipNotifications); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketTypeIdStage, _FinalStage { + private String ticketTypeId; + + private Optional skipNotifications = Optional.empty(); + + private Optional assignment = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional conversationToLinkId = Optional.empty(); + + private List contacts = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(EnqueueCreateTicketRequest other) { + ticketTypeId(other.getTicketTypeId()); + contacts(other.getContacts()); + conversationToLinkId(other.getConversationToLinkId()); + companyId(other.getCompanyId()); + createdAt(other.getCreatedAt()); + assignment(other.getAssignment()); + skipNotifications(other.getSkipNotifications()); + return this; + } + + /** + * The ID of the type of ticket you want to create

The ID of the type of ticket you want to create

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("ticket_type_id") + public _FinalStage ticketTypeId(@NotNull String ticketTypeId) { + this.ticketTypeId = Objects.requireNonNull(ticketTypeId, "ticketTypeId must not be null"); + return this; + } + + /** + *

Option to disable notifications when a Ticket is created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage skipNotifications(Boolean skipNotifications) { + this.skipNotifications = Optional.ofNullable(skipNotifications); + return this; + } + + /** + *

Option to disable notifications when a Ticket is created.

+ */ + @java.lang.Override + @JsonSetter(value = "skip_notifications", nulls = Nulls.SKIP) + public _FinalStage skipNotifications(Optional skipNotifications) { + this.skipNotifications = skipNotifications; + return this; + } + + @java.lang.Override + public _FinalStage assignment(Assignment assignment) { + this.assignment = Optional.ofNullable(assignment); + return this; + } + + @java.lang.Override + @JsonSetter(value = "assignment", nulls = Nulls.SKIP) + public _FinalStage assignment(Optional assignment) { + this.assignment = assignment; + return this; + } + + /** + *

The time the ticket was created. If not provided, the current time will be used.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The time the ticket was created. If not provided, the current time will be used.

+ */ + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom

+ */ + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + /** + *

The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets:

+ *
    + *
  • conversation | back-office ticket
  • + *
  • customer tickets | non-shared back-office ticket
  • + *
  • conversation | tracker ticket
  • + *
  • customer ticket | tracker ticket
  • + *
+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage conversationToLinkId(String conversationToLinkId) { + this.conversationToLinkId = Optional.ofNullable(conversationToLinkId); + return this; + } + + /** + *

The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets:

+ *
    + *
  • conversation | back-office ticket
  • + *
  • customer tickets | non-shared back-office ticket
  • + *
  • conversation | tracker ticket
  • + *
  • customer ticket | tracker ticket
  • + *
+ */ + @java.lang.Override + @JsonSetter(value = "conversation_to_link_id", nulls = Nulls.SKIP) + public _FinalStage conversationToLinkId(Optional conversationToLinkId) { + this.conversationToLinkId = conversationToLinkId; + return this; + } + + /** + *

The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addAllContacts(List contacts) { + this.contacts.addAll(contacts); + return this; + } + + /** + *

The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage addContacts(ContactsItem contacts) { + this.contacts.add(contacts); + return this; + } + + /** + *

The list of contacts (users or leads) affected by this ticket. Currently only one is allowed

+ */ + @java.lang.Override + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public _FinalStage contacts(List contacts) { + this.contacts.clear(); + this.contacts.addAll(contacts); + return this; + } + + @java.lang.Override + public EnqueueCreateTicketRequest build() { + return new EnqueueCreateTicketRequest( + ticketTypeId, + contacts, + conversationToLinkId, + companyId, + createdAt, + assignment, + skipNotifications, + additionalProperties); + } + } + + @JsonDeserialize(using = ContactsItem.Deserializer.class) + public static final class ContactsItem { + private final Object value; + + private final int type; + + private ContactsItem(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((Id) this.value); + } else if (this.type == 1) { + return visitor.visit((ExternalId) this.value); + } else if (this.type == 2) { + return visitor.visit((Email) 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 ContactsItem && equalTo((ContactsItem) other); + } + + private boolean equalTo(ContactsItem 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 ContactsItem of(Id value) { + return new ContactsItem(value, 0); + } + + public static ContactsItem of(ExternalId value) { + return new ContactsItem(value, 1); + } + + public static ContactsItem of(Email value) { + return new ContactsItem(value, 2); + } + + public interface Visitor { + T visit(Id value); + + T visit(ExternalId value); + + T visit(Email value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ContactsItem.class); + } + + @java.lang.Override + public ContactsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Id.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ExternalId.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Email.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Id.Builder.class) + public static final class Id { + private final String id; + + private final Map additionalProperties; + + private Id(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The identifier for the contact as given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Id && equalTo((Id) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Id other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The identifier for the contact as given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(Id other); + } + + public interface _FinalStage { + Id build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Id other) { + id(other.getId()); + return this; + } + + /** + * The identifier for the contact as given by Intercom.

The identifier for the contact as given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public Id build() { + return new Id(id, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = ExternalId.Builder.class) + public static final class ExternalId { + private final String externalId; + + private final Map additionalProperties; + + private ExternalId(String externalId, Map additionalProperties) { + this.externalId = externalId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The external_id you have defined for the contact who is being added as a participant. + */ + @JsonProperty("external_id") + public String getExternalId() { + return externalId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExternalId && equalTo((ExternalId) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExternalId other) { + return externalId.equals(other.externalId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ExternalIdStage builder() { + return new Builder(); + } + + public interface ExternalIdStage { + /** + * The external_id you have defined for the contact who is being added as a participant. + */ + _FinalStage externalId(@NotNull String externalId); + + Builder from(ExternalId other); + } + + public interface _FinalStage { + ExternalId build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ExternalIdStage, _FinalStage { + private String externalId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExternalId other) { + externalId(other.getExternalId()); + return this; + } + + /** + * The external_id you have defined for the contact who is being added as a participant.

The external_id you have defined for the contact who is being added as a participant.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("external_id") + public _FinalStage externalId(@NotNull String externalId) { + this.externalId = Objects.requireNonNull(externalId, "externalId must not be null"); + return this; + } + + @java.lang.Override + public ExternalId build() { + return new ExternalId(externalId, additionalProperties); + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Email.Builder.class) + public static final class Email { + private final String email; + + private final Map additionalProperties; + + private Email(String email, Map additionalProperties) { + this.email = email; + this.additionalProperties = additionalProperties; + } + + /** + * @return The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Email && equalTo((Email) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Email other) { + return email.equals(other.email); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.email); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EmailStage builder() { + return new Builder(); + } + + public interface EmailStage { + /** + * The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. + */ + _FinalStage email(@NotNull String email); + + Builder from(Email other); + } + + public interface _FinalStage { + Email build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EmailStage, _FinalStage { + private String email; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Email other) { + email(other.getEmail()); + return this; + } + + /** + * The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created.

The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("email") + public _FinalStage email(@NotNull String email) { + this.email = Objects.requireNonNull(email, "email must not be null"); + return this; + } + + @java.lang.Override + public Email build() { + return new Email(email, additionalProperties); + } + } + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Assignment.Builder.class) + public static final class Assignment { + private final Optional adminAssigneeId; + + private final Optional teamAssigneeId; + + private final Map additionalProperties; + + private Assignment( + Optional adminAssigneeId, + Optional teamAssigneeId, + Map additionalProperties) { + this.adminAssigneeId = adminAssigneeId; + this.teamAssigneeId = teamAssigneeId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. + */ + @JsonProperty("admin_assignee_id") + public Optional getAdminAssigneeId() { + return adminAssigneeId; + } + + /** + * @return The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. + */ + @JsonProperty("team_assignee_id") + public Optional getTeamAssigneeId() { + return teamAssigneeId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Assignment && equalTo((Assignment) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Assignment other) { + return adminAssigneeId.equals(other.adminAssigneeId) && teamAssigneeId.equals(other.teamAssigneeId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.adminAssigneeId, this.teamAssigneeId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional adminAssigneeId = Optional.empty(); + + private Optional teamAssigneeId = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Assignment other) { + adminAssigneeId(other.getAdminAssigneeId()); + teamAssigneeId(other.getTeamAssigneeId()); + return this; + } + + /** + *

The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned.

+ */ + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; + return this; + } + + public Builder adminAssigneeId(String adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + return this; + } + + /** + *

The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned.

+ */ + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; + return this; + } + + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + return this; + } + + public Assignment build() { + return new Assignment(adminAssigneeId, teamAssigneeId, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/requests/GetTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/GetTicketRequest.java new file mode 100644 index 0000000..6f31179 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/GetTicketRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetTicketRequest.Builder.class) +public final class GetTicketRequest { + private final String id; + + private final Map additionalProperties; + + private GetTicketRequest(String id, Map additionalProperties) { + this.id = id; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetTicketRequest && equalTo((GetTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetTicketRequest other) { + return id.equals(other.id); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the ticket which is given by Intercom. + */ + _FinalStage id(@NotNull String id); + + Builder from(GetTicketRequest other); + } + + public interface _FinalStage { + GetTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetTicketRequest other) { + id(other.getId()); + return this; + } + + /** + * The unique identifier for the ticket which is given by Intercom.

The unique identifier for the ticket which is given by Intercom.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + public GetTicketRequest build() { + return new GetTicketRequest(id, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/requests/ReplyTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/ReplyTicketRequest.java new file mode 100644 index 0000000..935a7bb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/ReplyTicketRequest.java @@ -0,0 +1,125 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.tickets.types.ReplyTicketRequestBody; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ReplyTicketRequest.Builder.class) +public final class ReplyTicketRequest { + private final String id; + + private final ReplyTicketRequestBody body; + + private final Map additionalProperties; + + private ReplyTicketRequest(String id, ReplyTicketRequestBody body, Map additionalProperties) { + this.id = id; + this.body = body; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("body") + public ReplyTicketRequestBody getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ReplyTicketRequest && equalTo((ReplyTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ReplyTicketRequest other) { + return id.equals(other.id) && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + BodyStage id(@NotNull String id); + + Builder from(ReplyTicketRequest other); + } + + public interface BodyStage { + _FinalStage body(@NotNull ReplyTicketRequestBody body); + } + + public interface _FinalStage { + ReplyTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, BodyStage, _FinalStage { + private String id; + + private ReplyTicketRequestBody body; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ReplyTicketRequest other) { + id(other.getId()); + body(other.getBody()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public BodyStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull ReplyTicketRequestBody body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + @java.lang.Override + public ReplyTicketRequest build() { + return new ReplyTicketRequest(id, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/requests/UpdateTicketRequest.java b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/UpdateTicketRequest.java new file mode 100644 index 0000000..49a425c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/requests/UpdateTicketRequest.java @@ -0,0 +1,479 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = UpdateTicketRequest.Builder.class) +public final class UpdateTicketRequest { + private final String id; + + private final Optional> ticketAttributes; + + private final Optional ticketStateId; + + private final Optional companyId; + + private final Optional open; + + private final Optional isShared; + + private final Optional snoozedUntil; + + private final Optional adminId; + + private final Optional assigneeId; + + private final Map additionalProperties; + + private UpdateTicketRequest( + String id, + Optional> ticketAttributes, + Optional ticketStateId, + Optional companyId, + Optional open, + Optional isShared, + Optional snoozedUntil, + Optional adminId, + Optional assigneeId, + Map additionalProperties) { + this.id = id; + this.ticketAttributes = ticketAttributes; + this.ticketStateId = ticketStateId; + this.companyId = companyId; + this.open = open; + this.isShared = isShared; + this.snoozedUntil = snoozedUntil; + this.adminId = adminId; + this.assigneeId = assigneeId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The attributes set on the ticket. + */ + @JsonProperty("ticket_attributes") + public Optional> getTicketAttributes() { + return ticketAttributes; + } + + /** + * @return The ID of the ticket state associated with the ticket type. + */ + @JsonProperty("ticket_state_id") + public Optional getTicketStateId() { + return ticketStateId; + } + + /** + * @return The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + + /** + * @return Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. + */ + @JsonProperty("open") + public Optional getOpen() { + return open; + } + + /** + * @return Specify whether the ticket is visible to users. + */ + @JsonProperty("is_shared") + public Optional getIsShared() { + return isShared; + } + + /** + * @return The time you want the ticket to reopen. + */ + @JsonProperty("snoozed_until") + public Optional getSnoozedUntil() { + return snoozedUntil; + } + + /** + * @return The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + /** + * @return The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + */ + @JsonProperty("assignee_id") + public Optional getAssigneeId() { + return assigneeId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateTicketRequest && equalTo((UpdateTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateTicketRequest other) { + return id.equals(other.id) + && ticketAttributes.equals(other.ticketAttributes) + && ticketStateId.equals(other.ticketStateId) + && companyId.equals(other.companyId) + && open.equals(other.open) + && isShared.equals(other.isShared) + && snoozedUntil.equals(other.snoozedUntil) + && adminId.equals(other.adminId) + && assigneeId.equals(other.assigneeId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.ticketAttributes, + this.ticketStateId, + this.companyId, + this.open, + this.isShared, + this.snoozedUntil, + this.adminId, + this.assigneeId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + /** + * The unique identifier for the ticket which is given by Intercom + */ + _FinalStage id(@NotNull String id); + + Builder from(UpdateTicketRequest other); + } + + public interface _FinalStage { + UpdateTicketRequest build(); + + /** + *

The attributes set on the ticket.

+ */ + _FinalStage ticketAttributes(Optional> ticketAttributes); + + _FinalStage ticketAttributes(Map ticketAttributes); + + /** + *

The ID of the ticket state associated with the ticket type.

+ */ + _FinalStage ticketStateId(Optional ticketStateId); + + _FinalStage ticketStateId(String ticketStateId); + + /** + *

The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company.

+ */ + _FinalStage companyId(Optional companyId); + + _FinalStage companyId(String companyId); + + /** + *

Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

+ */ + _FinalStage open(Optional open); + + _FinalStage open(Boolean open); + + /** + *

Specify whether the ticket is visible to users.

+ */ + _FinalStage isShared(Optional isShared); + + _FinalStage isShared(Boolean isShared); + + /** + *

The time you want the ticket to reopen.

+ */ + _FinalStage snoozedUntil(Optional snoozedUntil); + + _FinalStage snoozedUntil(Integer snoozedUntil); + + /** + *

The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins.

+ */ + _FinalStage adminId(Optional adminId); + + _FinalStage adminId(Integer adminId); + + /** + *

The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

+ */ + _FinalStage assigneeId(Optional assigneeId); + + _FinalStage assigneeId(String assigneeId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, _FinalStage { + private String id; + + private Optional assigneeId = Optional.empty(); + + private Optional adminId = Optional.empty(); + + private Optional snoozedUntil = Optional.empty(); + + private Optional isShared = Optional.empty(); + + private Optional open = Optional.empty(); + + private Optional companyId = Optional.empty(); + + private Optional ticketStateId = Optional.empty(); + + private Optional> ticketAttributes = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateTicketRequest other) { + id(other.getId()); + ticketAttributes(other.getTicketAttributes()); + ticketStateId(other.getTicketStateId()); + companyId(other.getCompanyId()); + open(other.getOpen()); + isShared(other.getIsShared()); + snoozedUntil(other.getSnoozedUntil()); + adminId(other.getAdminId()); + assigneeId(other.getAssigneeId()); + return this; + } + + /** + * The unique identifier for the ticket which is given by Intercom

The unique identifier for the ticket which is given by Intercom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + *

The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage assigneeId(String assigneeId) { + this.assigneeId = Optional.ofNullable(assigneeId); + return this; + } + + /** + *

The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it.

+ */ + @java.lang.Override + @JsonSetter(value = "assignee_id", nulls = Nulls.SKIP) + public _FinalStage assigneeId(Optional assigneeId) { + this.assigneeId = assigneeId; + return this; + } + + /** + *

The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage adminId(Integer adminId) { + this.adminId = Optional.ofNullable(adminId); + return this; + } + + /** + *

The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins.

+ */ + @java.lang.Override + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; + return this; + } + + /** + *

The time you want the ticket to reopen.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage snoozedUntil(Integer snoozedUntil) { + this.snoozedUntil = Optional.ofNullable(snoozedUntil); + return this; + } + + /** + *

The time you want the ticket to reopen.

+ */ + @java.lang.Override + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public _FinalStage snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; + return this; + } + + /** + *

Specify whether the ticket is visible to users.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isShared(Boolean isShared) { + this.isShared = Optional.ofNullable(isShared); + return this; + } + + /** + *

Specify whether the ticket is visible to users.

+ */ + @java.lang.Override + @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) + public _FinalStage isShared(Optional isShared) { + this.isShared = isShared; + return this; + } + + /** + *

Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage open(Boolean open) { + this.open = Optional.ofNullable(open); + return this; + } + + /** + *

Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

+ */ + @java.lang.Override + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public _FinalStage open(Optional open) { + this.open = open; + return this; + } + + /** + *

The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); + return this; + } + + /** + *

The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company.

+ */ + @java.lang.Override + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; + return this; + } + + /** + *

The ID of the ticket state associated with the ticket type.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage ticketStateId(String ticketStateId) { + this.ticketStateId = Optional.ofNullable(ticketStateId); + return this; + } + + /** + *

The ID of the ticket state associated with the ticket type.

+ */ + @java.lang.Override + @JsonSetter(value = "ticket_state_id", nulls = Nulls.SKIP) + public _FinalStage ticketStateId(Optional ticketStateId) { + this.ticketStateId = ticketStateId; + return this; + } + + /** + *

The attributes set on the ticket.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage ticketAttributes(Map ticketAttributes) { + this.ticketAttributes = Optional.ofNullable(ticketAttributes); + return this; + } + + /** + *

The attributes set on the ticket.

+ */ + @java.lang.Override + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public _FinalStage ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; + return this; + } + + @java.lang.Override + public UpdateTicketRequest build() { + return new UpdateTicketRequest( + id, + ticketAttributes, + ticketStateId, + companyId, + open, + isShared, + snoozedUntil, + adminId, + assigneeId, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/types/DeleteTicketResponse.java b/src/main/java/com/intercom/api/resources/unstable/tickets/types/DeleteTicketResponse.java new file mode 100644 index 0000000..bba8451 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/types/DeleteTicketResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DeleteTicketResponse.Builder.class) +public final class DeleteTicketResponse { + private final Optional id; + + private final Optional object; + + private final Optional deleted; + + private final Map additionalProperties; + + private DeleteTicketResponse( + Optional id, + Optional object, + Optional deleted, + Map additionalProperties) { + this.id = id; + this.object = object; + this.deleted = deleted; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return always ticket + */ + @JsonProperty("object") + public Optional getObject() { + return object; + } + + /** + * @return Whether the ticket is deleted or not. + */ + @JsonProperty("deleted") + public Optional getDeleted() { + return deleted; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteTicketResponse && equalTo((DeleteTicketResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteTicketResponse other) { + return id.equals(other.id) && object.equals(other.object) && deleted.equals(other.deleted); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.object, this.deleted); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional object = Optional.empty(); + + private Optional deleted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DeleteTicketResponse other) { + id(other.getId()); + object(other.getObject()); + deleted(other.getDeleted()); + return this; + } + + /** + *

The unique identifier for the ticket.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

always ticket

+ */ + @JsonSetter(value = "object", nulls = Nulls.SKIP) + public Builder object(Optional object) { + this.object = object; + return this; + } + + public Builder object(String object) { + this.object = Optional.ofNullable(object); + return this; + } + + /** + *

Whether the ticket is deleted or not.

+ */ + @JsonSetter(value = "deleted", nulls = Nulls.SKIP) + public Builder deleted(Optional deleted) { + this.deleted = deleted; + return this; + } + + public Builder deleted(Boolean deleted) { + this.deleted = Optional.ofNullable(deleted); + return this; + } + + public DeleteTicketResponse build() { + return new DeleteTicketResponse(id, object, deleted, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/types/ReplyTicketRequestBody.java b/src/main/java/com/intercom/api/resources/unstable/tickets/types/ReplyTicketRequestBody.java new file mode 100644 index 0000000..d7822c6 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/types/ReplyTicketRequestBody.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +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.resources.unstable.types.AdminReplyTicketRequest; +import com.intercom.api.resources.unstable.types.ContactReplyTicketRequest; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = ReplyTicketRequestBody.Deserializer.class) +public final class ReplyTicketRequestBody { + private final Object value; + + private final int type; + + private ReplyTicketRequestBody(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((ContactReplyTicketRequest) this.value); + } else if (this.type == 1) { + return visitor.visit((AdminReplyTicketRequest) 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 ReplyTicketRequestBody && equalTo((ReplyTicketRequestBody) other); + } + + private boolean equalTo(ReplyTicketRequestBody 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 ReplyTicketRequestBody of(ContactReplyTicketRequest value) { + return new ReplyTicketRequestBody(value, 0); + } + + public static ReplyTicketRequestBody of(AdminReplyTicketRequest value) { + return new ReplyTicketRequestBody(value, 1); + } + + public interface Visitor { + T visit(ContactReplyTicketRequest value); + + T visit(AdminReplyTicketRequest value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(ReplyTicketRequestBody.class); + } + + @java.lang.Override + public ReplyTicketRequestBody deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ContactReplyTicketRequest.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, AdminReplyTicketRequest.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/types/Ticket.java b/src/main/java/com/intercom/api/resources/unstable/tickets/types/Ticket.java new file mode 100644 index 0000000..4c8c910 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/types/Ticket.java @@ -0,0 +1,794 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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 com.intercom.api.resources.unstable.types.FileAttribute; +import com.intercom.api.resources.unstable.types.LinkedObjectList; +import com.intercom.api.resources.unstable.types.TicketParts; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Ticket.Builder.class) +public final class Ticket { + private final Optional type; + + private final Optional id; + + private final Optional ticketId; + + private final Optional category; + + private final Optional> ticketAttributes; + + private final Optional ticketState; + + private final Optional ticketType; + + private final Optional contacts; + + private final Optional adminAssigneeId; + + private final Optional teamAssigneeId; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional open; + + private final Optional snoozedUntil; + + private final Optional linkedObjects; + + private final Optional ticketParts; + + private final Optional isShared; + + private final Map additionalProperties; + + private Ticket( + Optional type, + Optional id, + Optional ticketId, + Optional category, + Optional> ticketAttributes, + Optional ticketState, + Optional ticketType, + Optional contacts, + Optional adminAssigneeId, + Optional teamAssigneeId, + Optional createdAt, + Optional updatedAt, + Optional open, + Optional snoozedUntil, + Optional linkedObjects, + Optional ticketParts, + Optional isShared, + Map additionalProperties) { + this.type = type; + this.id = id; + this.ticketId = ticketId; + this.category = category; + this.ticketAttributes = ticketAttributes; + this.ticketState = ticketState; + this.ticketType = ticketType; + this.contacts = contacts; + this.adminAssigneeId = adminAssigneeId; + this.teamAssigneeId = teamAssigneeId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.open = open; + this.snoozedUntil = snoozedUntil; + this.linkedObjects = linkedObjects; + this.ticketParts = ticketParts; + this.isShared = isShared; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always ticket + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. + */ + @JsonProperty("ticket_id") + public Optional getTicketId() { + return ticketId; + } + + /** + * @return Category of the Ticket. + */ + @JsonProperty("category") + public Optional getCategory() { + return category; + } + + @JsonProperty("ticket_attributes") + public Optional> getTicketAttributes() { + return ticketAttributes; + } + + @JsonProperty("ticket_state") + public Optional getTicketState() { + return ticketState; + } + + @JsonProperty("ticket_type") + public Optional getTicketType() { + return ticketType; + } + + @JsonProperty("contacts") + public Optional getContacts() { + return contacts; + } + + /** + * @return The id representing the admin assigned to the ticket. + */ + @JsonProperty("admin_assignee_id") + public Optional getAdminAssigneeId() { + return adminAssigneeId; + } + + /** + * @return The id representing the team assigned to the ticket. + */ + @JsonProperty("team_assignee_id") + public Optional getTeamAssigneeId() { + return teamAssigneeId; + } + + /** + * @return The time the ticket was created as a UTC Unix timestamp. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the ticket was updated as a UTC Unix timestamp. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return Whether or not the ticket is open. If false, the ticket is closed. + */ + @JsonProperty("open") + public Optional getOpen() { + return open; + } + + /** + * @return The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed. + */ + @JsonProperty("snoozed_until") + public Optional getSnoozedUntil() { + return snoozedUntil; + } + + @JsonProperty("linked_objects") + public Optional getLinkedObjects() { + return linkedObjects; + } + + @JsonProperty("ticket_parts") + public Optional getTicketParts() { + return ticketParts; + } + + /** + * @return Whether or not the ticket is shared with the customer. + */ + @JsonProperty("is_shared") + public Optional getIsShared() { + return isShared; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Ticket && equalTo((Ticket) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Ticket other) { + return type.equals(other.type) + && id.equals(other.id) + && ticketId.equals(other.ticketId) + && category.equals(other.category) + && ticketAttributes.equals(other.ticketAttributes) + && ticketState.equals(other.ticketState) + && ticketType.equals(other.ticketType) + && contacts.equals(other.contacts) + && adminAssigneeId.equals(other.adminAssigneeId) + && teamAssigneeId.equals(other.teamAssigneeId) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && open.equals(other.open) + && snoozedUntil.equals(other.snoozedUntil) + && linkedObjects.equals(other.linkedObjects) + && ticketParts.equals(other.ticketParts) + && isShared.equals(other.isShared); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.ticketId, + this.category, + this.ticketAttributes, + this.ticketState, + this.ticketType, + this.contacts, + this.adminAssigneeId, + this.teamAssigneeId, + this.createdAt, + this.updatedAt, + this.open, + this.snoozedUntil, + this.linkedObjects, + this.ticketParts, + this.isShared); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional ticketId = Optional.empty(); + + private Optional category = Optional.empty(); + + private Optional> ticketAttributes = Optional.empty(); + + private Optional ticketState = Optional.empty(); + + private Optional ticketType = Optional.empty(); + + private Optional contacts = Optional.empty(); + + private Optional adminAssigneeId = Optional.empty(); + + private Optional teamAssigneeId = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional open = Optional.empty(); + + private Optional snoozedUntil = Optional.empty(); + + private Optional linkedObjects = Optional.empty(); + + private Optional ticketParts = Optional.empty(); + + private Optional isShared = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Ticket other) { + type(other.getType()); + id(other.getId()); + ticketId(other.getTicketId()); + category(other.getCategory()); + ticketAttributes(other.getTicketAttributes()); + ticketState(other.getTicketState()); + ticketType(other.getTicketType()); + contacts(other.getContacts()); + adminAssigneeId(other.getAdminAssigneeId()); + teamAssigneeId(other.getTeamAssigneeId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + open(other.getOpen()); + snoozedUntil(other.getSnoozedUntil()); + linkedObjects(other.getLinkedObjects()); + ticketParts(other.getTicketParts()); + isShared(other.getIsShared()); + return this; + } + + /** + *

Always ticket

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The unique identifier for the ticket which is given by Intercom.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.

+ */ + @JsonSetter(value = "ticket_id", nulls = Nulls.SKIP) + public Builder ticketId(Optional ticketId) { + this.ticketId = ticketId; + return this; + } + + public Builder ticketId(String ticketId) { + this.ticketId = Optional.ofNullable(ticketId); + return this; + } + + /** + *

Category of the Ticket.

+ */ + @JsonSetter(value = "category", nulls = Nulls.SKIP) + public Builder category(Optional category) { + this.category = category; + return this; + } + + public Builder category(Category category) { + this.category = Optional.ofNullable(category); + return this; + } + + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public Builder ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; + return this; + } + + public Builder ticketAttributes(Map ticketAttributes) { + this.ticketAttributes = Optional.ofNullable(ticketAttributes); + return this; + } + + @JsonSetter(value = "ticket_state", nulls = Nulls.SKIP) + public Builder ticketState(Optional ticketState) { + this.ticketState = ticketState; + return this; + } + + public Builder ticketState(TicketState ticketState) { + this.ticketState = Optional.ofNullable(ticketState); + return this; + } + + @JsonSetter(value = "ticket_type", nulls = Nulls.SKIP) + public Builder ticketType(Optional ticketType) { + this.ticketType = ticketType; + return this; + } + + public Builder ticketType(TicketType ticketType) { + this.ticketType = Optional.ofNullable(ticketType); + return this; + } + + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional contacts) { + this.contacts = contacts; + return this; + } + + public Builder contacts(TicketContacts contacts) { + this.contacts = Optional.ofNullable(contacts); + return this; + } + + /** + *

The id representing the admin assigned to the ticket.

+ */ + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; + return this; + } + + public Builder adminAssigneeId(String adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + return this; + } + + /** + *

The id representing the team assigned to the ticket.

+ */ + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; + return this; + } + + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + return this; + } + + /** + *

The time the ticket was created as a UTC Unix timestamp.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The last time the ticket was updated as a UTC Unix timestamp.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

Whether or not the ticket is open. If false, the ticket is closed.

+ */ + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public Builder open(Optional open) { + this.open = open; + return this; + } + + public Builder open(Boolean open) { + this.open = Optional.ofNullable(open); + return this; + } + + /** + *

The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

+ */ + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public Builder snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; + return this; + } + + public Builder snoozedUntil(Integer snoozedUntil) { + this.snoozedUntil = Optional.ofNullable(snoozedUntil); + return this; + } + + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public Builder linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; + return this; + } + + public Builder linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); + return this; + } + + @JsonSetter(value = "ticket_parts", nulls = Nulls.SKIP) + public Builder ticketParts(Optional ticketParts) { + this.ticketParts = ticketParts; + return this; + } + + public Builder ticketParts(TicketParts ticketParts) { + this.ticketParts = Optional.ofNullable(ticketParts); + return this; + } + + /** + *

Whether or not the ticket is shared with the customer.

+ */ + @JsonSetter(value = "is_shared", nulls = Nulls.SKIP) + public Builder isShared(Optional isShared) { + this.isShared = isShared; + return this; + } + + public Builder isShared(Boolean isShared) { + this.isShared = Optional.ofNullable(isShared); + return this; + } + + public Ticket build() { + return new Ticket( + type, + id, + ticketId, + category, + ticketAttributes, + ticketState, + ticketType, + contacts, + adminAssigneeId, + teamAssigneeId, + createdAt, + updatedAt, + open, + snoozedUntil, + linkedObjects, + ticketParts, + isShared, + additionalProperties); + } + } + + public static final class Category { + public static final Category BACK_OFFICE = new Category(Value.BACK_OFFICE, "Back-office"); + + public static final Category CUSTOMER = new Category(Value.CUSTOMER, "Customer"); + + public static final Category TRACKER = new Category(Value.TRACKER, "Tracker"); + + private final Value value; + + private final String string; + + Category(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof Category && this.string.equals(((Category) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case BACK_OFFICE: + return visitor.visitBackOffice(); + case CUSTOMER: + return visitor.visitCustomer(); + case TRACKER: + return visitor.visitTracker(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Category valueOf(String value) { + switch (value) { + case "Back-office": + return BACK_OFFICE; + case "Customer": + return CUSTOMER; + case "Tracker": + return TRACKER; + default: + return new Category(Value.UNKNOWN, value); + } + } + + public enum Value { + CUSTOMER, + + BACK_OFFICE, + + TRACKER, + + UNKNOWN + } + + public interface Visitor { + T visitCustomer(); + + T visitBackOffice(); + + T visitTracker(); + + T visitUnknown(String unknownType); + } + } + + @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; + } + + @SuppressWarnings("unchecked") + 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/resources/unstable/tickets/types/TicketContacts.java b/src/main/java/com/intercom/api/resources/unstable/tickets/types/TicketContacts.java new file mode 100644 index 0000000..1cdf739 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/types/TicketContacts.java @@ -0,0 +1,134 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.intercom.api.core.ObjectMappers; +import com.intercom.api.resources.unstable.types.ContactReference; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TicketContacts.Builder.class) +public final class TicketContacts { + private final Optional type; + + private final Optional> contacts; + + private final Map additionalProperties; + + private TicketContacts( + Optional type, + Optional> contacts, + Map additionalProperties) { + this.type = type; + this.contacts = contacts; + this.additionalProperties = additionalProperties; + } + + /** + * @return always contact.list + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The list of contacts affected by this ticket. + */ + @JsonProperty("contacts") + public Optional> getContacts() { + return contacts; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TicketContacts && equalTo((TicketContacts) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TicketContacts other) { + return type.equals(other.type) && contacts.equals(other.contacts); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.contacts); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional> contacts = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TicketContacts other) { + type(other.getType()); + contacts(other.getContacts()); + return this; + } + + /** + *

always contact.list

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The list of contacts affected by this ticket.

+ */ + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional> contacts) { + this.contacts = contacts; + return this; + } + + public Builder contacts(List contacts) { + this.contacts = Optional.ofNullable(contacts); + return this; + } + + public TicketContacts build() { + return new TicketContacts(type, contacts, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/unstable/tickets/types/TicketPart.java b/src/main/java/com/intercom/api/resources/unstable/tickets/types/TicketPart.java new file mode 100644 index 0000000..e4e38a8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/unstable/tickets/types/TicketPart.java @@ -0,0 +1,1298 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.unstable.tickets.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +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 com.intercom.api.resources.unstable.types.PartAttachment; +import com.intercom.api.resources.unstable.types.Reference; +import com.intercom.api.resources.unstable.types.TicketPartAuthor; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = TicketPart.Builder.class) +public final class TicketPart { + private final Optional type; + + private final Optional id; + + private final Optional partType; + + private final Optional body; + + private final Optional previousTicketState; + + private final Optional ticketState; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional assignedTo; + + private final Optional author; + + private final Optional> attachments; + + private final Optional externalId; + + private final Optional redacted; + + private final Optional appPackageCode; + + private final Optional updatedAttributeData; + + private final Map additionalProperties; + + private TicketPart( + Optional type, + Optional id, + Optional partType, + Optional body, + Optional previousTicketState, + Optional ticketState, + Optional createdAt, + Optional updatedAt, + Optional assignedTo, + Optional author, + Optional> attachments, + Optional externalId, + Optional redacted, + Optional appPackageCode, + Optional updatedAttributeData, + Map additionalProperties) { + this.type = type; + this.id = id; + this.partType = partType; + this.body = body; + this.previousTicketState = previousTicketState; + this.ticketState = ticketState; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.assignedTo = assignedTo; + this.author = author; + this.attachments = attachments; + this.externalId = externalId; + this.redacted = redacted; + this.appPackageCode = appPackageCode; + this.updatedAttributeData = updatedAttributeData; + this.additionalProperties = additionalProperties; + } + + /** + * @return Always ticket_part + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id representing the ticket part. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The type of ticket part. + */ + @JsonProperty("part_type") + public Optional getPartType() { + return partType; + } + + /** + * @return The message body, which may contain HTML. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The previous state of the ticket. + */ + @JsonProperty("previous_ticket_state") + public Optional getPreviousTicketState() { + return previousTicketState; + } + + /** + * @return The state of the ticket. + */ + @JsonProperty("ticket_state") + public Optional getTicketState() { + return ticketState; + } + + /** + * @return The time the ticket part was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The last time the ticket part was updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.) + */ + @JsonProperty("assigned_to") + public Optional getAssignedTo() { + return assignedTo; + } + + @JsonProperty("author") + public Optional getAuthor() { + return author; + } + + /** + * @return A list of attachments for the part. + */ + @JsonProperty("attachments") + public Optional> getAttachments() { + return attachments; + } + + /** + * @return The external id of the ticket part + */ + @JsonProperty("external_id") + public Optional getExternalId() { + return externalId; + } + + /** + * @return Whether or not the ticket part has been redacted. + */ + @JsonProperty("redacted") + public Optional getRedacted() { + return redacted; + } + + /** + * @return The app package code if this part was created via API. Note this field won't show if the part was not created via API. + */ + @JsonProperty("app_package_code") + public Optional getAppPackageCode() { + return appPackageCode; + } + + /** + * @return The updated attribute data of the ticket part. Only present for attribute update parts. + */ + @JsonProperty("updated_attribute_data") + public Optional getUpdatedAttributeData() { + return updatedAttributeData; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof TicketPart && equalTo((TicketPart) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(TicketPart other) { + return type.equals(other.type) + && id.equals(other.id) + && partType.equals(other.partType) + && body.equals(other.body) + && previousTicketState.equals(other.previousTicketState) + && ticketState.equals(other.ticketState) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && assignedTo.equals(other.assignedTo) + && author.equals(other.author) + && attachments.equals(other.attachments) + && externalId.equals(other.externalId) + && redacted.equals(other.redacted) + && appPackageCode.equals(other.appPackageCode) + && updatedAttributeData.equals(other.updatedAttributeData); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.partType, + this.body, + this.previousTicketState, + this.ticketState, + this.createdAt, + this.updatedAt, + this.assignedTo, + this.author, + this.attachments, + this.externalId, + this.redacted, + this.appPackageCode, + this.updatedAttributeData); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional partType = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional previousTicketState = Optional.empty(); + + private Optional ticketState = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional assignedTo = Optional.empty(); + + private Optional author = Optional.empty(); + + private Optional> attachments = Optional.empty(); + + private Optional externalId = Optional.empty(); + + private Optional redacted = Optional.empty(); + + private Optional appPackageCode = Optional.empty(); + + private Optional updatedAttributeData = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(TicketPart other) { + type(other.getType()); + id(other.getId()); + partType(other.getPartType()); + body(other.getBody()); + previousTicketState(other.getPreviousTicketState()); + ticketState(other.getTicketState()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + assignedTo(other.getAssignedTo()); + author(other.getAuthor()); + attachments(other.getAttachments()); + externalId(other.getExternalId()); + redacted(other.getRedacted()); + appPackageCode(other.getAppPackageCode()); + updatedAttributeData(other.getUpdatedAttributeData()); + return this; + } + + /** + *

Always ticket_part

+ */ + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

The id representing the ticket part.

+ */ + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + /** + *

The type of ticket part.

+ */ + @JsonSetter(value = "part_type", nulls = Nulls.SKIP) + public Builder partType(Optional partType) { + this.partType = partType; + return this; + } + + public Builder partType(String partType) { + this.partType = Optional.ofNullable(partType); + return this; + } + + /** + *

The message body, which may contain HTML.

+ */ + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; + return this; + } + + public Builder body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + /** + *

The previous state of the ticket.

+ */ + @JsonSetter(value = "previous_ticket_state", nulls = Nulls.SKIP) + public Builder previousTicketState(Optional previousTicketState) { + this.previousTicketState = previousTicketState; + return this; + } + + public Builder previousTicketState(PreviousTicketState previousTicketState) { + this.previousTicketState = Optional.ofNullable(previousTicketState); + return this; + } + + /** + *

The state of the ticket.

+ */ + @JsonSetter(value = "ticket_state", nulls = Nulls.SKIP) + public Builder ticketState(Optional ticketState) { + this.ticketState = ticketState; + return this; + } + + public Builder ticketState(TicketState ticketState) { + this.ticketState = Optional.ofNullable(ticketState); + return this; + } + + /** + *

The time the ticket part was created.

+ */ + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + /** + *

The last time the ticket part was updated.

+ */ + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.)

+ */ + @JsonSetter(value = "assigned_to", nulls = Nulls.SKIP) + public Builder assignedTo(Optional assignedTo) { + this.assignedTo = assignedTo; + return this; + } + + public Builder assignedTo(Reference assignedTo) { + this.assignedTo = Optional.ofNullable(assignedTo); + return this; + } + + @JsonSetter(value = "author", nulls = Nulls.SKIP) + public Builder author(Optional author) { + this.author = author; + return this; + } + + public Builder author(TicketPartAuthor author) { + this.author = Optional.ofNullable(author); + return this; + } + + /** + *

A list of attachments for the part.

+ */ + @JsonSetter(value = "attachments", nulls = Nulls.SKIP) + public Builder attachments(Optional> attachments) { + this.attachments = attachments; + return this; + } + + public Builder attachments(List attachments) { + this.attachments = Optional.ofNullable(attachments); + return this; + } + + /** + *

The external id of the ticket part

+ */ + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } + + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } + + /** + *

Whether or not the ticket part has been redacted.

+ */ + @JsonSetter(value = "redacted", nulls = Nulls.SKIP) + public Builder redacted(Optional redacted) { + this.redacted = redacted; + return this; + } + + public Builder redacted(Boolean redacted) { + this.redacted = Optional.ofNullable(redacted); + return this; + } + + /** + *

The app package code if this part was created via API. Note this field won't show if the part was not created via API.

+ */ + @JsonSetter(value = "app_package_code", nulls = Nulls.SKIP) + public Builder appPackageCode(Optional appPackageCode) { + this.appPackageCode = appPackageCode; + return this; + } + + public Builder appPackageCode(String appPackageCode) { + this.appPackageCode = Optional.ofNullable(appPackageCode); + return this; + } + + /** + *

The updated attribute data of the ticket part. Only present for attribute update parts.

+ */ + @JsonSetter(value = "updated_attribute_data", nulls = Nulls.SKIP) + public Builder updatedAttributeData(Optional updatedAttributeData) { + this.updatedAttributeData = updatedAttributeData; + return this; + } + + public Builder updatedAttributeData(UpdatedAttributeData updatedAttributeData) { + this.updatedAttributeData = Optional.ofNullable(updatedAttributeData); + return this; + } + + public TicketPart build() { + return new TicketPart( + type, + id, + partType, + body, + previousTicketState, + ticketState, + createdAt, + updatedAt, + assignedTo, + author, + attachments, + externalId, + redacted, + appPackageCode, + updatedAttributeData, + additionalProperties); + } + } + + public static final class TicketState { + public static final TicketState IN_PROGRESS = new TicketState(Value.IN_PROGRESS, "in_progress"); + + public static final TicketState SUBMITTED = new TicketState(Value.SUBMITTED, "submitted"); + + public static final TicketState RESOLVED = new TicketState(Value.RESOLVED, "resolved"); + + public static final TicketState WAITING_ON_CUSTOMER = + new TicketState(Value.WAITING_ON_CUSTOMER, "waiting_on_customer"); + + private final Value value; + + private final String string; + + TicketState(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof TicketState && this.string.equals(((TicketState) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case IN_PROGRESS: + return visitor.visitInProgress(); + case SUBMITTED: + return visitor.visitSubmitted(); + case RESOLVED: + return visitor.visitResolved(); + case WAITING_ON_CUSTOMER: + return visitor.visitWaitingOnCustomer(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static TicketState valueOf(String value) { + switch (value) { + case "in_progress": + return IN_PROGRESS; + case "submitted": + return SUBMITTED; + case "resolved": + return RESOLVED; + case "waiting_on_customer": + return WAITING_ON_CUSTOMER; + default: + return new TicketState(Value.UNKNOWN, value); + } + } + + public enum Value { + SUBMITTED, + + IN_PROGRESS, + + WAITING_ON_CUSTOMER, + + RESOLVED, + + UNKNOWN + } + + public interface Visitor { + T visitSubmitted(); + + T visitInProgress(); + + T visitWaitingOnCustomer(); + + T visitResolved(); + + T visitUnknown(String unknownType); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = UpdatedAttributeData.Builder.class) + public static final class UpdatedAttributeData { + private final Attribute attribute; + + private final Value value; + + private final Map additionalProperties; + + private UpdatedAttributeData(Attribute attribute, Value value, Map additionalProperties) { + this.attribute = attribute; + this.value = value; + this.additionalProperties = additionalProperties; + } + + /** + * @return Information about the attribute that was updated. + */ + @JsonProperty("attribute") + public Attribute getAttribute() { + return attribute; + } + + /** + * @return The new value of the attribute. + */ + @JsonProperty("value") + public Value getValue() { + return value; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdatedAttributeData && equalTo((UpdatedAttributeData) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdatedAttributeData other) { + return attribute.equals(other.attribute) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.attribute, this.value); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static AttributeStage builder() { + return new Builder(); + } + + public interface AttributeStage { + /** + * Information about the attribute that was updated. + */ + ValueStage attribute(@NotNull Attribute attribute); + + Builder from(UpdatedAttributeData other); + } + + public interface ValueStage { + /** + * The new value of the attribute. + */ + _FinalStage value(@NotNull Value value); + } + + public interface _FinalStage { + UpdatedAttributeData build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements AttributeStage, ValueStage, _FinalStage { + private Attribute attribute; + + private Value value; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdatedAttributeData other) { + attribute(other.getAttribute()); + value(other.getValue()); + return this; + } + + /** + * Information about the attribute that was updated.

Information about the attribute that was updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("attribute") + public ValueStage attribute(@NotNull Attribute attribute) { + this.attribute = Objects.requireNonNull(attribute, "attribute must not be null"); + return this; + } + + /** + * The new value of the attribute.

The new value of the attribute.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("value") + public _FinalStage value(@NotNull Value value) { + this.value = Objects.requireNonNull(value, "value must not be null"); + return this; + } + + @java.lang.Override + public UpdatedAttributeData build() { + return new UpdatedAttributeData(attribute, value, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Value.Builder.class) + public static final class Value { + private final Id id; + + private final Label label; + + private final Map additionalProperties; + + private Value(Id id, Label label, Map additionalProperties) { + this.id = id; + this.label = label; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object. Always 'value'. + */ + @JsonProperty("type") + public String getType() { + return "value"; + } + + @JsonProperty("id") + public Id getId() { + return id; + } + + @JsonProperty("label") + public Label getLabel() { + return label; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Value && equalTo((Value) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Value other) { + return id.equals(other.id) && label.equals(other.label); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.label); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + LabelStage id(@NotNull Id id); + + Builder from(Value other); + } + + public interface LabelStage { + _FinalStage label(@NotNull Label label); + } + + public interface _FinalStage { + Value build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, LabelStage, _FinalStage { + private Id id; + + private Label label; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Value other) { + id(other.getId()); + label(other.getLabel()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public LabelStage id(@NotNull Id id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("label") + public _FinalStage label(@NotNull Label label) { + this.label = Objects.requireNonNull(label, "label must not be null"); + return this; + } + + @java.lang.Override + public Value build() { + return new Value(id, label, additionalProperties); + } + } + + @JsonDeserialize(using = Label.Deserializer.class) + public static final class Label { + private final Object value; + + private final int type; + + private Label(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + 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 Label && equalTo((Label) other); + } + + private boolean equalTo(Label 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 Label of(String value) { + return new Label(value, 0); + } + + public static Label of(List value) { + return new Label(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(List value); + } + + static final class Deserializer extends StdDeserializer