diff --git a/.fern/metadata.json b/.fern/metadata.json new file mode 100644 index 0000000..757181e --- /dev/null +++ b/.fern/metadata.json @@ -0,0 +1,12 @@ +{ + "cliVersion": "3.0.2", + "generatorName": "fernapi/fern-java-sdk", + "generatorVersion": "3.21.0", + "generatorConfig": { + "enable-inline-types": true, + "client-class-name": "Intercom", + "inline-path-parameters": true, + "enable-forward-compatible-enums": true, + "enable-wire-tests": false + } +} \ No newline at end of file diff --git a/.github/workflows/label-ai-generated-prs.yml b/.github/workflows/label-ai-generated-prs.yml deleted file mode 100644 index 547cbfe..0000000 --- a/.github/workflows/label-ai-generated-prs.yml +++ /dev/null @@ -1,11 +0,0 @@ -# .github/workflows/label-ai-generated-prs.yml -name: Label AI-generated PRs - -on: - pull_request: - types: [opened, edited, synchronize] # run when the body changes too - -jobs: - call-label-ai-prs: - uses: intercom/github-action-workflows/.github/workflows/label-ai-prs.yml@main - secrets: inherit \ No newline at end of file diff --git a/README.md b/README.md index f50483c..019e098 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,53 @@ # Intercom Java Library [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fintercom%2Fintercom-java) +[![Maven Central](https://img.shields.io/maven-central/v/io.intercom/intercom-java)](https://central.sonatype.com/artifact/io.intercom/intercom-java) -The Intercom Java library provides convenient access to the Intercom API from Java. +The Intercom Java library provides convenient access to the Intercom APIs from Java. + +## Table of Contents + +- [Installation](#installation) +- [Reference](#reference) +- [Usage](#usage) +- [Environments](#environments) +- [Base Url](#base-url) +- [Exception Handling](#exception-handling) +- [Advanced](#advanced) + - [Custom Client](#custom-client) + - [Retries](#retries) + - [Timeouts](#timeouts) + - [Custom Headers](#custom-headers) + - [Access Raw Response Data](#access-raw-response-data) +- [Contributing](#contributing) + +## Installation + +### Gradle + +Add the dependency in your `build.gradle` file: + +```groovy +dependencies { + implementation 'io.intercom:intercom-java' +} +``` + +### Maven + +Add the dependency in your `pom.xml` file: + +```xml + + io.intercom + intercom-java + 4.0.0 + +``` + +## Reference + +A full reference for this library is available [here](https://github.com/intercom/intercom-java/blob/HEAD/./reference.md). ## Usage @@ -12,8 +57,7 @@ Instantiate and use the client with the following: package com.example.usage; import com.intercom.api.Intercom; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; -import com.intercom.api.resources.articles.types.CreateArticleRequestState; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; public class Example { public static void main(String[] args) { @@ -22,14 +66,10 @@ public class Example { .token("") .build(); - client.articles().create( - CreateArticleRequest + client.aiContent().createContentImportSource( + CreateContentImportSourceRequest .builder() - .title("Thanks for everything") - .authorId(1295) - .description("Description of the Article") - .body("Body of the Article") - .state(CreateArticleRequestState.PUBLISHED) + .url("https://www.example.com") .build() ); } @@ -70,9 +110,9 @@ When the API returns a non-success status code (4xx or 5xx response), an API exc ```java import com.intercom.api.core.IntercomApiApiException; -try { - client.articles().create(...); -} catch (IntercomApiApiException e) { +try{ + client.aiContent().createContentImportSource(...); +} catch (IntercomApiApiException e){ // Do something with the API exception... } ``` @@ -81,7 +121,7 @@ try { ### Custom Client -This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one. +This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one. However, you can pass your own client like so: ```java @@ -100,7 +140,9 @@ Intercom client = Intercom The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured -retry limit (default: 2). +retry limit (default: 2). Before defaulting to exponential backoff, the SDK will first attempt to respect +the `Retry-After` header (as either in seconds or as an HTTP date), and then the `X-RateLimit-Reset` header +(as a Unix timestamp in epoch seconds); failing both of those, it will fall back to exponential backoff. A request is deemed retryable when any of the following HTTP status codes is returned: @@ -134,7 +176,7 @@ Intercom client = Intercom .build(); // Request level -client.articles().create( +client.aiContent().createContentImportSource( ..., RequestOptions .builder() @@ -143,6 +185,45 @@ client.articles().create( ); ``` +### Custom Headers + +The SDK allows you to add custom headers to requests. You can configure headers at the client level or at the request level. + +```java +import com.intercom.api.Intercom; +import com.intercom.api.core.RequestOptions; + +// Client level +Intercom client = Intercom + .builder() + .addHeader("X-Custom-Header", "custom-value") + .addHeader("X-Request-Id", "abc-123") + .build(); +; + +// Request level +client.aiContent().createContentImportSource( + ..., + RequestOptions + .builder() + .addHeader("X-Request-Header", "request-value") + .build() +); +``` + +### Access Raw Response Data + +The SDK provides access to raw response data, including headers, through the `withRawResponse()` method. +The `withRawResponse()` method returns a raw client that wraps all responses with `body()` and `headers()` methods. +(A normal client's `response` is identical to a raw client's `response.body()`.) + +```java +CreateContentImportSourceHttpResponse response = client.aiContent().withRawResponse().createContentImportSource(...); + +System.out.println(response.body()); +System.out.println(response.headers().get("X-My-Header")); +``` + ## Contributing While we value open-source contributions to this SDK, this library is generated programmatically. diff --git a/build.gradle b/build.gradle index c4409ab..234ac1a 100644 --- a/build.gradle +++ b/build.gradle @@ -14,12 +14,13 @@ repositories { } dependencies { - api 'com.squareup.okhttp3:okhttp:4.12.0' - api 'com.fasterxml.jackson.core:jackson-databind:2.17.2' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2' + api 'com.squareup.okhttp3:okhttp:5.2.1' + api 'com.fasterxml.jackson.core:jackson-databind:2.18.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2' } @@ -46,7 +47,7 @@ java { group = 'io.intercom' -version = '3.0.0' +version = '4.0.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -77,7 +78,7 @@ publishing { maven(MavenPublication) { groupId = 'io.intercom' artifactId = 'intercom-java' - version = '3.0.0' + version = '4.0.0' from components.java pom { name = 'intercom' @@ -121,9 +122,10 @@ sonatypeCentralUpload { } signing { - def signingKeyId = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" + def signingKeyId = "$System.env.MAVEN_SIGNATURE_KID" + def signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" def signingPassword = "$System.env.MAVEN_SIGNATURE_PASSWORD" - useInMemoryPgpKeys(signingKeyId, signingPassword) + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) sign publishing.publications.maven } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 002b867..d4081da 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.14.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..9c14666 --- /dev/null +++ b/reference.md @@ -0,0 +1,21759 @@ +# Reference +## Admins +
client.admins.identify() -> Optional<AdminWithApp> +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().identify(); +``` +
+
+
+
+ + +
+
+
+ +
client.admins.away(adminId, request) -> Optional<Admin> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can set an Admin as away for the Inbox. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().away( + ConfigureAwayAdminRequest + .builder() + .adminId(1) + .awayModeEnabled(true) + .awayModeReassign(true) + .awayStatusReasonId(12345) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**adminId:** `Integer` — The unique identifier of a given admin + +
+
+ +
+
+ +**awayModeEnabled:** `Boolean` — Set to "true" to change the status of the admin to away. + +
+
+ +
+
+ +**awayModeReassign:** `Boolean` — Set to "true" to assign any new conversation replies to your default inbox. + +
+
+ +
+
+ +**awayStatusReasonId:** `Optional` — The unique identifier of the away status reason + +
+
+
+
+ + +
+
+
+ +
client.admins.listAllActivityLogs() -> ActivityLogList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a log of activities by all admins in an app. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().listAllActivityLogs( + ListAllActivityLogsRequest + .builder() + .createdAtAfter("1677253093") + .createdAtBefore("1677861493") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**createdAtAfter:** `String` — The start date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+ +
+
+ +**createdAtBefore:** `Optional` — The end date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+
+
+ + +
+
+
+ +
client.admins.list() -> AdminList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of admins for a given workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.admins.find(adminId) -> Optional<Admin> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve the details of a single admin. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().find( + FindAdminRequest + .builder() + .adminId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**adminId:** `Integer` — The unique identifier of a given admin + +
+
+
+
+ + +
+
+
+ +## AI Content +
client.aiContent.listContentImportSources() -> ContentImportSourcesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all content import sources for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().listContentImportSources(); +``` +
+
+
+
+ + +
+
+
+ +
client.aiContent.createContentImportSource(request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new content import source by sending a POST request to this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().createContentImportSource( + CreateContentImportSourceRequest + .builder() + .url("https://www.example.com") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**syncBehavior:** `String` — If you intend to create or update External Pages via the API, this should be set to `api`. + +
+
+ +
+
+ +**status:** `Optional` — The status of the content import source. + +
+
+ +
+
+ +**url:** `String` — The URL of the content import source. + +
+
+
+
+ + +
+
+
+ +
client.aiContent.getContentImportSource(sourceId) -> ContentImportSource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().getContentImportSource( + GetContentImportSourceRequest + .builder() + .sourceId("source_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**sourceId:** `String` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.aiContent.updateContentImportSource(sourceId, request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing content import source. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().updateContentImportSource( + UpdateContentImportSourceRequest + .builder() + .sourceId("source_id") + .syncBehavior(UpdateContentImportSourceRequestSyncBehavior.API) + .url("https://www.example.com") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**sourceId:** `String` — The unique identifier for the content import source which is given by Intercom. + +
+
+ +
+
+ +**syncBehavior:** `UpdateContentImportSourceRequestSyncBehavior` — 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. + +
+
+ +
+
+ +**status:** `Optional` — The status of the content import source. + +
+
+ +
+
+ +**url:** `String` — The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + +
+
+
+
+ + +
+
+
+ +
client.aiContent.deleteContentImportSource(sourceId) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().deleteContentImportSource( + DeleteContentImportSourceRequest + .builder() + .sourceId("source_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**sourceId:** `String` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.aiContent.listExternalPages() -> ExternalPagesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all external pages for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().listExternalPages(); +``` +
+
+
+
+ + +
+
+
+ +
client.aiContent.createExternalPage(request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().createExternalPage( + CreateExternalPageRequest + .builder() + .title("Test") + .html("

Test

") + .sourceId(44) + .externalId("abc1234") + .url("https://www.example.com") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**title:** `String` — The title of the external page. + +
+
+ +
+
+ +**html:** `String` — The body of the external page in HTML. + +
+
+ +
+
+ +**url:** `Optional` — 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. + +
+
+ +
+
+ +**aiAgentAvailability:** `Optional` — Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page. + +
+
+ +
+
+ +**aiCopilotAvailability:** `Optional` — Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. + +
+
+ +
+
+ +**locale:** `String` — Always en + +
+
+ +
+
+ +**sourceId:** `Integer` — 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. + +
+
+ +
+
+ +**externalId:** `String` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
client.aiContent.getExternalPage(pageId) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve an external page. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().getExternalPage( + GetExternalPageRequest + .builder() + .pageId("page_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**pageId:** `String` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.aiContent.updateExternalPage(pageId, request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing external page (if it was created via the API). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().updateExternalPage( + UpdateExternalPageRequest + .builder() + .pageId("page_id") + .title("Test") + .html("

Test

") + .url("https://www.example.com") + .sourceId(47) + .externalId("5678") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**pageId:** `String` — The unique identifier for the external page which is given by Intercom. + +
+
+ +
+
+ +**title:** `String` — The title of the external page. + +
+
+ +
+
+ +**html:** `String` — The body of the external page in HTML. + +
+
+ +
+
+ +**url:** `String` — The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + +
+
+ +
+
+ +**finAvailability:** `Optional` — Whether the external page should be used to answer questions by Fin. + +
+
+ +
+
+ +**locale:** `String` — Always en + +
+
+ +
+
+ +**sourceId:** `Integer` — 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. + +
+
+ +
+
+ +**externalId:** `Optional` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
client.aiContent.deleteExternalPage(pageId) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().deleteExternalPage( + DeleteExternalPageRequest + .builder() + .pageId("page_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**pageId:** `String` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Articles +
client.articles.list() -> SyncPagingIterable<ArticleListItem> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().list( + ListArticlesRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
client.articles.create(request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new article by making a POST request to `https://api.intercom.io/articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().create( + Optional.of( + CreateArticleRequest + .builder() + .title("Thanks for everything") + .authorId(991267497) + .description("Description of the Article") + .body("Body of the Article") + .state(CreateArticleRequestState.PUBLISHED) + .parentId(145) + .parentType(CreateArticleRequestParentType.COLLECTION) + .translatedContent( + ArticleTranslatedContent + .builder() + .fr( + ArticleContent + .builder() + .title("Merci pour tout") + .description("Description de l'article") + .body("Corps de l'article") + .authorId(991267497) + .state(ArticleContentState.PUBLISHED) + .build() + ) + .build() + ) + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.articles.find(articleId) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().find( + FindArticleRequest + .builder() + .articleId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**articleId:** `Integer` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.articles.update(articleId, request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().update( + UpdateArticleRequest + .builder() + .articleId(1) + .title("Christmas is here!") + .body("

New gifts in store for the jolly season

") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**articleId:** `Integer` — The unique identifier for the article which is given by Intercom. + +
+
+ +
+
+ +**title:** `Optional` — The title of the article.For multilingual articles, this will be the title of the default language's content. + +
+
+ +
+
+ +**description:** `Optional` — The description of the article. For multilingual articles, this will be the description of the default language's content. + +
+
+ +
+
+ +**body:** `Optional` — The content of the article. For multilingual articles, this will be the body of the default language's content. + +
+
+ +
+
+ +**authorId:** `Optional` — 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. + +
+
+ +
+
+ +**state:** `Optional` — 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. + +
+
+ +
+
+ +**parentId:** `Optional` — The id of the article's parent collection or section. An article without this field stands alone. + +
+
+ +
+
+ +**parentType:** `Optional` — The type of parent, which can either be a `collection` or `section`. + +
+
+ +
+
+ +**translatedContent:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.articles.delete(articleId) -> DeletedArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().delete( + DeleteArticleRequest + .builder() + .articleId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**articleId:** `Integer` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.articles.search() -> ArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().search( + SearchArticlesRequest + .builder() + .phrase("Getting started") + .state("published") + .helpCenterId(1) + .highlight(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**phrase:** `Optional` — The phrase within your articles to search for. + +
+
+ +
+
+ +**state:** `Optional` — The state of the Articles returned. One of `published`, `draft` or `all`. + +
+
+ +
+
+ +**helpCenterId:** `Optional` — The ID of the Help Center to search in. + +
+
+ +
+
+ +**highlight:** `Optional` — Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. + +
+
+
+
+ + +
+
+
+ +## Away Status Reasons +
client.awayStatusReasons.listAwayStatusReasons() -> List<AwayStatusReason> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of all away status reasons configured for the workspace, including deleted ones. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.awayStatusReasons().listAwayStatusReasons(); +``` +
+
+
+
+ + +
+
+
+ +## Export +
client.export.enqueueANewReportingDataExportJob(request) -> PostExportReportingDataEnqueueResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.export().enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest + .builder() + .datasetId("conversation") + .startTime(1717490000L) + .endTime(1717510000L) + .attributeIds( + Arrays.asList("conversation_id", "conversation_started_at") + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` + +
+
+ +
+
+ +**attributeIds:** `List` + +
+
+ +
+
+ +**startTime:** `Long` + +
+
+ +
+
+ +**endTime:** `Long` + +
+
+
+
+ + +
+
+
+ +
client.export.listAvailableDatasetsAndAttributes() -> GetExportReportingDataGetDatasetsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.export().listAvailableDatasetsAndAttributes(); +``` +
+
+
+
+ + +
+
+
+ +## Data Export +
client.dataExport.exportReportingData(jobIdentifier) -> DataExportExportReportingDataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().exportReportingData( + ExportReportingDataRequest + .builder() + .jobIdentifier("job_identifier") + .appId("app_id") + .clientId("client_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` — Unique identifier of the job. + +
+
+ +
+
+ +**appId:** `String` — The Intercom defined code of the workspace the company is associated to. + +
+
+ +
+
+ +**clientId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.dataExport.downloadReportingDataExport(jobIdentifier) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Download the data from a completed reporting data export job. + +> Octet header required +> +> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().downloadReportingDataExport( + DownloadReportingDataExportRequest + .builder() + .jobIdentifier("job_identifier") + .appId("app_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` + +
+
+ +
+
+ +**appId:** `String` + +
+
+ +
+
+ +**accept:** `String` — Required header for downloading the export file + +
+
+
+
+ + +
+
+
+ +
client.dataExport.create(request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().create( + CreateDataExportRequest + .builder() + .createdAtAfter(1734519776) + .createdAtBefore(1734537776) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**createdAtAfter:** `Integer` — The start date that you request data for. It must be formatted as a unix timestamp. + +
+
+ +
+
+ +**createdAtBefore:** `Integer` — The end date that you request data for. It must be formatted as a unix timestamp. + +
+
+
+
+ + +
+
+
+ +
client.dataExport.find(jobIdentifier) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().find( + FindDataExportRequest + .builder() + .jobIdentifier("job_identifier") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` — job_identifier + +
+
+
+
+ + +
+
+
+ +
client.dataExport.cancel(jobIdentifier) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can cancel your job +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().cancel( + CancelDataExportRequest + .builder() + .jobIdentifier("job_identifier") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` — job_identifier + +
+
+
+
+ + +
+
+
+ +
client.dataExport.download(jobIdentifier) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().download( + DownloadDataExportRequest + .builder() + .jobIdentifier("job_identifier") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` — job_identifier + +
+
+
+
+ + +
+
+
+ +## HelpCenters +
client.helpCenters.find(helpCenterId) -> HelpCenter +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().find( + FindHelpCenterRequest + .builder() + .helpCenterId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**helpCenterId:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.helpCenters.list() -> SyncPagingIterable<HelpCenter> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().list( + ListHelpCentersRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +## Internal Articles +
client.internalArticles.listInternalArticles() -> InternalArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().listInternalArticles(); +``` +
+
+
+
+ + +
+
+
+ +
client.internalArticles.createInternalArticle(request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().createInternalArticle( + Optional.of( + CreateInternalArticleRequest + .builder() + .title("Thanks for everything") + .authorId(991266252) + .ownerId(991266252) + .body("Body of the Article") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.internalArticles.retrieveInternalArticle(internalArticleId) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().retrieveInternalArticle( + RetrieveInternalArticleRequest + .builder() + .internalArticleId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**internalArticleId:** `Integer` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.internalArticles.updateInternalArticle(internalArticleId, request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().updateInternalArticle( + UpdateInternalArticleRequestBody + .builder() + .internalArticleId(1) + .title("Christmas is here!") + .body("

New gifts in store for the jolly season

") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**internalArticleId:** `Integer` — The unique identifier for the internal article which is given by Intercom. + +
+
+ +
+
+ +**title:** `Optional` — The title of the article. + +
+
+ +
+
+ +**body:** `Optional` — The content of the article. + +
+
+ +
+
+ +**authorId:** `Optional` — The id of the author of the article. + +
+
+ +
+
+ +**ownerId:** `Optional` — The id of the author of the article. + +
+
+
+
+ + +
+
+
+ +
client.internalArticles.deleteInternalArticle(internalArticleId) -> DeletedInternalArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().deleteInternalArticle( + DeleteInternalArticleRequest + .builder() + .internalArticleId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**internalArticleId:** `Integer` — The unique identifier for the internal article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.internalArticles.searchInternalArticles() -> InternalArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().searchInternalArticles( + SearchInternalArticlesRequest + .builder() + .folderId("folder_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**folderId:** `Optional` — The ID of the folder to search in. + +
+
+
+
+ + +
+
+
+ +## Companies +
client.companies.retrieve() -> CompaniesRetrieveResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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}` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().retrieve( + RetrieveCompanyRequest + .builder() + .name("my company") + .companyId("12345") + .tagId("678910") + .segmentId("98765") + .page(1) + .perPage(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `Optional` — The `name` of the company to filter by. + +
+
+ +
+
+ +**companyId:** `Optional` — The `company_id` of the company to filter by. + +
+
+ +
+
+ +**tagId:** `Optional` — The `tag_id` of the company to filter by. + +
+
+ +
+
+ +**segmentId:** `Optional` — The `segment_id` of the company to filter by. + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
client.companies.createOrUpdate(request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().createOrUpdate( + Optional.of( + CreateOrUpdateCompanyRequest + .builder() + .name("my company") + .companyId("company_remote_id") + .remoteCreatedAt(1374138000) + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.companies.find(companyId) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().find( + FindCompanyRequest + .builder() + .companyId("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.companies.update(companyId, request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().update( + UpdateCompanyRequest + .builder() + .companyId("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .body( + UpdateCompanyRequestBody + .builder() + .name("my company") + .website("http://www.mycompany.com/") + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.companies.delete(companyId) -> DeletedCompanyObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().delete( + DeleteCompanyRequest + .builder() + .companyId("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.companies.listAttachedContacts(companyId) -> CompanyAttachedContacts +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listAttachedContacts( + ListAttachedContactsRequest + .builder() + .companyId("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.companies.listAttachedSegments(companyId) -> CompanyAttachedSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().listAttachedSegments( + ListSegmentsAttachedToCompanyRequest + .builder() + .companyId("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.companies.list() -> SyncPagingIterable<Company> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/reference#iterating-over-all-companies). +{% 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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().list( + ListCompaniesRequest + .builder() + .page(1) + .perPage(1) + .order("desc") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to return per page. Defaults to 15 + +
+
+ +
+
+ +**order:** `Optional` — `asc` or `desc`. Return the companies in ascending or descending order. Defaults to desc + +
+
+
+
+ + +
+
+
+ +
client.companies.scroll() -> SyncPagingIterable<Company> +
+
+ +#### 📝 Description + +
+
+ +
+
+ + 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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().scroll( + ScrollCompaniesRequest + .builder() + .scrollParam("scroll_param") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**scrollParam:** `Optional` — + +
+
+
+
+ + +
+
+
+ +
client.companies.attachContact(contactId, request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can attach a company to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().attachContact( + AttachContactToCompanyRequest + .builder() + .contactId("contact_id") + .companyId("6762f09a1bb69f9f2193bb34") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.companies.detachContact(contactId, companyId) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can detach a company from a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().detachContact( + DetachContactFromCompanyRequest + .builder() + .contactId("58a430d35458202d41b1e65b") + .companyId("58a430d35458202d41b1e65b") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Contacts +
client.contacts.listAttachedCompanies(contactId) -> SyncPagingIterable<Company> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of companies that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().listAttachedCompanies( + ListAttachedCompaniesRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .page(1) + .perPage(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
client.contacts.listAttachedSegments(contactId) -> ContactSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of segments that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().listAttachedSegments( + ListSegmentsAttachedToContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.contacts.listAttachedSubscriptions(contactId) -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().listAttachedSubscriptions( + ListAttachedSubscriptionsRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.contacts.attachSubscription(contactId, request) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().attachSubscription( + AttachSubscriptionToContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .subscriptionId("37846") + .consentType("opt_in") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**subscriptionId:** `String` — The unique identifier for the subscription which is given by Intercom + +
+
+ +
+
+ +**consentType:** `String` — The consent_type of a subscription, opt_out or opt_in. + +
+
+
+
+ + +
+
+
+ +
client.contacts.detachSubscription(contactId, subscriptionId) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().detachSubscription( + DetachSubscriptionFromContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .subscriptionId("37846") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**subscriptionId:** `String` — The unique identifier for the subscription type which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.contacts.listAttachedTags(contactId) -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags that are attached to a specific contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().listAttachedTags( + ListTagsAttachedToContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.contacts.find(contactId) -> ContactsFindResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().find( + FindContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — contact_id + +
+
+
+
+ + +
+
+
+ +
client.contacts.update(contactId, request) -> ContactsUpdateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().update( + UpdateContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .email("joebloggs@intercom.io") + .name("joe bloggs") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — id + +
+
+ +
+
+ +**role:** `Optional` — The role of the contact. + +
+
+ +
+
+ +**externalId:** `Optional` — A unique identifier for the contact which is given to Intercom + +
+
+ +
+
+ +**email:** `Optional` — The contacts email + +
+
+ +
+
+ +**phone:** `Optional` — The contacts phone + +
+
+ +
+
+ +**name:** `Optional` — The contacts name + +
+
+ +
+
+ +**avatar:** `Optional` — An image URL containing the avatar of a contact + +
+
+ +
+
+ +**signedUpAt:** `Optional` — The time specified for when a contact signed up + +
+
+ +
+
+ +**lastSeenAt:** `Optional` — The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) + +
+
+ +
+
+ +**ownerId:** `Optional` — The id of an admin that has been assigned account ownership of the contact + +
+
+ +
+
+ +**unsubscribedFromEmails:** `Optional` — Whether the contact is unsubscribed from emails + +
+
+ +
+
+ +**customAttributes:** `Optional>` — The custom attributes which are set for the contact + +
+
+
+
+ + +
+
+
+ +
client.contacts.delete(contactId) -> ContactDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().delete( + DeleteContactRequest + .builder() + .contactId("contact_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — contact_id + +
+
+
+
+ + +
+
+
+ +
client.contacts.mergeLeadInUser(request) -> ContactsMergeLeadInUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().mergeLeadInUser( + MergeContactsRequest + .builder() + .leadId("6762f0d51bb69f9f2193bb7f") + .contactId("6762f0d51bb69f9f2193bb80") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**leadId:** `Optional` — The unique identifier for the contact to merge away from. Must be a lead. + +
+
+ +
+
+ +**contactId:** `Optional` — The unique identifier for the contact to merge into. Must be a user. + +
+
+
+
+ + +
+
+
+ +
client.contacts.search(request) -> SyncPagingIterable<Contact> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) 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
Accepts user or lead | +| name | String | +| avatar | String | +| owner_id | Integer | +| email | String | +| email_domain | String | +| 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
Shortcut for `OR` queries
Values must be in Array | +| NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Date (UNIX Timestamp) | Greater than | +| < | Integer
Date (UNIX Timestamp) | Lower than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().searchContacts( + SearchRequest + .builder() + .query( + SearchRequestQuery.of( + SingleFilterSearchRequest + .builder() + .value( + SingleFilterSearchRequestValue.of() + ) + .build() + ) + ) + .pagination( + StartingAfterPaging + .builder() + .perPage(5) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
client.contacts.list() -> SyncPagingIterable<Contact> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().list( + ListContactsRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+ +
+
+ +**startingAfter:** `Optional` — String used to get the next page of conversations. + +
+
+
+
+ + +
+
+
+ +
client.contacts.create(request) -> ContactsCreateResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new contact (ie. user or lead). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().create( + CreateContactRequest.of( + CreateContactRequestWithEmail + .builder() + .email("joebloggs@intercom.io") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateContactRequest` + +
+
+
+
+ + +
+
+
+ +
client.contacts.showContactByExternalId(externalId) -> ShowContactByExternalIdResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().showContactByExternalId( + ShowContactByExternalIdRequest + .builder() + .externalId("cdd29344-5e0c-4ef0-ac56-f9ba2979bc27") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**externalId:** `String` — The external ID of the user that you want to retrieve + +
+
+
+
+ + +
+
+
+ +
client.contacts.archive(contactId) -> ContactArchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can archive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().archive( + ArchiveContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — contact_id + +
+
+
+
+ + +
+
+
+ +
client.contacts.unarchive(contactId) -> ContactUnarchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can unarchive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().unarchive( + UnarchiveContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — contact_id + +
+
+
+
+ + +
+
+
+ +
client.contacts.blockContact(contactId) -> ContactBlocked +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().blockContact( + BlockContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — contact_id + +
+
+
+
+ + +
+
+
+ +## Notes +
client.notes.list(contactId) -> SyncPagingIterable<Note> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of notes that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.notes().list( + ListContactNotesRequest + .builder() + .contactId("contact_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier of a contact. + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
client.notes.create(contactId, request) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a note to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.notes().create( + CreateContactNoteRequest + .builder() + .contactId("123") + .body("Hello") + .adminId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier of a given contact. + +
+
+ +
+
+ +**body:** `String` — The text of the note. + +
+
+ +
+
+ +**adminId:** `Optional` — The unique identifier of a given admin. + +
+
+
+
+ + +
+
+
+ +
client.notes.find(noteId) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single note. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.notes().find( + FindNoteRequest + .builder() + .noteId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**noteId:** `Integer` — The unique identifier of a given note + +
+
+
+
+ + +
+
+
+ +## Tags +
client.tags.tagContact(contactId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific contact. This will return a tag object for the tag that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().tagContact( + TagContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .tagId("7522907") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**tagId:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.tags.untagContact(contactId, tagId) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().untagContact( + UntagContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .tagId("7522907") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**tagId:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.tags.tagConversation(conversationId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().tagConversation( + TagConversationRequest + .builder() + .conversationId("64619700005694") + .tagId("7522907") + .adminId("780") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — conversation_id + +
+
+ +
+
+ +**tagId:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.tags.untagConversation(conversationId, tagId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().untagConversation( + UntagConversationRequest + .builder() + .conversationId("64619700005694") + .tagId("7522907") + .adminId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — conversation_id + +
+
+ +
+
+ +**tagId:** `String` — tag_id + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.tags.list() -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags for a given workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.tags.create(request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().create( + TagsCreateRequestBody.of( + CreateOrUpdateTagRequest + .builder() + .name("test") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `TagsCreateRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.tags.find(tagId) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of tags that are on the workspace by their id. +This will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().find( + FindTagRequest + .builder() + .tagId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**tagId:** `String` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
client.tags.delete(tagId) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete the details of tags that are on the workspace by passing in the id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().delete( + DeleteTagRequest + .builder() + .tagId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**tagId:** `String` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
client.tags.tagTicket(ticketId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().tagTicket( + TagTicketRequest + .builder() + .ticketId("64619700005694") + .tagId("7522907") + .adminId("780") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` — ticket_id + +
+
+ +
+
+ +**tagId:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.tags.untagTicket(ticketId, tagId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().untagTicket( + UntagTicketRequest + .builder() + .ticketId("64619700005694") + .tagId("7522907") + .adminId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` — ticket_id + +
+
+ +
+
+ +**tagId:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Conversations +
client.conversations.list() -> SyncPagingIterable<Conversation> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().list( + ListConversationsRequest + .builder() + .perPage(1) + .startingAfter("starting_after") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**perPage:** `Optional` — How many results per page + +
+
+ +
+
+ +**startingAfter:** `Optional` — String used to get the next page of conversations. + +
+
+
+
+ + +
+
+
+ +
client.conversations.create(request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().create( + CreateConversationRequest + .builder() + .from( + CreateConversationRequestFrom + .builder() + .type(CreateConversationRequestFromType.USER) + .id("6762f11b1bb69f9f2193bba3") + .build() + ) + .body("Hello there") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**from:** `CreateConversationRequestFrom` + +
+
+ +
+
+ +**body:** `String` — The content of the message. HTML is not supported. + +
+
+ +
+
+ +**createdAt:** `Optional` — 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. + +
+
+
+
+ + +
+
+
+ +
client.conversations.find(conversationId) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().find( + FindConversationRequest + .builder() + .conversationId("123") + .displayAs("plaintext") + .includeTranslations(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The id of the conversation to target + +
+
+ +
+
+ +**displayAs:** `Optional` — Set to plaintext to retrieve conversation messages in plain text. + +
+
+ +
+
+ +**includeTranslations:** `Optional` — If set to true, conversation parts will be translated to the detected language of the conversation. + +
+
+
+
+ + +
+
+
+ +
client.conversations.update(conversationId, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().update( + UpdateConversationRequest + .builder() + .conversationId("conversation_id") + .displayAs("plaintext") + .read(true) + .title("new conversation title") + .customAttributes( + new HashMap() {{ + put("issue_type", CustomAttributesValue.of("Billing")); + put("priority", CustomAttributesValue.of("High")); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The id of the conversation to target + +
+
+ +
+
+ +**displayAs:** `Optional` — Set to plaintext to retrieve conversation messages in plain text. + +
+
+ +
+
+ +**read:** `Optional` — Mark a conversation as read within Intercom. + +
+
+ +
+
+ +**title:** `Optional` — The title given to the conversation + +
+
+ +
+
+ +**customAttributes:** `Optional>` + +
+
+ +
+
+ +**companyId:** `Optional` — The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + +
+
+
+
+ + +
+
+
+ +
client.conversations.deleteConversation(conversationId) -> ConversationDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().deleteConversation( + DeleteConversationRequest + .builder() + .conversationId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `Integer` — id + +
+
+
+
+ + +
+
+
+ +
client.conversations.search(request) -> SyncPagingIterable<Conversation> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) 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
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 | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().searchConversations( + SearchRequest + .builder() + .query( + SearchRequestQuery.of( + SingleFilterSearchRequest + .builder() + .value( + SingleFilterSearchRequestValue.of() + ) + .build() + ) + ) + .pagination( + StartingAfterPaging + .builder() + .perPage(5) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
client.conversations.reply(conversationId, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().reply( + ReplyToConversationRequest + .builder() + .conversationId("123 or \"last\"") + .body( + ReplyConversationRequest.of( + ContactReplyConversationRequest.of( + ContactReplyIntercomUserIdRequest + .builder() + .messageType("comment") + .type("user") + .body("Thanks again :)") + .intercomUserId("6762f1571bb69f9f2193bbbb") + .build() + ) + ) + ) + .build() + ); + } +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + +
+
+ +
+
+ +**request:** `ReplyConversationRequest` + +
+
+
+
+ + +
+
+
+ +
client.conversations.manage(conversationId, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().manage( + ManageConversationPartsRequest + .builder() + .conversationId("123") + .body( + ConversationsManageRequestBody.close( + CloseConversationRequest + .builder() + .type("admin") + .adminId("12345") + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**request:** `ConversationsManageRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.conversations.attachContactAsAdmin(conversationId, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().attachContactAsAdmin( + AttachContactToConversationRequest + .builder() + .conversationId("123") + .adminId("12345") + .customer( + AttachContactToConversationRequestCustomer.of( + AttachContactToConversationRequestCustomerIntercomUserId + .builder() + .intercomUserId("6762f19b1bb69f9f2193bbd4") + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**adminId:** `Optional` — The `id` of the admin who is adding the new participant. + +
+
+ +
+
+ +**customer:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.conversations.detachContactAsAdmin(conversationId, contactId, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().detachContactAsAdmin( + DetachContactFromConversationRequest + .builder() + .conversationId("123") + .contactId("123") + .adminId("5017690") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**contactId:** `String` — The identifier for the contact as given by Intercom. + +
+
+ +
+
+ +**adminId:** `String` — The `id` of the admin who is performing the action. + +
+
+
+
+ + +
+
+
+ +
client.conversations.redactConversationPart(request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().redactConversationPart( + RedactConversationRequest.conversationPart( + RedactConversationRequestConversationPart + .builder() + .conversationId("19894788788") + .conversationPartId("19381789428") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `RedactConversationRequest` + +
+
+
+
+ + +
+
+
+ +
client.conversations.convertToTicket(conversationId, request) -> Optional<Ticket> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can convert a conversation to a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().convertToTicket( + ConvertConversationToTicketRequest + .builder() + .conversationId(1) + .ticketTypeId("53") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `Integer` — The id of the conversation to target + +
+
+ +
+
+ +**ticketTypeId:** `String` — The ID of the type of ticket you want to convert the conversation to + +
+
+ +
+
+ +**attributes:** `Optional>` + +
+
+
+
+ + +
+
+
+ +
client.conversations.runAssignmentRules(conversationId) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +{% admonition type="danger" name="Deprecation of Run Assignment Rules" %} +Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. +{% /admonition %} +You can let a conversation be automatically assigned following assignment rules. +{% admonition type="warning" name="When using workflows" %} +It is not possible to use this endpoint with Workflows. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().runAssignmentRules( + AutoAssignConversationRequest + .builder() + .conversationId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The identifier for the conversation as given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Custom Channel Events +
client.customChannelEvents.notifyNewConversation(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyNewConversation( + CustomChannelBaseEvent + .builder() + .eventId("event_id") + .externalConversationId("external_conversation_id") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("external_id") + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CustomChannelBaseEvent` + +
+
+
+
+ + +
+
+
+ +
client.customChannelEvents.notifyNewMessage(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyNewMessage( + NotifyNewMessageRequest + .builder() + .eventId("event_id") + .externalConversationId("external_conversation_id") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("external_id") + .build() + ) + .body("body") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**body:** `String` — The message content sent by the user. + +
+
+
+
+ + +
+
+
+ +
client.customChannelEvents.notifyQuickReplySelected(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyQuickReplySelected( + NotifyQuickReplySelectedRequest + .builder() + .eventId("evt_67890") + .externalConversationId("conv_13579") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("user_003") + .name("Alice Example") + .email("alice@example.com") + .build() + ) + .quickReplyOptionId("1234") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**quickReplyOptionId:** `String` — Id of the selected quick reply option. + +
+
+
+
+ + +
+
+
+ +
client.customChannelEvents.notifyAttributeCollected(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyAttributeCollected( + NotifyAttributeCollectedRequest + .builder() + .eventId("event_id") + .externalConversationId("external_conversation_id") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("external_id") + .build() + ) + .attribute( + CustomChannelAttribute + .builder() + .id("id") + .value("value") + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**attribute:** `CustomChannelAttribute` + +
+
+
+
+ + +
+
+
+ +## Custom Object Instances +
client.customObjectInstances.getCustomObjectInstancesByExternalId(customObjectTypeIdentifier) -> Optional<CustomObjectInstance> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .externalId("external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**externalId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.customObjectInstances.createCustomObjectInstances(customObjectTypeIdentifier, request) -> Optional<CustomObjectInstance> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create or update a custom object instance +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest + .builder() + .customObjectTypeIdentifier("Order") + .externalId("123") + .externalCreatedAt(1392036272) + .externalUpdatedAt(1392036272) + .customAttributes( + new HashMap>() {{ + put("order_number", Optional.of("ORDER-12345")); + put("total_amount", Optional.of("custom_attributes")); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**externalId:** `Optional` — A unique identifier for the Custom Object instance in the external system it originated from. + +
+
+ +
+
+ +**externalCreatedAt:** `Optional` — The time when the Custom Object instance was created in the external system it originated from. + +
+
+ +
+
+ +**externalUpdatedAt:** `Optional` — The time when the Custom Object instance was last updated in the external system it originated from. + +
+
+ +
+
+ +**customAttributes:** `Optional>>` — The custom attributes which are set for the Custom Object instance. + +
+
+
+
+ + +
+
+
+ +
client.customObjectInstances.deleteCustomObjectInstancesById(customObjectTypeIdentifier) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .externalId("external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**externalId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.customObjectInstances.getCustomObjectInstancesById(customObjectTypeIdentifier, customObjectInstanceId) -> Optional<CustomObjectInstance> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .customObjectInstanceId("custom_object_instance_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**customObjectInstanceId:** `String` — The id or external_id of the custom object instance + +
+
+
+
+ + +
+
+
+ +
client.customObjectInstances.deleteCustomObjectInstancesByExternalId(customObjectTypeIdentifier, customObjectInstanceId) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance using the Intercom defined id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .customObjectInstanceId("custom_object_instance_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**customObjectInstanceId:** `String` — The Intercom defined id of the custom object instance + +
+
+
+
+ + +
+
+
+ +## Data Attributes +
client.dataAttributes.list() -> DataAttributeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataAttributes().list( + ListDataAttributesRequest + .builder() + .model(DataAttributesListRequestModel.CONTACT) + .includeArchived(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**model:** `Optional` — Specify the data attribute model to return. + +
+
+ +
+
+ +**includeArchived:** `Optional` — Include archived attributes in the list. By default we return only non archived data attributes. + +
+
+
+
+ + +
+
+
+ +
client.dataAttributes.create(request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a data attributes for a `contact` or a `company`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataAttributes().create( + CreateDataAttributeRequest.of( + CreateDataAttributeRequestOptions + .builder() + .dataType("string") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateDataAttributeRequest` + +
+
+
+
+ + +
+
+
+ +
client.dataAttributes.update(dataAttributeId, request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataAttributes().update( + UpdateDataAttributeRequest + .builder() + .dataAttributeId(1) + .body( + UpdateDataAttributeRequestBody.of( + UpdateDataAttributeRequestOptions + .builder() + .options( + Arrays.asList( + UpdateDataAttributeRequestOptionsOptionsItem + .builder() + .value("1-10") + .build(), + UpdateDataAttributeRequestOptionsOptionsItem + .builder() + .value("11-20") + .build() + ) + ) + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataAttributeId:** `Integer` — The data attribute id + +
+
+ +
+
+ +**request:** `UpdateDataAttributeRequestBody` + +
+
+
+
+ + +
+
+
+ +## Events +
client.events.list() -> DataEventSummary +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +> 🚧 +> +> 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](http://en.wikipedia.org/wiki/Percent-encoding) when sending. + +You can optionally define the result page size as well with the `per_page` parameter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().list( + ListEventsRequest + .builder() + .type("type") + .userId("user_id") + .intercomUserId("intercom_user_id") + .email("email") + .summary(true) + .perPage(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `Optional` — user_id query parameter + +
+
+ +
+
+ +**intercomUserId:** `Optional` — intercom_user_id query parameter + +
+
+ +
+
+ +**email:** `Optional` — email query parameter + +
+
+ +
+
+ +**type:** `String` — The value must be user + +
+
+ +
+
+ +**summary:** `Optional` — summary flag + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
client.events.create(request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-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](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().create( + CreateDataEventRequest.of( + CreateDataEventRequestWithId + .builder() + .id("8a88a590-e1c3-41e2-a502-e0649dbf721c") + .eventName("invited-friend") + .createdAt(1671028894) + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateDataEventRequest` + +
+
+
+
+ + +
+
+
+ +
client.events.summaries(request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().summaries( + ListEventSummariesRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `Optional` — Your identifier for the user. + +
+
+ +
+
+ +**eventSummaries:** `Optional` — 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`. + +
+
+
+
+ + +
+
+
+ +## Jobs +
client.jobs.status(jobId) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve the status of job execution. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.jobs().status( + JobsStatusRequest + .builder() + .jobId("job_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobId:** `String` — The unique identifier for the job which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Messages +
client.messages.create(request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + +> 🚧 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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.messages().create( + Optional.of( + CreateMessageRequest.email( + CreateMessageRequestWithEmail + .builder() + .subject("Thanks for everything") + .body("Hello there") + .template("plain") + .from( + CreateMessageRequestFrom + .builder() + .type("admin") + .id(394051) + .build() + ) + .to( + CreateMessageRequestTo + .builder() + .type(CreateMessageRequestType.USER) + .id("536e564f316c83104c000020") + .build() + ) + .build() + ) + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +## Segments +
client.segments.list() -> SegmentList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.segments().list( + ListSegmentsRequest + .builder() + .includeCount(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**includeCount:** `Optional` — It includes the count of contacts that belong to each segment. + +
+
+
+
+ + +
+
+
+ +
client.segments.find(segmentId) -> Segment +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single segment. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.segments().find( + FindSegmentRequest + .builder() + .segmentId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**segmentId:** `String` — The unique identified of a given segment. + +
+
+
+
+ + +
+
+
+ +## Subscription Types +
client.subscriptionTypes.list() -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all subscription types. A list of subscription type objects will be returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.subscriptionTypes().list(); +``` +
+
+
+
+ + +
+
+
+ +## PhoneCallRedirects +
client.phoneCallRedirects.create(request) -> Optional<PhoneSwitch> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.phoneCallRedirects().create( + Optional.of( + CreatePhoneSwitchRequest + .builder() + .phone("+353832345678") + .customAttributes( + new HashMap() {{ + put("issue_type", CustomAttributesValue.of("Billing")); + put("priority", CustomAttributesValue.of("High")); + }} + ) + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +## Calls +
client.calls.listCalls() -> CallList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a paginated list of calls. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.calls().listCalls( + ListCallsRequest + .builder() + .page(1) + .perPage(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 25. Max 25. + +
+
+
+
+ + +
+
+
+ +
client.calls.showCall(callId) -> Call +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single call by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.calls().showCall( + ShowCallRequest + .builder() + .callId("call_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**callId:** `String` — The id of the call to retrieve + +
+
+
+
+ + +
+
+
+ +
client.calls.showCallRecording(callId) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Redirects to a signed URL for the call's recording if it exists. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.calls().showCallRecording( + ShowCallRecordingRequest + .builder() + .callId("call_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**callId:** `String` — The id of the call + +
+
+
+
+ + +
+
+
+ +
client.calls.showCallTranscript(callId) -> String +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns the transcript for the specified call as a downloadable text file. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.calls().showCallTranscript( + ShowCallTranscriptRequest + .builder() + .callId("call_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**callId:** `String` — The id of the call + +
+
+
+
+ + +
+
+
+ +
client.calls.listCallsWithTranscripts(request) -> ListCallsWithTranscriptsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve calls by a list of conversation ids and include transcripts when available. +A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.calls().listCallsWithTranscripts( + ListCallsWithTranscriptsRequest + .builder() + .conversationIds( + Arrays.asList("64619700005694", "64619700005695") + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationIds:** `List` — A list of conversation ids to fetch calls for. Maximum 20. + +
+
+
+
+ + +
+
+
+ +## Teams +
client.teams.list() -> TeamList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This will return a list of team objects for the App. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.teams().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.teams.find(teamId) -> Team +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single team, containing an array of admins that belong to this team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.teams().find( + FindTeamRequest + .builder() + .teamId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**teamId:** `String` — The unique identifier of a given team. + +
+
+
+
+ + +
+
+
+ +## Ticket States +
client.ticketStates.listTicketStates() -> TicketStateList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket states for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketStates().listTicketStates(); +``` +
+
+
+
+ + +
+
+
+ +## Ticket Types +
client.ticketTypes.list() -> TicketTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket types for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.ticketTypes.create(request) -> Optional<TicketType> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new ticket type. +> 📘 Creating ticket types. +> +> Every ticket type will be created with two default attributes: _default_title_ and _default_description_. +> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().create( + Optional.of( + CreateTicketTypeRequest + .builder() + .name("Customer Issue") + .description("Customer Report Template") + .category(CreateTicketTypeRequestCategory.CUSTOMER) + .icon("🎟️") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.ticketTypes.get(ticketTypeId) -> Optional<TicketType> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().get( + FindTicketTypeRequest + .builder() + .ticketTypeId("ticket_type_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketTypeId:** `String` — The unique identifier for the ticket type which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.ticketTypes.update(ticketTypeId, request) -> Optional<TicketType> +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +You can update a ticket type. + +> 📘 Updating a ticket type. +> +> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().update( + UpdateTicketTypeRequest + .builder() + .ticketTypeId("ticket_type_id") + .name("Bug Report 2") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketTypeId:** `String` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**name:** `Optional` — The name of the ticket type. + +
+
+ +
+
+ +**description:** `Optional` — The description of the ticket type. + +
+
+ +
+
+ +**category:** `Optional` — Category of the Ticket Type. + +
+
+ +
+
+ +**icon:** `Optional` — The icon of the ticket type. + +
+
+ +
+
+ +**archived:** `Optional` — The archived status of the ticket type. + +
+
+ +
+
+ +**isInternal:** `Optional` — 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. + +
+
+
+
+ + +
+
+
+ +## Tickets +
client.tickets.reply(ticketId, request) -> TicketReply +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tickets().reply( + ReplyToTicketRequest + .builder() + .ticketId("123") + .body( + TicketsReplyRequestBody.of( + ContactReplyTicketRequest.of( + ContactReplyTicketIntercomUserIdRequest + .builder() + .messageType("comment") + .type("user") + .body("Thanks again :)") + .intercomUserId("6762f2971bb69f9f2193bc49") + .build() + ) + ) + ) + .build() + ); + } +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` + +
+
+ +
+
+ +**request:** `TicketsReplyRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.tickets.create(request) -> Optional<Ticket> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tickets().create( + CreateTicketRequest + .builder() + .ticketTypeId("1234") + .contacts( + Arrays.asList( + CreateTicketRequestContactsItem.of( + CreateTicketRequestContactsItemId + .builder() + .id("6762f2d81bb69f9f2193bc54") + .build() + ) + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**skipNotifications:** `Optional` — Option to disable notifications when a Ticket is created. + +
+
+
+
+ + +
+
+
+ +
client.tickets.enqueueCreateTicket(request) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tickets().enqueueCreateTicket( + EnqueueCreateTicketRequest + .builder() + .ticketTypeId("1234") + .contacts( + Arrays.asList( + CreateTicketRequestContactsItem.of( + CreateTicketRequestContactsItemId + .builder() + .id("6762f2d81bb69f9f2193bc54") + .build() + ) + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**skipNotifications:** `Optional` — Option to disable notifications when a Ticket is created. + +
+
+
+
+ + +
+
+
+ +
client.tickets.get(ticketId) -> Optional<Ticket> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tickets().get( + FindTicketRequest + .builder() + .ticketId("ticket_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.tickets.update(ticketId, request) -> Optional<Ticket> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tickets().update( + UpdateTicketRequest + .builder() + .ticketId("ticket_id") + .ticketAttributes( + new HashMap() {{ + put("_default_title_", "example"); + put("_default_description_", "there is a problem"); + }} + ) + .ticketStateId("123") + .open(true) + .snoozedUntil(1673609604) + .adminId(991268011) + .assigneeId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` — The unique identifier for the ticket which is given by Intercom + +
+
+ +
+
+ +**ticketAttributes:** `Optional>` — The attributes set on the ticket. + +
+
+ +
+
+ +**ticketStateId:** `Optional` — The ID of the ticket state associated with the ticket type. + +
+
+ +
+
+ +**companyId:** `Optional` — 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. + +
+
+ +
+
+ +**open:** `Optional` — Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. + +
+
+ +
+
+ +**isShared:** `Optional` — Specify whether the ticket is visible to users. + +
+
+ +
+
+ +**snoozedUntil:** `Optional` — The time you want the ticket to reopen. + +
+
+ +
+
+ +**adminId:** `Optional` — The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + +
+
+ +
+
+ +**assigneeId:** `Optional` — The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + +
+
+
+
+ + +
+
+
+ +
client.tickets.deleteTicket(ticketId) -> DeleteTicketResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a ticket using the Intercom provided ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tickets().deleteTicket( + DeleteTicketRequest + .builder() + .ticketId("ticket_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.tickets.search(request) -> SyncPagingIterable<Optional<Ticket>> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) 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) | +| title | String | +| 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 | + +{% admonition type="info" name="Searching by Category" %} +When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: +* For **Customer** category tickets, use the term `request`. +* For **Back-office** category tickets, use the term `task`. +* For **Tracker** category tickets, use the term `tracker`. +{% /admonition %} + +### 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 | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tickets().searchTickets( + SearchRequest + .builder() + .query( + SearchRequestQuery.of( + SingleFilterSearchRequest + .builder() + .value( + SingleFilterSearchRequestValue.of() + ) + .build() + ) + ) + .pagination( + StartingAfterPaging + .builder() + .perPage(5) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +## Visitors +
client.visitors.find() -> Optional<Visitor> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single visitor. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.visitors().find( + FindVisitorRequest + .builder() + .userId("user_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `String` — The user_id of the Visitor you want to retrieve. + +
+
+
+
+ + +
+
+
+ +
client.visitors.update(request) -> Optional<Visitor> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a PUT request to `/visitors` will result in an update of an existing Visitor. + +**Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. + +**Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.visitors().update( + UpdateVisitorRequest.of( + UpdateVisitorRequestWithId + .builder() + .id("6762f30c1bb69f9f2193bc5e") + .name("Gareth Bale") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpdateVisitorRequest` + +
+
+
+
+ + +
+
+
+ +
client.visitors.mergeToContact(request) -> Contact +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a Visitor to a Contact of role type `lead` or `user`. + +> 📘 What happens upon a visitor being converted? +> +> If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().visitors().convertVisitor( + ConvertVisitorRequest + .builder() + .type("user") + .user(new + HashMap() {{put("id", "8a88a590-e1c3-41e2-a502-e0649dbf721c"); + put("email", "foo@bar.com"); + }}) + .visitor(new + HashMap() {{put("user_id", "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3"); + }}) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**type:** `String` — Represents the role of the Contact model. Accepts `lead` or `user`. + +
+
+ +
+
+ +**user:** `ConvertVisitorRequestUser` — The unique identifiers retained after converting or merging. + +
+
+ +
+
+ +**visitor:** `ConvertVisitorRequestVisitor` — The unique identifiers to convert a single Visitor. + +
+
+
+
+ + +
+
+
+ +## HelpCenters Collections +
client.helpCenters.collections.list() -> SyncPagingIterable<Collection> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().collections().list( + ListCollectionsRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
client.helpCenters.collections.create(request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().collections().create( + CreateCollectionRequest + .builder() + .name("Thanks for everything") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `String` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**description:** `Optional` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**translatedContent:** `Optional` + +
+
+ +
+
+ +**parentId:** `Optional` — The id of the parent collection. If `null` then it will be created as the first level collection. + +
+
+ +
+
+ +**helpCenterId:** `Optional` — The id of the help center where the collection will be created. If `null` then it will be created in the default help center. + +
+
+
+
+ + +
+
+
+ +
client.helpCenters.collections.find(collectionId) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().collections().find( + FindCollectionRequest + .builder() + .collectionId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collectionId:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.helpCenters.collections.update(collectionId, request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().collections().update( + UpdateCollectionRequest + .builder() + .collectionId(1) + .name("Update collection name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collectionId:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+ +
+
+ +**name:** `Optional` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**description:** `Optional` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**translatedContent:** `Optional` + +
+
+ +
+
+ +**parentId:** `Optional` — The id of the parent collection. If `null` then it will be updated as the first level collection. + +
+
+
+
+ + +
+
+
+ +
client.helpCenters.collections.delete(collectionId) -> DeletedCollectionObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().collections().delete( + DeleteCollectionRequest + .builder() + .collectionId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**collectionId:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## News Items +
client.news.items.list() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().items().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.news.items.create(request) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a news item +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().items().create( + NewsItemRequest + .builder() + .title("Halloween is here!") + .senderId(991267834) + .body("

New costumes in store for this spooky season

") + .state(NewsItemRequestState.LIVE) + .deliverSilently(true) + .labels( + Optional.of( + Arrays.asList("Product", "Update", "New") + ) + ) + .reactions( + Optional.of( + Arrays.asList(Optional.of("😆"), Optional.of("😅")) + ) + ) + .newsfeedAssignments( + Optional.of( + Arrays.asList( + NewsfeedAssignment + .builder() + .newsfeedId(53) + .publishedAt(1664638214) + .build() + ) + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
client.news.items.find(newsItemId) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().items().find( + FindNewsItemRequest + .builder() + .newsItemId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**newsItemId:** `Integer` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.news.items.update(newsItemId, request) -> NewsItem +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().items().update( + UpdateNewsItemRequest + .builder() + .newsItemId(1) + .body( + NewsItemRequest + .builder() + .title("Christmas is here!") + .senderId(991267845) + .body("

New gifts in store for the jolly season

") + .reactions( + Optional.of( + Arrays.asList(Optional.of("😝"), Optional.of("😂")) + ) + ) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**newsItemId:** `Integer` — The unique identifier for the news item which is given by Intercom. + +
+
+ +
+
+ +**request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
client.news.items.delete(newsItemId) -> DeletedObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().items().delete( + DeleteNewsItemRequest + .builder() + .newsItemId(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**newsItemId:** `Integer` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## News Feeds +
client.news.feeds.listItems(newsfeedId) -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items that are live on a given newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().feeds().listItems( + ListNewsFeedItemsRequest + .builder() + .newsfeedId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**newsfeedId:** `String` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.news.feeds.list() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all newsfeeds +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().feeds().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.news.feeds.find(newsfeedId) -> Newsfeed +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().feeds().find( + FindNewsFeedRequest + .builder() + .newsfeedId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**newsfeedId:** `String` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## TicketTypes Attributes +
client.ticketTypes.attributes.create(ticketTypeId, request) -> Optional<TicketTypeAttribute> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().attributes().create( + CreateTicketTypeAttributeRequest + .builder() + .ticketTypeId("ticket_type_id") + .name("Attribute Title") + .description("Attribute Description") + .dataType(CreateTicketTypeAttributeRequestDataType.STRING) + .requiredToCreate(false) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketTypeId:** `String` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**name:** `String` — The name of the ticket type attribute + +
+
+ +
+
+ +**description:** `String` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**dataType:** `CreateTicketTypeAttributeRequestDataType` — The data type of the attribute + +
+
+ +
+
+ +**requiredToCreate:** `Optional` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**requiredToCreateForContacts:** `Optional` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**visibleOnCreate:** `Optional` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**visibleToContacts:** `Optional` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**multiline:** `Optional` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**listItems:** `Optional` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**allowMultipleValues:** `Optional` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+
+
+ + +
+
+
+ +
client.ticketTypes.attributes.update(ticketTypeId, attributeId, request) -> Optional<TicketTypeAttribute> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().attributes().update( + UpdateTicketTypeAttributeRequest + .builder() + .ticketTypeId("ticket_type_id") + .attributeId("attribute_id") + .description("New Attribute Description") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketTypeId:** `String` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**attributeId:** `String` — The unique identifier for the ticket type attribute which is given by Intercom. + +
+
+ +
+
+ +**name:** `Optional` — The name of the ticket type attribute + +
+
+ +
+
+ +**description:** `Optional` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**requiredToCreate:** `Optional` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**requiredToCreateForContacts:** `Optional` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**visibleOnCreate:** `Optional` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**visibleToContacts:** `Optional` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**multiline:** `Optional` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**listItems:** `Optional` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**allowMultipleValues:** `Optional` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+ +
+
+ +**archived:** `Optional` — Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets) + +
+
+
+
+ + +
+
+
+ +## Admins +
client.unstable.admins.identifyAdmin() -> Optional<AdminWithApp> +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().identify(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.admins.setAwayAdmin(id, request) -> Optional<Admin> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can set an Admin as away for the Inbox. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().admins().setAwayAdmin( + SetAwayAdminRequest + .builder() + .id(1) + .awayModeEnabled(true) + .awayModeReassign(true) + .awayStatusReasonId(12345) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier of a given admin + +
+
+ +
+
+ +**awayModeEnabled:** `Boolean` — Set to "true" to change the status of the admin to away. + +
+
+ +
+
+ +**awayModeReassign:** `Boolean` — Set to "true" to assign any new conversation replies to your default inbox. + +
+
+ +
+
+ +**awayStatusReasonId:** `Optional` — The unique identifier of the away status reason + +
+
+
+
+ + +
+
+
+ +
client.unstable.admins.listActivityLogs() -> ActivityLogList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a log of activities by all admins in an app. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().listAllActivityLogs( + ListAllActivityLogsRequest + .builder() + .createdAtAfter("1677253093") + .createdAtBefore("1677861493") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**createdAtAfter:** `String` — The start date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+ +
+
+ +**createdAtBefore:** `Optional` — The end date that you request data for. It must be formatted as a UNIX timestamp. + +
+
+
+
+ + +
+
+
+ +
client.unstable.admins.listAdmins() -> AdminList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of admins for a given workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.admins().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.admins.retrieveAdmin(id) -> Optional<Admin> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve the details of a single admin. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().admins().retrieveAdmin( + RetrieveAdminRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier of a given admin + +
+
+
+
+ + +
+
+
+ +## AI Content +
client.unstable.aiContent.listContentImportSources() -> ContentImportSourcesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all content import sources for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().listContentImportSources(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.createContentImportSource(request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new content import source by sending a POST request to this endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().createContentImportSource( + CreateContentImportSourceRequest + .builder() + .url("https://www.example.com") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**syncBehavior:** `String` — If you intend to create or update External Pages via the API, this should be set to `api`. + +
+
+ +
+
+ +**status:** `Optional` — The status of the content import source. + +
+
+ +
+
+ +**url:** `String` — The URL of the content import source. + +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.getContentImportSource(id) -> ContentImportSource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().aiContent().getContentImportSource( + GetContentImportSourceRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.updateContentImportSource(id, request) -> ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing content import source. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().aiContent().updateContentImportSource( + UpdateContentImportSourceRequest + .builder() + .id("id") + .syncBehavior(UpdateContentImportSourceRequestSyncBehavior.API) + .url("https://www.example.com") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the content import source which is given by Intercom. + +
+
+ +
+
+ +**syncBehavior:** `UpdateContentImportSourceRequestSyncBehavior` — 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. + +
+
+ +
+
+ +**status:** `Optional` — The status of the content import source. + +
+
+ +
+
+ +**url:** `String` — The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.deleteContentImportSource(id) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().aiContent().deleteContentImportSource( + DeleteContentImportSourceRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the content import source which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.listExternalPages() -> ExternalPagesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all external pages for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().listExternalPages(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.createExternalPage(request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.aiContent().createExternalPage( + CreateExternalPageRequest + .builder() + .title("Test") + .html("

Test

") + .sourceId(44) + .externalId("abc1234") + .url("https://www.example.com") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**title:** `String` — The title of the external page. + +
+
+ +
+
+ +**html:** `String` — The body of the external page in HTML. + +
+
+ +
+
+ +**url:** `Optional` — 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. + +
+
+ +
+
+ +**aiAgentAvailability:** `Optional` — Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page. + +
+
+ +
+
+ +**aiCopilotAvailability:** `Optional` — Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. + +
+
+ +
+
+ +**locale:** `String` — Always en + +
+
+ +
+
+ +**sourceId:** `Integer` — 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. + +
+
+ +
+
+ +**externalId:** `String` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.getExternalPage(id) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve an external page. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().aiContent().getExternalPage( + GetExternalPageRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.updateExternalPage(id, request) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing external page (if it was created via the API). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().aiContent().updateExternalPage( + UpdateExternalPageRequest + .builder() + .id("id") + .title("Test") + .html("

Test

") + .url("https://www.example.com") + .sourceId(47) + .externalId("5678") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the external page which is given by Intercom. + +
+
+ +
+
+ +**title:** `String` — The title of the external page. + +
+
+ +
+
+ +**html:** `String` — The body of the external page in HTML. + +
+
+ +
+
+ +**url:** `String` — The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. + +
+
+ +
+
+ +**finAvailability:** `Optional` — Whether the external page should be used to answer questions by Fin. + +
+
+ +
+
+ +**locale:** `String` — Always en + +
+
+ +
+
+ +**sourceId:** `Integer` — 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. + +
+
+ +
+
+ +**externalId:** `Optional` — The identifier for the external page which was given by the source. Must be unique for the source. + +
+
+
+
+ + +
+
+
+ +
client.unstable.aiContent.deleteExternalPage(id) -> ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().aiContent().deleteExternalPage( + DeleteExternalPageRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the external page which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Articles +
client.unstable.articles.listArticles() -> ArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().list( + ListArticlesRequest + .builder() + .build() +); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.articles.createArticle(request) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new article by making a POST request to `https://api.intercom.io/articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().articles().createArticle(new +HashMap() {{put("key", "value"); +}}); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +
client.unstable.articles.retrieveArticle(id) -> Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().articles().retrieveArticle( + RetrieveArticleRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.articles.deleteArticle(id) -> DeletedArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().articles().deleteArticle( + DeleteArticleRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.articles.searchArticles() -> ArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.articles().search( + SearchArticlesRequest + .builder() + .phrase("Getting started") + .state("published") + .helpCenterId(1) + .highlight(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**phrase:** `Optional` — The phrase within your articles to search for. + +
+
+ +
+
+ +**state:** `Optional` — The state of the Articles returned. One of `published`, `draft` or `all`. + +
+
+ +
+
+ +**helpCenterId:** `Optional` — The ID of the Help Center to search in. + +
+
+ +
+
+ +**highlight:** `Optional` — Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. + +
+
+
+
+ + +
+
+
+ +## Away Status Reasons +
client.unstable.awayStatusReasons.listAwayStatusReasons() -> List<AwayStatusReason> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of all away status reasons configured for the workspace, including deleted ones. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.awayStatusReasons().listAwayStatusReasons(); +``` +
+
+
+
+ + +
+
+
+ +## Unstable Export +
client.unstable.export.enqueueANewReportingDataExportJob(request) -> PostExportReportingDataEnqueueResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.export().enqueueANewReportingDataExportJob( + PostExportReportingDataEnqueueRequest + .builder() + .datasetId("conversation") + .startTime(1717490000L) + .endTime(1717510000L) + .attributeIds( + Arrays.asList("conversation_id", "conversation_started_at") + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**datasetId:** `String` + +
+
+ +
+
+ +**attributeIds:** `List` + +
+
+ +
+
+ +**startTime:** `Long` + +
+
+ +
+
+ +**endTime:** `Long` + +
+
+
+
+ + +
+
+
+ +
client.unstable.export.listAvailableDatasetsAndAttributes() -> GetExportReportingDataGetDatasetsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.export().listAvailableDatasetsAndAttributes(); +``` +
+
+
+
+ + +
+
+
+ +## Help Center +
client.unstable.helpCenter.listAllCollections() -> CollectionList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().collections().list( + ListCollectionsRequest + .builder() + .build() +); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.helpCenter.createCollection(request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().collections().create( + CreateCollectionRequest + .builder() + .name("Thanks for everything") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `String` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**description:** `Optional` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**translatedContent:** `Optional` + +
+
+ +
+
+ +**parentId:** `Optional` — The id of the parent collection. If `null` then it will be created as the first level collection. + +
+
+ +
+
+ +**helpCenterId:** `Optional` — The id of the help center where the collection will be created. If `null` then it will be created in the default help center. + +
+
+
+
+ + +
+
+
+ +
client.unstable.helpCenter.retrieveCollection(id) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().helpCenter().retrieveCollection( + RetrieveCollectionRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.helpCenter.updateCollection(id, request) -> Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().helpCenter().updateCollection( + UpdateCollectionRequest + .builder() + .id(1) + .name("Update collection name") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+ +
+
+ +**name:** `Optional` — The name of the collection. For multilingual collections, this will be the name of the default language's content. + +
+
+ +
+
+ +**description:** `Optional` — The description of the collection. For multilingual collections, this will be the description of the default language's content. + +
+
+ +
+
+ +**translatedContent:** `Optional` + +
+
+ +
+
+ +**parentId:** `Optional` — The id of the parent collection. If `null` then it will be updated as the first level collection. + +
+
+
+
+ + +
+
+
+ +
client.unstable.helpCenter.deleteCollection(id) -> DeletedCollectionObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().helpCenter().deleteCollection( + DeleteCollectionRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.helpCenter.retrieveHelpCenter(id) -> HelpCenter +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().helpCenter().retrieveHelpCenter( + RetrieveHelpCenterRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the collection which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.helpCenter.listHelpCenters() -> HelpCenterList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.helpCenters().list( + ListHelpCentersRequest + .builder() + .build() +); +``` +
+
+
+
+ + +
+
+
+ +## Internal Articles +
client.unstable.internalArticles.listInternalArticles() -> InternalArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().listInternalArticles(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.internalArticles.createInternalArticle(request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().createInternalArticle( + Optional.of( + CreateInternalArticleRequest + .builder() + .title("Thanks for everything") + .authorId(991266252) + .ownerId(991266252) + .body("Body of the Article") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.unstable.internalArticles.retrieveInternalArticle(id) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().internalArticles().retrieveInternalArticle( + RetrieveInternalArticleRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.internalArticles.updateInternalArticle(id, request) -> InternalArticleListItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().internalArticles().updateInternalArticle( + UpdateInternalArticleRequestBody + .builder() + .id(1) + .title("Christmas is here!") + .body("

New gifts in store for the jolly season

") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the internal article which is given by Intercom. + +
+
+ +
+
+ +**title:** `Optional` — The title of the article. + +
+
+ +
+
+ +**body:** `Optional` — The content of the article. + +
+
+ +
+
+ +**authorId:** `Optional` — The id of the author of the article. + +
+
+ +
+
+ +**ownerId:** `Optional` — The id of the author of the article. + +
+
+
+
+ + +
+
+
+ +
client.unstable.internalArticles.deleteInternalArticle(id) -> DeletedInternalArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().internalArticles().deleteInternalArticle( + DeleteInternalArticleRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the internal article which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.internalArticles.searchInternalArticles() -> InternalArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.internalArticles().searchInternalArticles( + SearchInternalArticlesRequest + .builder() + .folderId("folder_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**folderId:** `Optional` — The ID of the folder to search in. + +
+
+
+
+ + +
+
+
+ +## Companies +
client.unstable.companies.retrieveCompany() -> CompanyList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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}` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().retrieve( + RetrieveCompanyRequest + .builder() + .name("my company") + .companyId("12345") + .tagId("678910") + .segmentId("98765") + .page(1) + .perPage(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `Optional` — The `name` of the company to filter by. + +
+
+ +
+
+ +**companyId:** `Optional` — The `company_id` of the company to filter by. + +
+
+ +
+
+ +**tagId:** `Optional` — The `tag_id` of the company to filter by. + +
+
+ +
+
+ +**segmentId:** `Optional` — The `segment_id` of the company to filter by. + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 15 + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.createOrUpdateCompany(request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().createOrUpdateCompany(new +HashMap() {{put("key", "value"); +}}); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.retrieveACompanyById(id) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().retrieveACompanyById( + RetrieveACompanyByIdRequest + .builder() + .id("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.updateCompany(id) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().updateCompany( + UpdateCompanyRequest + .builder() + .id("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.deleteCompany(id) -> DeletedCompanyObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().deleteCompany( + DeleteCompanyRequest + .builder() + .id("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.listAttachedContacts(id) -> CompanyAttachedContacts +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().listAttachedContacts( + ListAttachedContactsRequest + .builder() + .id("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.listAttachedSegmentsForCompanies(id) -> CompanyAttachedSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments that belong to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().listAttachedSegmentsForCompanies( + ListAttachedSegmentsForCompaniesRequest + .builder() + .id("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.listAllCompanies() -> CompanyList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/reference#iterating-over-all-companies). +{% 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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().list( + ListCompaniesRequest + .builder() + .page(1) + .perPage(1) + .order("desc") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to return per page. Defaults to 15 + +
+
+ +
+
+ +**order:** `Optional` — `asc` or `desc`. Return the companies in ascending or descending order. Defaults to desc + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.scrollOverAllCompanies() -> Optional<CompanyScroll> +
+
+ +#### 📝 Description + +
+
+ +
+
+ + 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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.companies().scroll( + ScrollCompaniesRequest + .builder() + .scrollParam("scroll_param") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**scrollParam:** `Optional` — + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.attachContactToACompany(id, request) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can attach a company to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().attachContactToACompany( + AttachContactToACompanyRequest + .builder() + .id("id") + .companyId("6762f09a1bb69f9f2193bb34") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**companyId:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.companies.detachContactFromACompany(contactId, id) -> Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can detach a company from a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().companies().detachContactFromACompany( + DetachContactFromACompanyRequest + .builder() + .contactId("58a430d35458202d41b1e65b") + .id("58a430d35458202d41b1e65b") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Notes +
client.unstable.notes.listCompanyNotes(id) -> NoteList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of notes that are associated to a company. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().notes().listCompanyNotes( + ListCompanyNotesRequest + .builder() + .id("5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the company which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.notes.listNotes(id) -> NoteList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of notes that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().notes().listNotes( + ListNotesRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier of a contact. + +
+
+
+
+ + +
+
+
+ +
client.unstable.notes.createNote(id, request) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a note to a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().notes().createNote( + CreateNoteRequest + .builder() + .id(1) + .body("Hello") + .contactId("6762f0ad1bb69f9f2193bb62") + .adminId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier of a given contact. + +
+
+ +
+
+ +**body:** `String` — The text of the note. + +
+
+ +
+
+ +**contactId:** `Optional` — The unique identifier of a given contact. + +
+
+ +
+
+ +**adminId:** `Optional` — The unique identifier of a given admin. + +
+
+
+
+ + +
+
+
+ +
client.unstable.notes.retrieveNote(id) -> Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single note. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().notes().retrieveNote( + RetrieveNoteRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier of a given note + +
+
+
+
+ + +
+
+
+ +## Contacts +
client.unstable.contacts.listCompaniesForAContact(id) -> ContactAttachedCompanies +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of companies that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().listCompaniesForAContact( + ListCompaniesForAContactRequest + .builder() + .id("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.listSegmentsForAContact(contactId) -> ContactSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of segments that are associated to a contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().listAttachedSegments( + ListSegmentsAttachedToContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.listSubscriptionsForAContact(contactId) -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().listAttachedSubscriptions( + ListAttachedSubscriptionsRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.listTagsForAContact(contactId) -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags that are attached to a specific contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().listAttachedTags( + ListTagsAttachedToContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.showContact(id) -> ShowContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().showContact( + ShowContactRequest + .builder() + .id("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — id + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.updateContact(id, request) -> UpdateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().updateContact( + UpdateContactRequest + .builder() + .id("63a07ddf05a32042dffac965") + .email("joebloggs@intercom.io") + .name("joe bloggs") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — id + +
+
+ +
+
+ +**role:** `Optional` — The role of the contact. + +
+
+ +
+
+ +**externalId:** `Optional` — A unique identifier for the contact which is given to Intercom + +
+
+ +
+
+ +**email:** `Optional` — The contacts email + +
+
+ +
+
+ +**phone:** `Optional` — The contacts phone + +
+
+ +
+
+ +**name:** `Optional` — The contacts name + +
+
+ +
+
+ +**avatar:** `Optional` — An image URL containing the avatar of a contact + +
+
+ +
+
+ +**signedUpAt:** `Optional` — The time specified for when a contact signed up + +
+
+ +
+
+ +**lastSeenAt:** `Optional` — The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) + +
+
+ +
+
+ +**ownerId:** `Optional` — The id of an admin that has been assigned account ownership of the contact + +
+
+ +
+
+ +**unsubscribedFromEmails:** `Optional` — Whether the contact is unsubscribed from emails + +
+
+ +
+
+ +**customAttributes:** `Optional>` — The custom attributes which are set for the contact + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.deleteContact(id) -> ContactDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().deleteContact( + DeleteContactRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — id + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.mergeContact(request) -> MergeContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().mergeLeadInUser( + MergeContactsRequest + .builder() + .leadId("6762f0d51bb69f9f2193bb7f") + .contactId("6762f0d51bb69f9f2193bb80") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**from:** `Optional` — The unique identifier for the contact to merge away from. Must be a lead. + +
+
+ +
+
+ +**into:** `Optional` — The unique identifier for the contact to merge into. Must be a user. + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.searchContacts(request) -> ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) 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
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
Shortcut for `OR` queries
Values must be in Array | +| NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Date (UNIX Timestamp) | Greater than | +| < | Integer
Date (UNIX Timestamp) | Lower than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().searchContacts( + SearchRequest + .builder() + .query( + SearchRequestQuery.of( + SingleFilterSearchRequest + .builder() + .value( + SingleFilterSearchRequestValue.of() + ) + .build() + ) + ) + .pagination( + StartingAfterPaging + .builder() + .perPage(5) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.listContacts() -> ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().list( + ListContactsRequest + .builder() + .build() +); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.createContact(request) -> CreateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new contact (ie. user or lead). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().create( + CreateContactRequest.of( + CreateContactRequestWithEmail + .builder() + .email("joebloggs@intercom.io") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.showContactByExternalId(externalId) -> ShowContactByExternalIdResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().showContactByExternalId( + ShowContactByExternalIdRequest + .builder() + .externalId("cdd29344-5e0c-4ef0-ac56-f9ba2979bc27") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**externalId:** `String` — The external ID of the user that you want to retrieve + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.archiveContact(id) -> ContactArchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can archive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().archiveContact( + ArchiveContactRequest + .builder() + .id("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — id + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.unarchiveContact(id) -> ContactUnarchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can unarchive a single contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().unarchiveContact( + UnarchiveContactRequest + .builder() + .id("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — id + +
+
+
+
+ + +
+
+
+ +
client.unstable.contacts.blockContact(id) -> ContactBlocked +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().contacts().blockContact( + BlockContactRequest + .builder() + .id("63a07ddf05a32042dffac965") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — id + +
+
+
+
+ + +
+
+
+ +## Subscription Types +
client.unstable.subscriptionTypes.attachSubscriptionTypeToContact(contactId, request) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.contacts().attachSubscription( + AttachSubscriptionToContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .subscriptionId("37846") + .consentType("opt_in") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the subscription which is given by Intercom + +
+
+ +
+
+ +**consentType:** `String` — The consent_type of a subscription, opt_out or opt_in. + +
+
+
+
+ + +
+
+
+ +
client.unstable.subscriptionTypes.detachSubscriptionTypeToContact(contactId, id) -> SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().subscriptionTypes().detachSubscriptionTypeToContact( + DetachSubscriptionTypeToContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .id("37846") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the subscription type which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.subscriptionTypes.listSubscriptionTypes() -> SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all subscription types. A list of subscription type objects will be returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.subscriptionTypes().list(); +``` +
+
+
+
+ + +
+
+
+ +## Tags +
client.unstable.tags.attachTagToContact(contactId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific contact. This will return a tag object for the tag that was added to the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().tagContact( + TagContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .tagId("7522907") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.detachTagFromContact(contactId, id) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tags().detachTagFromContact( + DetachTagFromContactRequest + .builder() + .contactId("63a07ddf05a32042dffac965") + .id("7522907") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**contactId:** `String` — The unique identifier for the contact which is given by Intercom + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.attachTagToConversation(conversationId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().tagConversation( + TagConversationRequest + .builder() + .conversationId("64619700005694") + .tagId("7522907") + .adminId("780") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — conversation_id + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.detachTagFromConversation(conversationId, id, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tags().detachTagFromConversation( + DetachTagFromConversationRequest + .builder() + .conversationId("64619700005694") + .id("7522907") + .adminId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — conversation_id + +
+
+ +
+
+ +**id:** `String` — id + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.listTags() -> TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags for a given workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.createTag(request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().create( + TagsCreateRequestBody.of( + CreateOrUpdateTagRequest + .builder() + .name("test") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateTagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.findTag(id) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of tags that are on the workspace by their id. +This will return a tag object. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tags().findTag( + FindTagRequest + .builder() + .id("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.deleteTag(id) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete the details of tags that are on the workspace by passing in the id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tags().deleteTag( + DeleteTagRequest + .builder() + .id("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier of a given tag + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.attachTagToTicket(ticketId, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tags().tagTicket( + TagTicketRequest + .builder() + .ticketId("64619700005694") + .tagId("7522907") + .adminId("780") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` — ticket_id + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.tags.detachTagFromTicket(ticketId, id, request) -> Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tags().detachTagFromTicket( + DetachTagFromTicketRequest + .builder() + .ticketId("64619700005694") + .id("7522907") + .adminId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketId:** `String` — ticket_id + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the tag which is given by Intercom + +
+
+ +
+
+ +**adminId:** `String` — The unique identifier for the admin which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Conversations +
client.unstable.conversations.listConversations() -> ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. +{% /admonition %} +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().list( + ListConversationsRequest + .builder() + .perPage(1) + .startingAfter("starting_after") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**perPage:** `Optional` — How many results per page + +
+
+ +
+
+ +**startingAfter:** `Optional` — String used to get the next page of conversations. + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.createConversation(request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().create( + CreateConversationRequest + .builder() + .from( + CreateConversationRequestFrom + .builder() + .type(CreateConversationRequestFromType.USER) + .id("6762f11b1bb69f9f2193bba3") + .build() + ) + .body("Hello there") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**from:** `CreateConversationRequestFrom` + +
+
+ +
+
+ +**body:** `String` — The content of the message. HTML is not supported. + +
+
+ +
+
+ +**createdAt:** `Optional` — 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. + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.retrieveConversation(id) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().retrieveConversation( + RetrieveConversationRequest + .builder() + .id(1) + .displayAs("plaintext") + .includeTranslations(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The id of the conversation to target + +
+
+ +
+
+ +**displayAs:** `Optional` — Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. + +
+
+ +
+
+ +**includeTranslations:** `Optional` — If set to true, conversation parts will be translated to the detected language of the conversation. + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.updateConversation(id, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().updateConversation( + UpdateConversationRequest + .builder() + .id(1) + .displayAs("plaintext") + .read(true) + .title("new conversation title") + .customAttributes( + new HashMap() {{ + put("issue_type", CustomAttributesValue.of("Billing")); + put("priority", CustomAttributesValue.of("High")); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The id of the conversation to target + +
+
+ +
+
+ +**displayAs:** `Optional` — Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. + +
+
+ +
+
+ +**read:** `Optional` — Mark a conversation as read within Intercom. + +
+
+ +
+
+ +**title:** `Optional` — The title given to the conversation + +
+
+ +
+
+ +**customAttributes:** `Optional>` + +
+
+ +
+
+ +**companyId:** `Optional` — The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.deleteConversation(id) -> ConversationDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single conversation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().deleteConversation( + DeleteConversationRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — id + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.searchConversations(request) -> ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) 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
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 | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().searchConversations( + SearchRequest + .builder() + .query( + SearchRequestQuery.of( + SingleFilterSearchRequest + .builder() + .value( + SingleFilterSearchRequestValue.of() + ) + .build() + ) + ) + .pagination( + StartingAfterPaging + .builder() + .perPage(5) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.replyConversation(id, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().replyConversation( + ReplyConversationRequest + .builder() + .id("123 or \"last\"") + .body( + ReplyConversationRequestBody.of( + ContactReplyConversationRequest.of( + ContactReplyIntercomUserIdRequest + .builder() + .messageType("comment") + .type("user") + .body("Thanks again :)") + .intercomUserId("6762f1571bb69f9f2193bbbb") + .build() + ) + ) + ) + .build() + ); + } +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + +
+
+ +
+
+ +**request:** `ReplyConversationRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.manageConversation(id, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().manageConversation( + ManageConversationRequest + .builder() + .id("123") + .body( + ManageConversationRequestBody.close( + CloseConversationRequest + .builder() + .type("admin") + .adminId("12345") + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**request:** `ManageConversationRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.attachContactToConversation(id, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().attachContactToConversation( + AttachContactToConversationRequest + .builder() + .id("123") + .adminId("12345") + .customer( + AttachContactToConversationRequestCustomer.of( + AttachContactToConversationRequestCustomerIntercomUserId + .builder() + .intercomUserId("6762f19b1bb69f9f2193bbd4") + .build() + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**adminId:** `Optional` — The `id` of the admin who is adding the new participant. + +
+
+ +
+
+ +**customer:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.detachContactFromConversation(conversationId, contactId, request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().detachContactAsAdmin( + DetachContactFromConversationRequest + .builder() + .conversationId("123") + .contactId("123") + .adminId("5017690") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationId:** `String` — The identifier for the conversation as given by Intercom. + +
+
+ +
+
+ +**contactId:** `String` — The identifier for the contact as given by Intercom. + +
+
+ +
+
+ +**adminId:** `String` — The `id` of the admin who is performing the action. + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.redactConversation(request) -> Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.conversations().redactConversationPart( + RedactConversationRequest.conversationPart( + RedactConversationRequestConversationPart + .builder() + .conversationId("19894788788") + .conversationPartId("19381789428") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `RedactConversationRequest` + +
+
+
+
+ + +
+
+
+ +
client.unstable.conversations.convertConversationToTicket(id, request) -> Optional<Ticket> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can convert a conversation to a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().conversations().convertConversationToTicket( + ConvertConversationToTicketRequest + .builder() + .id(1) + .ticketTypeId("53") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The id of the conversation to target + +
+
+ +
+
+ +**ticketTypeId:** `String` — The ID of the type of ticket you want to convert the conversation to + +
+
+ +
+
+ +**attributes:** `Optional>` + +
+
+
+
+ + +
+
+
+ +## Unstable CustomChannelEvents +
client.unstable.customChannelEvents.notifyNewConversation(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyNewConversation( + CustomChannelBaseEvent + .builder() + .eventId("evt_12345") + .externalConversationId("conv_67890") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("user_001") + .name("Jane Doe") + .email("jane.doe@example.com") + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CustomChannelBaseEvent` + +
+
+
+
+ + +
+
+
+ +
client.unstable.customChannelEvents.notifyNewMessage(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyNewMessage( + NotifyNewMessageRequest + .builder() + .eventId("evt_54321") + .externalConversationId("conv_98765") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("user_002") + .name("John Smith") + .email("john.smith@example.com") + .build() + ) + .body("Hello, I need help with my order.") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**body:** `String` — The message content sent by the user. + +
+
+
+
+ + +
+
+
+ +
client.unstable.customChannelEvents.notifyQuickReplySelected(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyQuickReplySelected( + NotifyQuickReplySelectedRequest + .builder() + .eventId("evt_67890") + .externalConversationId("conv_13579") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("user_003") + .name("Alice Example") + .email("alice@example.com") + .build() + ) + .quickReplyOptionId("1234") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**quickReplyOptionId:** `String` — Id of the selected quick reply option. + +
+
+
+
+ + +
+
+
+ +
client.unstable.customChannelEvents.notifyAttributeCollected(request) -> CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customChannelEvents().notifyAttributeCollected( + NotifyAttributeCollectedRequest + .builder() + .eventId("evt_24680") + .externalConversationId("conv_11223") + .contact( + CustomChannelContact + .builder() + .type(CustomChannelContactType.USER) + .externalId("user_004") + .name("Bob Example") + .email("bob@example.com") + .build() + ) + .attribute( + CustomChannelAttribute + .builder() + .id("shipping_address") + .value("123 Main St, Springfield") + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**attribute:** `CustomChannelAttribute` + +
+
+
+
+ + +
+
+
+ +## Custom Object Instances +
client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId(customObjectTypeIdentifier) -> Optional<CustomObjectInstance> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().getCustomObjectInstancesByExternalId( + GetCustomObjectInstancesByExternalIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .externalId("external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**externalId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.unstable.customObjectInstances.createCustomObjectInstances(customObjectTypeIdentifier, request) -> Optional<CustomObjectInstance> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create or update a custom object instance +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().createCustomObjectInstances( + CreateOrUpdateCustomObjectInstanceRequest + .builder() + .customObjectTypeIdentifier("Order") + .externalId("123") + .externalCreatedAt(1392036272) + .externalUpdatedAt(1392036272) + .customAttributes( + new HashMap>() {{ + put("order_number", Optional.of("ORDER-12345")); + put("total_amount", Optional.of("custom_attributes")); + }} + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**externalId:** `Optional` — A unique identifier for the Custom Object instance in the external system it originated from. + +
+
+ +
+
+ +**externalCreatedAt:** `Optional` — The time when the Custom Object instance was created in the external system it originated from. + +
+
+ +
+
+ +**externalUpdatedAt:** `Optional` — The time when the Custom Object instance was last updated in the external system it originated from. + +
+
+ +
+
+ +**customAttributes:** `Optional>>` — The custom attributes which are set for the Custom Object instance. + +
+
+
+
+ + +
+
+
+ +
client.unstable.customObjectInstances.deleteCustomObjectInstancesById(customObjectTypeIdentifier) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance by external_id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.customObjectInstances().deleteCustomObjectInstancesById( + DeleteCustomObjectInstancesByIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .externalId("external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**externalId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.unstable.customObjectInstances.getCustomObjectInstancesById(customObjectTypeIdentifier, id) -> Optional<CustomObjectInstance> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().customObjectInstances().getCustomObjectInstancesById( + GetCustomObjectInstancesByIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**id:** `String` — The id or external_id of the custom object instance + +
+
+
+
+ + +
+
+
+ +
client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId(customObjectTypeIdentifier, id) -> CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance using the Intercom defined id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().customObjectInstances().deleteCustomObjectInstancesByExternalId( + DeleteCustomObjectInstancesByExternalIdRequest + .builder() + .customObjectTypeIdentifier("Order") + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customObjectTypeIdentifier:** `String` — The unique identifier of the custom object type that defines the structure of the custom object instance. + +
+
+ +
+
+ +**id:** `String` — The Intercom defined id of the custom object instance + +
+
+
+
+ + +
+
+
+ +## Data Attributes +
client.unstable.dataAttributes.lisDataAttributes() -> DataAttributeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataAttributes().list( + ListDataAttributesRequest + .builder() + .model(DataAttributesListRequestModel.CONTACT) + .includeArchived(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**model:** `Optional` — Specify the data attribute model to return. + +
+
+ +
+
+ +**includeArchived:** `Optional` — Include archived attributes in the list. By default we return only non archived data attributes. + +
+
+
+
+ + +
+
+
+ +
client.unstable.dataAttributes.createDataAttribute(request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a data attributes for a `contact` or a `company`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().dataAttributes().createDataAttribute(new +HashMap() {{put("key", "value"); +}}); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +
client.unstable.dataAttributes.updateDataAttribute(id, request) -> DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().dataAttributes().updateDataAttribute( + UpdateDataAttributeRequest + .builder() + .id(1) + .body(new + HashMap() {{put("key", "value"); + }}) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The data attribute id + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +## Data Events +
client.unstable.dataEvents.lisDataEvents() -> DataEventSummary +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +> 🚧 +> +> 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](http://en.wikipedia.org/wiki/Percent-encoding) when sending. + +You can optionally define the result page size as well with the `per_page` parameter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().dataEvents().lisDataEvents( + LisDataEventsRequest + .builder() + .filter( + LisDataEventsRequestFilter.of( + LisDataEventsRequestFilterUserId + .builder() + .userId("user_id") + .build() + ) + ) + .type("type") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**filter:** `LisDataEventsRequestFilter` + +
+
+ +
+
+ +**type:** `String` — The value must be user + +
+
+ +
+
+ +**summary:** `Optional` — summary flag + +
+
+
+
+ + +
+
+
+ +
client.unstable.dataEvents.createDataEvent(request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ + +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](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-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](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().dataEvents().createDataEvent(new +HashMap() {{put("key", "value"); +}}); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +
client.unstable.dataEvents.dataEventSummaries(request) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.events().summaries( + ListEventSummariesRequest + .builder() + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `Optional` — Your identifier for the user. + +
+
+ +
+
+ +**eventSummaries:** `Optional` — 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`. + +
+
+
+
+ + +
+
+
+ +## Data Export +
client.unstable.dataExport.createDataExport(request) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().create( + CreateDataExportRequest + .builder() + .createdAtAfter(1734519776) + .createdAtBefore(1734537776) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**createdAtAfter:** `Integer` — The start date that you request data for. It must be formatted as a unix timestamp. + +
+
+ +
+
+ +**createdAtBefore:** `Integer` — The end date that you request data for. It must be formatted as a unix timestamp. + +
+
+
+
+ + +
+
+
+ +
client.unstable.dataExport.getDataExport(jobIdentifier) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().find( + FindDataExportRequest + .builder() + .jobIdentifier("job_identifier") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` — job_identifier + +
+
+
+
+ + +
+
+
+ +
client.unstable.dataExport.cancelDataExport(jobIdentifier) -> DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can cancel your job +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().cancel( + CancelDataExportRequest + .builder() + .jobIdentifier("job_identifier") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` — job_identifier + +
+
+
+
+ + +
+
+
+ +
client.unstable.dataExport.downloadDataExport(jobIdentifier) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.dataExport().download( + DownloadDataExportRequest + .builder() + .jobIdentifier("job_identifier") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**jobIdentifier:** `String` — job_identifier + +
+
+
+
+ + +
+
+
+ +## Jobs +
client.unstable.jobs.status(id) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve the status of job execution. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().jobs().status( + JobsStatusRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the job which is given by Intercom + +
+
+
+
+ + +
+
+
+ +## Macros +
client.unstable.macros.listMacros() -> MacroList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all macros (saved replies) in your workspace for use in automating responses. + +The macros are returned in descending order by updated_at. + +**Pagination** + +This endpoint uses cursor-based pagination via the `starting_after` parameter. The cursor is a Base64-encoded JSON array containing `[updated_at, id]` of the last item from the previous page. + +**Placeholder Transformation** + +The API transforms Intercom placeholders to a more standard XML-like format: +- From: `{{user.name | fallback: 'there'}}` +- To: `` +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().macros().listMacros( + ListMacrosRequest + .builder() + .perPage(1) + .startingAfter("WzE3MTk0OTM3NTcuMCwgIjEyMyJd") + .updatedSince(1000000L) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**perPage:** `Optional` — The number of results per page + +
+
+ +
+
+ +**startingAfter:** `Optional` — Base64-encoded cursor containing [updated_at, id] for pagination + +
+
+ +
+
+ +**updatedSince:** `Optional` — Unix timestamp to filter macros updated after this time + +
+
+
+
+ + +
+
+
+ +
client.unstable.macros.getMacro(id) -> Optional<Macro> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single macro (saved reply) by its ID. The macro will only be returned if it is visible to the authenticated user based on its visibility settings. + +**Visibility Rules** + +A macro is returned based on its `visible_to` setting: +- `everyone`: Always visible to all team members +- `specific_teams`: Only visible if the authenticated user belongs to one of the teams specified in `visible_to_team_ids` + +If a macro exists but is not visible to the authenticated user, a 404 error is returned. + +**Placeholder Transformation** + +The API transforms Intercom placeholders to a more standard XML-like format in the `body` field: +- From: `{{user.name | fallback: 'there'}}` +- To: `` + +Default values in placeholders are HTML-escaped for security. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().macros().getMacro( + GetMacroRequest + .builder() + .id("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier of the macro + +
+
+
+
+ + +
+
+
+ +## Messages +
client.unstable.messages.createMessage(request) -> Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email, sms or whatsapp. + +> 🚧 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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().messages().createMessage(new +HashMap() {{put("from", new + HashMap() {{put("type", "user"); + put("id", "6762f2341bb69f9f2193bc17"); + }}); + put("body", "heyy"); + put("referer", "https://twitter.com/bob"); +}}); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + + + + + + + + + + + +
client.unstable.messages.getWhatsAppMessageStatus() -> WhatsappMessageStatusList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().messages().getWhatsAppMessageStatus( + GetWhatsAppMessageStatusRequest + .builder() + .rulesetId("ruleset_id") + .perPage(1) + .startingAfter("starting_after") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**rulesetId:** `String` — The unique identifier for the set of messages to check status for + +
+
+ +
+
+ +**perPage:** `Optional` — Number of results per page (default 50, max 100) + +
+
+ +
+
+ +**startingAfter:** `Optional` — Cursor for pagination, used to fetch the next page of results + +
+
+
+
+ + +
+
+
+ +## News +
client.unstable.news.listNewsItems() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().items().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.news.createNewsItem(request) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a news item +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().items().create( + NewsItemRequest + .builder() + .title("Halloween is here!") + .senderId(991267834) + .body("

New costumes in store for this spooky season

") + .state(NewsItemRequestState.LIVE) + .deliverSilently(true) + .labels( + Optional.of( + Arrays.asList("Product", "Update", "New") + ) + ) + .reactions( + Optional.of( + Arrays.asList(Optional.of("😆"), Optional.of("😅")) + ) + ) + .newsfeedAssignments( + Optional.of( + Arrays.asList( + NewsfeedAssignment + .builder() + .newsfeedId(53) + .publishedAt(1664638214) + .build() + ) + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
client.unstable.news.retrieveNewsItem(id) -> NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().news().retrieveNewsItem( + RetrieveNewsItemRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.news.updateNewsItem(id, request) -> NewsItem +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().news().updateNewsItem( + UpdateNewsItemRequest + .builder() + .id(1) + .body( + NewsItemRequest + .builder() + .title("Christmas is here!") + .senderId(991267845) + .body("

New gifts in store for the jolly season

") + .reactions( + Optional.of( + Arrays.asList(Optional.of("😝"), Optional.of("😂")) + ) + ) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the news item which is given by Intercom. + +
+
+ +
+
+ +**request:** `NewsItemRequest` + +
+
+
+
+ + +
+
+
+ +
client.unstable.news.deleteNewsItem(id) -> DeletedObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single news item. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().news().deleteNewsItem( + DeleteNewsItemRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The unique identifier for the news item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.news.listLiveNewsfeedItems(id) -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items that are live on a given newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().news().listLiveNewsfeedItems( + ListLiveNewsfeedItemsRequest + .builder() + .id("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.news.listNewsfeeds() -> PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all newsfeeds +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.news().feeds().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.news.retrieveNewsfeed(id) -> Newsfeed +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single newsfeed +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().news().retrieveNewsfeed( + RetrieveNewsfeedRequest + .builder() + .id("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the news feed item which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Segments +
client.unstable.segments.listSegments() -> SegmentList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.segments().list( + ListSegmentsRequest + .builder() + .includeCount(true) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**includeCount:** `Optional` — It includes the count of contacts that belong to each segment. + +
+
+
+
+ + +
+
+
+ +
client.unstable.segments.retrieveSegment(id) -> Segment +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single segment. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().segments().retrieveSegment( + RetrieveSegmentRequest + .builder() + .id("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identified of a given segment. + +
+
+
+
+ + +
+
+
+ +## Switch +
client.unstable.switch_.createPhoneSwitch(request) -> Optional<PhoneSwitch> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().switch_().createPhoneSwitch(new +HashMap() {{put("key", "value"); +}}); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +## Calls +
client.unstable.calls.listCalls() -> CallList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a paginated list of calls. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.calls().listCalls( + ListCallsRequest + .builder() + .page(1) + .perPage(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `Optional` — The page of results to fetch. Defaults to first page + +
+
+ +
+
+ +**perPage:** `Optional` — How many results to display per page. Defaults to 25. Max 25. + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.showCall(id) -> Call +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single call by id. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().calls().showCall( + ShowCallRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The id of the call to retrieve + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.showCallRecording(id) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Redirects to a signed URL for the call's recording if it exists. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().calls().showCallRecording( + ShowCallRecordingRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The id of the call + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.showCallTranscript(id) -> String +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns the transcript for the specified call as a downloadable text file. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().calls().showCallTranscript( + ShowCallTranscriptRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The id of the call + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.listCallsWithTranscripts(request) -> ListCallsWithTranscriptsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve calls by a list of conversation ids and include transcripts when available. +A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.calls().listCallsWithTranscripts( + ListCallsWithTranscriptsRequest + .builder() + .conversationIds( + Arrays.asList("64619700005694", "64619700005695") + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**conversationIds:** `List` — A list of conversation ids to fetch calls for. Maximum 20. + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.registerFinVoiceCall(request) -> AiCallResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Register a Fin Voice call with Intercom. This endpoint creates an external reference +that links an external call identifier to an Intercom call and conversation. + +The call can be from different sources: +- AWS Connect (default) +- Five9 +- Zoom Phone +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().calls().registerFinVoiceCall( + Optional.of( + RegisterFinVoiceCallRequest + .builder() + .phoneNumber("+1234567890") + .callId("call-123-abc") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Optional` + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.collectFinVoiceCallById(id) -> AiCallResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve information about a Fin Voice call using the external reference ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().calls().collectFinVoiceCallById( + CollectFinVoiceCallByIdRequest + .builder() + .id(1) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `Integer` — The external reference ID + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.collectFinVoiceCallByExternalId(externalId) -> AiCallResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve information about a Fin Voice call using the external call identifier. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().calls().collectFinVoiceCallByExternalId( + CollectFinVoiceCallByExternalIdRequest + .builder() + .externalId("external_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**externalId:** `String` — The external call identifier from the call provider + +
+
+
+
+ + +
+
+
+ +
client.unstable.calls.collectFinVoiceCallByPhoneNumber(phoneNumber) -> Error +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve information about a Fin Voice call using the phone number. + +Returns the most recent matched call for the given phone number, ordered by creation date. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().calls().collectFinVoiceCallByPhoneNumber( + CollectFinVoiceCallByPhoneNumberRequest + .builder() + .phoneNumber("phone_number") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**phoneNumber:** `String` — Phone number in E.164 format + +
+
+
+
+ + +
+
+
+ +## Teams +
client.unstable.teams.listTeams() -> TeamList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This will return a list of team objects for the App. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.teams().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.teams.retrieveTeam(id) -> Team +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single team, containing an array of admins that belong to this team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().teams().retrieveTeam( + RetrieveTeamRequest + .builder() + .id("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier of a given team. + +
+
+
+
+ + +
+
+
+ +## Ticket States +
client.unstable.ticketStates.listTicketStates() -> TicketStateList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket states for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketStates().listTicketStates(); +``` +
+
+
+
+ + +
+
+
+ +## Ticket Type Attributes +
client.unstable.ticketTypeAttributes.createTicketTypeAttribute(ticketTypeId, request) -> Optional<TicketTypeAttribute> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().attributes().create( + CreateTicketTypeAttributeRequest + .builder() + .ticketTypeId("ticket_type_id") + .name("Attribute Title") + .description("Attribute Description") + .dataType(CreateTicketTypeAttributeRequestDataType.STRING) + .requiredToCreate(false) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketTypeId:** `String` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**name:** `String` — The name of the ticket type attribute + +
+
+ +
+
+ +**description:** `String` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**dataType:** `CreateTicketTypeAttributeRequestDataType` — The data type of the attribute + +
+
+ +
+
+ +**requiredToCreate:** `Optional` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**requiredToCreateForContacts:** `Optional` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**visibleOnCreate:** `Optional` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**visibleToContacts:** `Optional` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**multiline:** `Optional` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**listItems:** `Optional` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**allowMultipleValues:** `Optional` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+
+
+ + +
+
+
+ +
client.unstable.ticketTypeAttributes.updateTicketTypeAttribute(ticketTypeId, id, request) -> Optional<TicketTypeAttribute> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing attribute for a ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().ticketTypeAttributes().updateTicketTypeAttribute( + UpdateTicketTypeAttributeRequest + .builder() + .ticketTypeId("ticket_type_id") + .id("id") + .description("New Attribute Description") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ticketTypeId:** `String` — The unique identifier for the ticket type which is given by Intercom. + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the ticket type attribute which is given by Intercom. + +
+
+ +
+
+ +**name:** `Optional` — The name of the ticket type attribute + +
+
+ +
+
+ +**description:** `Optional` — The description of the attribute presented to the teammate or contact + +
+
+ +
+
+ +**requiredToCreate:** `Optional` — Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. + +
+
+ +
+
+ +**requiredToCreateForContacts:** `Optional` — Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. + +
+
+ +
+
+ +**visibleOnCreate:** `Optional` — Whether the attribute is visible to teammates when creating a ticket in Inbox. + +
+
+ +
+
+ +**visibleToContacts:** `Optional` — Whether the attribute is visible to contacts when creating a ticket in Messenger. + +
+
+ +
+
+ +**multiline:** `Optional` — Whether the attribute allows multiple lines of text (only applicable to string attributes) + +
+
+ +
+
+ +**listItems:** `Optional` — A comma delimited list of items for the attribute value (only applicable to list attributes) + +
+
+ +
+
+ +**allowMultipleValues:** `Optional` — Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) + +
+
+ +
+
+ +**archived:** `Optional` — Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets) + +
+
+
+
+ + +
+
+
+ +## Ticket Types +
client.unstable.ticketTypes.listTicketTypes() -> TicketTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket types for a workspace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.ticketTypes().list(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.ticketTypes.createTicketType(request) -> Optional<TicketType> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new ticket type. +> 📘 Creating ticket types. +> +> Every ticket type will be created with two default attributes: _default_title_ and _default_description_. +> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().ticketTypes().createTicketType(new +HashMap() {{put("key", "value"); +}}); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +
client.unstable.ticketTypes.getTicketType(id) -> Optional<TicketType> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket type. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().ticketTypes().getTicketType( + GetTicketTypeRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the ticket type which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +## Tickets +
client.unstable.tickets.replyTicket(id, request) -> TicketReply +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tickets().replyTicket( + ReplyTicketRequest + .builder() + .id("123") + .body( + ReplyTicketRequestBody.of( + ContactReplyTicketRequest.of( + ContactReplyTicketIntercomUserIdRequest + .builder() + .messageType("comment") + .type("user") + .body("Thanks again :)") + .intercomUserId("6762f2971bb69f9f2193bc49") + .build() + ) + ) + ) + .build() + ); + } +} +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` + +
+
+ +
+
+ +**request:** `ReplyTicketRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.unstable.tickets.enqueueCreateTicket(request) -> Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.tickets().enqueueCreateTicket( + EnqueueCreateTicketRequest + .builder() + .ticketTypeId("1234") + .contacts( + Arrays.asList( + CreateTicketRequestContactsItem.of( + CreateTicketRequestContactsItemId + .builder() + .id("6762f2d81bb69f9f2193bc54") + .build() + ) + ) + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**skipNotifications:** `Optional` — Option to disable notifications when a Ticket is created. + +
+
+
+
+ + +
+
+
+ +
client.unstable.tickets.getTicket(id) -> Optional<Ticket> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tickets().getTicket( + GetTicketRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.tickets.updateTicket(id, request) -> Optional<Ticket> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a ticket. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tickets().updateTicket( + UpdateTicketRequest + .builder() + .id("id") + .ticketAttributes( + new HashMap() {{ + put("_default_title_", "example"); + put("_default_description_", "there is a problem"); + }} + ) + .ticketStateId("123") + .open(true) + .snoozedUntil(1673609604) + .adminId(991268011) + .assigneeId("123") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the ticket which is given by Intercom + +
+
+ +
+
+ +**ticketAttributes:** `Optional>` — The attributes set on the ticket. + +
+
+ +
+
+ +**ticketStateId:** `Optional` — The ID of the ticket state associated with the ticket type. + +
+
+ +
+
+ +**companyId:** `Optional` — 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. + +
+
+ +
+
+ +**open:** `Optional` — Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. + +
+
+ +
+
+ +**isShared:** `Optional` — Specify whether the ticket is visible to users. + +
+
+ +
+
+ +**snoozedUntil:** `Optional` — The time you want the ticket to reopen. + +
+
+ +
+
+ +**adminId:** `Optional` — The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + +
+
+ +
+
+ +**assigneeId:** `Optional` — The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + +
+
+
+
+ + +
+
+
+ +
client.unstable.tickets.deleteTicket(id) -> DeleteTicketResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a ticket using the Intercom provided ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tickets().deleteTicket( + DeleteTicketRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier for the ticket which is given by Intercom. + +
+
+
+
+ + +
+
+
+ +
client.unstable.tickets.searchTickets(request) -> TicketList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) 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) | +| title | String | +| 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 | + +{% admonition type="info" name="Searching by Category" %} +When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: +* For **Customer** category tickets, use the term `request`. +* For **Back-office** category tickets, use the term `task`. +* For **Tracker** category tickets, use the term `tracker`. +{% /admonition %} + +### 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 | +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().tickets().searchTickets( + SearchRequest + .builder() + .query( + SearchRequestQuery.of( + SingleFilterSearchRequest + .builder() + .value( + SingleFilterSearchRequestValue.of() + ) + .build() + ) + ) + .pagination( + StartingAfterPaging + .builder() + .perPage(5) + .build() + ) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `SearchRequest` + +
+
+
+
+ + +
+
+
+ +## Visitors +
client.unstable.visitors.retrieveVisitorWithUserId() -> Optional<Visitor> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single visitor. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.visitors().find( + FindVisitorRequest + .builder() + .userId("user_id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `String` — The user_id of the Visitor you want to retrieve. + +
+
+
+
+ + +
+
+
+ +
client.unstable.visitors.updateVisitor(request) -> Optional<Visitor> +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a PUT request to `/visitors` will result in an update of an existing Visitor. + +**Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. + +**Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.visitors().update( + UpdateVisitorRequest.of( + UpdateVisitorRequestWithId + .builder() + .id("6762f30c1bb69f9f2193bc5e") + .name("Gareth Bale") + .build() + ) +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Object` + +
+
+
+
+ + +
+
+
+ +
client.unstable.visitors.convertVisitor(request) -> Contact +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a Visitor to a Contact of role type `lead` or `user`. + +> 📘 What happens upon a visitor being converted? +> +> If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().visitors().convertVisitor( + ConvertVisitorRequest + .builder() + .type("user") + .user(new + HashMap() {{put("email", "foo@bar.com"); + }}) + .visitor(new + HashMap() {{put("user_id", "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3"); + }}) + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**type:** `String` — Represents the role of the Contact model. Accepts `lead` or `user`. + +
+
+ +
+
+ +**user:** `Object` + +
+
+ +
+
+ +**visitor:** `Object` + +
+
+
+
+ + +
+
+
+ +## Brands +
client.unstable.brands.listBrands() -> BrandList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves all brands for the workspace, including the default brand. +The default brand id always matches the workspace +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().brands().listBrands(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.brands.retrieveBrand(id) -> Brand +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetches a specific brand by its unique identifier +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().brands().retrieveBrand( + RetrieveBrandRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier of the brand + +
+
+
+
+ + +
+
+
+ +## Emails +
client.unstable.emails.listEmails() -> EmailList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Lists all sender email address settings for the workspace +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().emails().listEmails(); +``` +
+
+
+
+ + +
+
+
+ +
client.unstable.emails.retrieveEmail(id) -> EmailSetting +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetches a specific email setting by its unique identifier +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.unstable().emails().retrieveEmail( + RetrieveEmailRequest + .builder() + .id("id") + .build() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `String` — The unique identifier of the email setting + +
+
+
+
+ + +
+
+
diff --git a/src/main/java/com/intercom/api/AsyncIntercom.java b/src/main/java/com/intercom/api/AsyncIntercom.java index 7973c6a..1a036b6 100644 --- a/src/main/java/com/intercom/api/AsyncIntercom.java +++ b/src/main/java/com/intercom/api/AsyncIntercom.java @@ -6,14 +6,22 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.Suppliers; import com.intercom.api.resources.admins.AsyncAdminsClient; +import com.intercom.api.resources.aicontent.AsyncAiContentClient; import com.intercom.api.resources.articles.AsyncArticlesClient; +import com.intercom.api.resources.awaystatusreasons.AsyncAwayStatusReasonsClient; +import com.intercom.api.resources.calls.AsyncCallsClient; 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.customobjectinstances.AsyncCustomObjectInstancesClient; import com.intercom.api.resources.dataattributes.AsyncDataAttributesClient; import com.intercom.api.resources.dataexport.AsyncDataExportClient; import com.intercom.api.resources.events.AsyncEventsClient; +import com.intercom.api.resources.export.AsyncExportClient; import com.intercom.api.resources.helpcenters.AsyncHelpCentersClient; +import com.intercom.api.resources.internalarticles.AsyncInternalArticlesClient; +import com.intercom.api.resources.jobs.AsyncJobsClient; import com.intercom.api.resources.messages.AsyncMessagesClient; import com.intercom.api.resources.news.AsyncNewsClient; import com.intercom.api.resources.notes.AsyncNotesClient; @@ -23,6 +31,7 @@ import com.intercom.api.resources.tags.AsyncTagsClient; import com.intercom.api.resources.teams.AsyncTeamsClient; import com.intercom.api.resources.tickets.AsyncTicketsClient; +import com.intercom.api.resources.ticketstates.AsyncTicketStatesClient; import com.intercom.api.resources.tickettypes.AsyncTicketTypesClient; import com.intercom.api.resources.unstable.AsyncUnstableClient; import com.intercom.api.resources.visitors.AsyncVisitorsClient; @@ -33,10 +42,20 @@ public class AsyncIntercom { protected final Supplier adminsClient; + protected final Supplier aiContentClient; + protected final Supplier articlesClient; + protected final Supplier awayStatusReasonsClient; + + protected final Supplier exportClient; + + protected final Supplier dataExportClient; + protected final Supplier helpCentersClient; + protected final Supplier internalArticlesClient; + protected final Supplier companiesClient; protected final Supplier contactsClient; @@ -47,11 +66,15 @@ public class AsyncIntercom { protected final Supplier conversationsClient; + protected final Supplier customChannelEventsClient; + + protected final Supplier customObjectInstancesClient; + protected final Supplier dataAttributesClient; protected final Supplier eventsClient; - protected final Supplier dataExportClient; + protected final Supplier jobsClient; protected final Supplier messagesClient; @@ -61,8 +84,12 @@ public class AsyncIntercom { protected final Supplier phoneCallRedirectsClient; + protected final Supplier callsClient; + protected final Supplier teamsClient; + protected final Supplier ticketStatesClient; + protected final Supplier ticketTypesClient; protected final Supplier ticketsClient; @@ -76,21 +103,30 @@ public class AsyncIntercom { public AsyncIntercom(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.dataExportClient = Suppliers.memoize(() -> new AsyncDataExportClient(clientOptions)); this.helpCentersClient = Suppliers.memoize(() -> new AsyncHelpCentersClient(clientOptions)); + this.internalArticlesClient = Suppliers.memoize(() -> new AsyncInternalArticlesClient(clientOptions)); this.companiesClient = Suppliers.memoize(() -> new AsyncCompaniesClient(clientOptions)); this.contactsClient = Suppliers.memoize(() -> new AsyncContactsClient(clientOptions)); this.notesClient = Suppliers.memoize(() -> new AsyncNotesClient(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.eventsClient = Suppliers.memoize(() -> new AsyncEventsClient(clientOptions)); - this.dataExportClient = Suppliers.memoize(() -> new AsyncDataExportClient(clientOptions)); + this.jobsClient = Suppliers.memoize(() -> new AsyncJobsClient(clientOptions)); this.messagesClient = Suppliers.memoize(() -> new AsyncMessagesClient(clientOptions)); this.segmentsClient = Suppliers.memoize(() -> new AsyncSegmentsClient(clientOptions)); this.subscriptionTypesClient = Suppliers.memoize(() -> new AsyncSubscriptionTypesClient(clientOptions)); this.phoneCallRedirectsClient = Suppliers.memoize(() -> new AsyncPhoneCallRedirectsClient(clientOptions)); + this.callsClient = Suppliers.memoize(() -> new AsyncCallsClient(clientOptions)); this.teamsClient = Suppliers.memoize(() -> new AsyncTeamsClient(clientOptions)); + this.ticketStatesClient = Suppliers.memoize(() -> new AsyncTicketStatesClient(clientOptions)); this.ticketTypesClient = Suppliers.memoize(() -> new AsyncTicketTypesClient(clientOptions)); this.ticketsClient = Suppliers.memoize(() -> new AsyncTicketsClient(clientOptions)); this.visitorsClient = Suppliers.memoize(() -> new AsyncVisitorsClient(clientOptions)); @@ -102,14 +138,34 @@ 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 AsyncDataExportClient dataExport() { + return this.dataExportClient.get(); + } + public AsyncHelpCentersClient helpCenters() { return this.helpCentersClient.get(); } + public AsyncInternalArticlesClient internalArticles() { + return this.internalArticlesClient.get(); + } + public AsyncCompaniesClient companies() { return this.companiesClient.get(); } @@ -130,6 +186,14 @@ 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(); } @@ -138,8 +202,8 @@ public AsyncEventsClient events() { return this.eventsClient.get(); } - public AsyncDataExportClient dataExport() { - return this.dataExportClient.get(); + public AsyncJobsClient jobs() { + return this.jobsClient.get(); } public AsyncMessagesClient messages() { @@ -158,10 +222,18 @@ public AsyncPhoneCallRedirectsClient phoneCallRedirects() { return this.phoneCallRedirectsClient.get(); } + public AsyncCallsClient calls() { + return this.callsClient.get(); + } + public AsyncTeamsClient teams() { return this.teamsClient.get(); } + public AsyncTicketStatesClient ticketStates() { + return this.ticketStatesClient.get(); + } + public AsyncTicketTypesClient ticketTypes() { return this.ticketTypesClient.get(); } diff --git a/src/main/java/com/intercom/api/AsyncIntercomBuilder.java b/src/main/java/com/intercom/api/AsyncIntercomBuilder.java index 778432b..e01c37b 100644 --- a/src/main/java/com/intercom/api/AsyncIntercomBuilder.java +++ b/src/main/java/com/intercom/api/AsyncIntercomBuilder.java @@ -5,15 +5,24 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.Environment; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; import okhttp3.OkHttpClient; -public final class AsyncIntercomBuilder { - private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); +public class AsyncIntercomBuilder { + private Optional timeout = Optional.empty(); + + private Optional maxRetries = Optional.empty(); + + private final Map customHeaders = new HashMap<>(); private String token = System.getenv("INTERCOM_API_KEY"); private Environment environment = Environment.US_PRODUCTION; + private OkHttpClient httpClient; + /** * Sets token. * Defaults to the INTERCOM_API_KEY environment variable. @@ -37,7 +46,7 @@ public AsyncIntercomBuilder url(String url) { * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. */ public AsyncIntercomBuilder timeout(int timeout) { - this.clientOptionsBuilder.timeout(timeout); + this.timeout = Optional.of(timeout); return this; } @@ -45,7 +54,7 @@ public AsyncIntercomBuilder timeout(int timeout) { * Sets the maximum number of retries for the client. Defaults to 2 retries. */ public AsyncIntercomBuilder maxRetries(int maxRetries) { - this.clientOptionsBuilder.maxRetries(maxRetries); + this.maxRetries = Optional.of(maxRetries); return this; } @@ -53,16 +62,145 @@ public AsyncIntercomBuilder maxRetries(int maxRetries) { * Sets the underlying OkHttp client */ public AsyncIntercomBuilder httpClient(OkHttpClient httpClient) { - this.clientOptionsBuilder.httpClient(httpClient); + this.httpClient = httpClient; return this; } + /** + * Add a custom header to be sent with all requests. + * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. + * + * @param name The header name + * @param value The header value + * @return This builder for method chaining + */ + public AsyncIntercomBuilder addHeader(String name, String value) { + this.customHeaders.put(name, value); + return this; + } + + protected ClientOptions buildClientOptions() { + ClientOptions.Builder builder = ClientOptions.builder(); + setEnvironment(builder); + setAuthentication(builder); + setHttpClient(builder); + setTimeouts(builder); + setRetries(builder); + for (Map.Entry header : this.customHeaders.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + setAdditional(builder); + return builder.build(); + } + + /** + * Sets the environment configuration for the client. + * Override this method to modify URLs or add environment-specific logic. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setEnvironment(ClientOptions.Builder builder) { + builder.environment(this.environment); + } + + /** + * Override this method to customize authentication. + * This method is called during client options construction to set up authentication headers. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAuthentication(ClientOptions.Builder builder) {
+     *     super.setAuthentication(builder); // Keep existing auth
+     *     builder.addHeader("X-API-Key", this.apiKey);
+     * }
+     * }
+ */ + protected void setAuthentication(ClientOptions.Builder builder) { + if (this.token != null) { + builder.addHeader("Authorization", "Bearer " + this.token); + } + } + + /** + * Sets the request timeout configuration. + * Override this method to customize timeout behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setTimeouts(ClientOptions.Builder builder) { + if (this.timeout.isPresent()) { + builder.timeout(this.timeout.get()); + } + } + + /** + * Sets the retry configuration for failed requests. + * Override this method to implement custom retry strategies. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setRetries(ClientOptions.Builder builder) { + if (this.maxRetries.isPresent()) { + builder.maxRetries(this.maxRetries.get()); + } + } + + /** + * Sets the OkHttp client configuration. + * Override this method to customize HTTP client behavior (interceptors, connection pools, etc). + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setHttpClient(ClientOptions.Builder builder) { + if (this.httpClient != null) { + builder.httpClient(this.httpClient); + } + } + + /** + * Override this method to add any additional configuration to the client. + * This method is called at the end of the configuration chain, allowing you to add + * custom headers, modify settings, or perform any other client customization. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAdditional(ClientOptions.Builder builder) {
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Client-Version", "1.0.0");
+     * }
+     * }
+ */ + protected void setAdditional(ClientOptions.Builder builder) {} + + /** + * Override this method to add custom validation logic before the client is built. + * This method is called at the beginning of the build() method to ensure the configuration is valid. + * Throw an exception to prevent client creation if validation fails. + * + * Example: + *
{@code
+     * @Override
+     * protected void validateConfiguration() {
+     *     super.validateConfiguration(); // Run parent validations
+     *     if (tenantId == null || tenantId.isEmpty()) {
+     *         throw new IllegalStateException("tenantId is required");
+     *     }
+     * }
+     * }
+ */ + protected void validateConfiguration() {} + public AsyncIntercom build() { if (token == null) { throw new RuntimeException("Please provide token or set the INTERCOM_API_KEY environment variable."); } - this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); - clientOptionsBuilder.environment(this.environment); - return new AsyncIntercom(clientOptionsBuilder.build()); + validateConfiguration(); + return new AsyncIntercom(buildClientOptions()); } } diff --git a/src/main/java/com/intercom/api/Intercom.java b/src/main/java/com/intercom/api/Intercom.java index 4d9bfec..11fa252 100644 --- a/src/main/java/com/intercom/api/Intercom.java +++ b/src/main/java/com/intercom/api/Intercom.java @@ -6,14 +6,22 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.Suppliers; import com.intercom.api.resources.admins.AdminsClient; +import com.intercom.api.resources.aicontent.AiContentClient; import com.intercom.api.resources.articles.ArticlesClient; +import com.intercom.api.resources.awaystatusreasons.AwayStatusReasonsClient; +import com.intercom.api.resources.calls.CallsClient; 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.customobjectinstances.CustomObjectInstancesClient; import com.intercom.api.resources.dataattributes.DataAttributesClient; import com.intercom.api.resources.dataexport.DataExportClient; import com.intercom.api.resources.events.EventsClient; +import com.intercom.api.resources.export.ExportClient; import com.intercom.api.resources.helpcenters.HelpCentersClient; +import com.intercom.api.resources.internalarticles.InternalArticlesClient; +import com.intercom.api.resources.jobs.JobsClient; import com.intercom.api.resources.messages.MessagesClient; import com.intercom.api.resources.news.NewsClient; import com.intercom.api.resources.notes.NotesClient; @@ -23,6 +31,7 @@ import com.intercom.api.resources.tags.TagsClient; import com.intercom.api.resources.teams.TeamsClient; import com.intercom.api.resources.tickets.TicketsClient; +import com.intercom.api.resources.ticketstates.TicketStatesClient; import com.intercom.api.resources.tickettypes.TicketTypesClient; import com.intercom.api.resources.unstable.UnstableClient; import com.intercom.api.resources.visitors.VisitorsClient; @@ -33,10 +42,20 @@ public class Intercom { protected final Supplier adminsClient; + protected final Supplier aiContentClient; + protected final Supplier articlesClient; + protected final Supplier awayStatusReasonsClient; + + protected final Supplier exportClient; + + protected final Supplier dataExportClient; + protected final Supplier helpCentersClient; + protected final Supplier internalArticlesClient; + protected final Supplier companiesClient; protected final Supplier contactsClient; @@ -47,11 +66,15 @@ public class Intercom { protected final Supplier conversationsClient; + protected final Supplier customChannelEventsClient; + + protected final Supplier customObjectInstancesClient; + protected final Supplier dataAttributesClient; protected final Supplier eventsClient; - protected final Supplier dataExportClient; + protected final Supplier jobsClient; protected final Supplier messagesClient; @@ -61,8 +84,12 @@ public class Intercom { protected final Supplier phoneCallRedirectsClient; + protected final Supplier callsClient; + protected final Supplier teamsClient; + protected final Supplier ticketStatesClient; + protected final Supplier ticketTypesClient; protected final Supplier ticketsClient; @@ -76,21 +103,30 @@ public class Intercom { public Intercom(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.dataExportClient = Suppliers.memoize(() -> new DataExportClient(clientOptions)); this.helpCentersClient = Suppliers.memoize(() -> new HelpCentersClient(clientOptions)); + this.internalArticlesClient = Suppliers.memoize(() -> new InternalArticlesClient(clientOptions)); this.companiesClient = Suppliers.memoize(() -> new CompaniesClient(clientOptions)); this.contactsClient = Suppliers.memoize(() -> new ContactsClient(clientOptions)); this.notesClient = Suppliers.memoize(() -> new NotesClient(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.eventsClient = Suppliers.memoize(() -> new EventsClient(clientOptions)); - this.dataExportClient = Suppliers.memoize(() -> new DataExportClient(clientOptions)); + this.jobsClient = Suppliers.memoize(() -> new JobsClient(clientOptions)); this.messagesClient = Suppliers.memoize(() -> new MessagesClient(clientOptions)); this.segmentsClient = Suppliers.memoize(() -> new SegmentsClient(clientOptions)); this.subscriptionTypesClient = Suppliers.memoize(() -> new SubscriptionTypesClient(clientOptions)); this.phoneCallRedirectsClient = Suppliers.memoize(() -> new PhoneCallRedirectsClient(clientOptions)); + this.callsClient = Suppliers.memoize(() -> new CallsClient(clientOptions)); this.teamsClient = Suppliers.memoize(() -> new TeamsClient(clientOptions)); + this.ticketStatesClient = Suppliers.memoize(() -> new TicketStatesClient(clientOptions)); this.ticketTypesClient = Suppliers.memoize(() -> new TicketTypesClient(clientOptions)); this.ticketsClient = Suppliers.memoize(() -> new TicketsClient(clientOptions)); this.visitorsClient = Suppliers.memoize(() -> new VisitorsClient(clientOptions)); @@ -102,14 +138,34 @@ 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 DataExportClient dataExport() { + return this.dataExportClient.get(); + } + public HelpCentersClient helpCenters() { return this.helpCentersClient.get(); } + public InternalArticlesClient internalArticles() { + return this.internalArticlesClient.get(); + } + public CompaniesClient companies() { return this.companiesClient.get(); } @@ -130,6 +186,14 @@ 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(); } @@ -138,8 +202,8 @@ public EventsClient events() { return this.eventsClient.get(); } - public DataExportClient dataExport() { - return this.dataExportClient.get(); + public JobsClient jobs() { + return this.jobsClient.get(); } public MessagesClient messages() { @@ -158,10 +222,18 @@ public PhoneCallRedirectsClient phoneCallRedirects() { return this.phoneCallRedirectsClient.get(); } + public CallsClient calls() { + return this.callsClient.get(); + } + public TeamsClient teams() { return this.teamsClient.get(); } + public TicketStatesClient ticketStates() { + return this.ticketStatesClient.get(); + } + public TicketTypesClient ticketTypes() { return this.ticketTypesClient.get(); } diff --git a/src/main/java/com/intercom/api/IntercomBuilder.java b/src/main/java/com/intercom/api/IntercomBuilder.java index ff8fbaa..900be36 100644 --- a/src/main/java/com/intercom/api/IntercomBuilder.java +++ b/src/main/java/com/intercom/api/IntercomBuilder.java @@ -5,15 +5,24 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.Environment; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; import okhttp3.OkHttpClient; -public final class IntercomBuilder { - private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); +public class IntercomBuilder { + private Optional timeout = Optional.empty(); + + private Optional maxRetries = Optional.empty(); + + private final Map customHeaders = new HashMap<>(); private String token = System.getenv("INTERCOM_API_KEY"); private Environment environment = Environment.US_PRODUCTION; + private OkHttpClient httpClient; + /** * Sets token. * Defaults to the INTERCOM_API_KEY environment variable. @@ -37,7 +46,7 @@ public IntercomBuilder url(String url) { * Sets the timeout (in seconds) for the client. Defaults to 60 seconds. */ public IntercomBuilder timeout(int timeout) { - this.clientOptionsBuilder.timeout(timeout); + this.timeout = Optional.of(timeout); return this; } @@ -45,7 +54,7 @@ public IntercomBuilder timeout(int timeout) { * Sets the maximum number of retries for the client. Defaults to 2 retries. */ public IntercomBuilder maxRetries(int maxRetries) { - this.clientOptionsBuilder.maxRetries(maxRetries); + this.maxRetries = Optional.of(maxRetries); return this; } @@ -53,16 +62,145 @@ public IntercomBuilder maxRetries(int maxRetries) { * Sets the underlying OkHttp client */ public IntercomBuilder httpClient(OkHttpClient httpClient) { - this.clientOptionsBuilder.httpClient(httpClient); + this.httpClient = httpClient; return this; } + /** + * Add a custom header to be sent with all requests. + * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. + * + * @param name The header name + * @param value The header value + * @return This builder for method chaining + */ + public IntercomBuilder addHeader(String name, String value) { + this.customHeaders.put(name, value); + return this; + } + + protected ClientOptions buildClientOptions() { + ClientOptions.Builder builder = ClientOptions.builder(); + setEnvironment(builder); + setAuthentication(builder); + setHttpClient(builder); + setTimeouts(builder); + setRetries(builder); + for (Map.Entry header : this.customHeaders.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + setAdditional(builder); + return builder.build(); + } + + /** + * Sets the environment configuration for the client. + * Override this method to modify URLs or add environment-specific logic. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setEnvironment(ClientOptions.Builder builder) { + builder.environment(this.environment); + } + + /** + * Override this method to customize authentication. + * This method is called during client options construction to set up authentication headers. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAuthentication(ClientOptions.Builder builder) {
+     *     super.setAuthentication(builder); // Keep existing auth
+     *     builder.addHeader("X-API-Key", this.apiKey);
+     * }
+     * }
+ */ + protected void setAuthentication(ClientOptions.Builder builder) { + if (this.token != null) { + builder.addHeader("Authorization", "Bearer " + this.token); + } + } + + /** + * Sets the request timeout configuration. + * Override this method to customize timeout behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setTimeouts(ClientOptions.Builder builder) { + if (this.timeout.isPresent()) { + builder.timeout(this.timeout.get()); + } + } + + /** + * Sets the retry configuration for failed requests. + * Override this method to implement custom retry strategies. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setRetries(ClientOptions.Builder builder) { + if (this.maxRetries.isPresent()) { + builder.maxRetries(this.maxRetries.get()); + } + } + + /** + * Sets the OkHttp client configuration. + * Override this method to customize HTTP client behavior (interceptors, connection pools, etc). + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setHttpClient(ClientOptions.Builder builder) { + if (this.httpClient != null) { + builder.httpClient(this.httpClient); + } + } + + /** + * Override this method to add any additional configuration to the client. + * This method is called at the end of the configuration chain, allowing you to add + * custom headers, modify settings, or perform any other client customization. + * + * @param builder The ClientOptions.Builder to configure + * + * Example: + *
{@code
+     * @Override
+     * protected void setAdditional(ClientOptions.Builder builder) {
+     *     builder.addHeader("X-Request-ID", () -> UUID.randomUUID().toString());
+     *     builder.addHeader("X-Client-Version", "1.0.0");
+     * }
+     * }
+ */ + protected void setAdditional(ClientOptions.Builder builder) {} + + /** + * Override this method to add custom validation logic before the client is built. + * This method is called at the beginning of the build() method to ensure the configuration is valid. + * Throw an exception to prevent client creation if validation fails. + * + * Example: + *
{@code
+     * @Override
+     * protected void validateConfiguration() {
+     *     super.validateConfiguration(); // Run parent validations
+     *     if (tenantId == null || tenantId.isEmpty()) {
+     *         throw new IllegalStateException("tenantId is required");
+     *     }
+     * }
+     * }
+ */ + protected void validateConfiguration() {} + public Intercom build() { if (token == null) { throw new RuntimeException("Please provide token or set the INTERCOM_API_KEY environment variable."); } - this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token); - clientOptionsBuilder.environment(this.environment); - return new Intercom(clientOptionsBuilder.build()); + validateConfiguration(); + return new Intercom(buildClientOptions()); } } diff --git a/src/main/java/com/intercom/api/core/ApiVersion.java b/src/main/java/com/intercom/api/core/ApiVersion.java index e0f2c7b..86f308c 100644 --- a/src/main/java/com/intercom/api/core/ApiVersion.java +++ b/src/main/java/com/intercom/api/core/ApiVersion.java @@ -9,6 +9,8 @@ public final class ApiVersion { public static final ApiVersion _2_1 = new ApiVersion(Value._2_1, "2.1"); + public static final ApiVersion _2_14 = new ApiVersion(Value._2_14, "2.14"); + public static final ApiVersion _2_2 = new ApiVersion(Value._2_2, "2.2"); public static final ApiVersion _1_0 = new ApiVersion(Value._1_0, "1.0"); @@ -41,8 +43,12 @@ public final class ApiVersion { public static final ApiVersion UNSTABLE = new ApiVersion(Value.UNSTABLE, "Unstable"); + public static final ApiVersion _2_12 = new ApiVersion(Value._2_12, "2.12"); + public static final ApiVersion _2_0 = new ApiVersion(Value._2_0, "2.0"); + public static final ApiVersion _2_13 = new ApiVersion(Value._2_13, "2.13"); + private final Value value; private final String string; @@ -76,6 +82,8 @@ public T visit(Visitor visitor) { switch (value) { case _2_1: return visitor.visit_21(); + case _2_14: + return visitor.visit_214(); case _2_2: return visitor.visit_22(); case _1_0: @@ -108,8 +116,12 @@ public T visit(Visitor visitor) { return visitor.visit_211(); case UNSTABLE: return visitor.visitUnstable(); + case _2_12: + return visitor.visit_212(); case _2_0: return visitor.visit_20(); + case _2_13: + return visitor.visit_213(); case UNKNOWN: default: return visitor.visitUnknown(string); @@ -121,6 +133,8 @@ public static ApiVersion valueOf(String value) { switch (value) { case "2.1": return _2_1; + case "2.14": + return _2_14; case "2.2": return _2_2; case "1.0": @@ -153,8 +167,12 @@ public static ApiVersion valueOf(String value) { return _2_11; case "Unstable": return UNSTABLE; + case "2.12": + return _2_12; case "2.0": return _2_0; + case "2.13": + return _2_13; default: return new ApiVersion(Value.UNKNOWN, value); } @@ -195,6 +213,12 @@ public enum Value { _2_11, + _2_12, + + _2_13, + + _2_14, + UNSTABLE, UNKNOWN @@ -235,6 +259,12 @@ public interface Visitor { T visit_211(); + T visit_212(); + + T visit_213(); + + T visit_214(); + T visitUnstable(); T visitUnknown(String unknownType); diff --git a/src/main/java/com/intercom/api/core/ClientOptions.java b/src/main/java/com/intercom/api/core/ClientOptions.java index 4c66e52..20ac75c 100644 --- a/src/main/java/com/intercom/api/core/ClientOptions.java +++ b/src/main/java/com/intercom/api/core/ClientOptions.java @@ -21,13 +21,15 @@ public final class ClientOptions { private final int timeout; + private final int maxRetries; + /** * version.toString() is sent as the "Intercom-Version" header. */ private final ApiVersion version; /** - * @param version Defaults to "2.11" if empty + * @param version Defaults to "2.14" if empty */ private ClientOptions( Environment environment, @@ -35,22 +37,24 @@ private ClientOptions( Map> headerSuppliers, OkHttpClient httpClient, int timeout, + int maxRetries, Optional version) { this.environment = environment; this.headers = new HashMap<>(); this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "io.intercom:intercom-java/3.0.0"); + put("User-Agent", "io.intercom:intercom-java/4.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"); + put("X-Fern-SDK-Version", "4.0.0"); } }); this.headerSuppliers = headerSuppliers; this.httpClient = httpClient; this.timeout = timeout; - this.version = version.orElse(ApiVersion._2_11); + this.maxRetries = maxRetries; + this.version = version.orElse(ApiVersion._2_14); this.headers.put("Intercom-Version", this.version.toString()); } @@ -100,11 +104,15 @@ public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { .build(); } + public int maxRetries() { + return this.maxRetries; + } + public static Builder builder() { return new Builder(); } - public static final class Builder { + public static class Builder { private Environment environment; private final Map headers = new HashMap<>(); @@ -167,7 +175,7 @@ public Builder httpClient(OkHttpClient httpClient) { * version.toString() is sent as the "Intercom-Version" header. */ public Builder version(ApiVersion version) { - this.version = Optional.of(version); + this.version = Optional.ofNullable(version); return this; } @@ -193,7 +201,24 @@ public ClientOptions build() { this.httpClient = httpClientBuilder.build(); this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); - return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get(), version); + return new ClientOptions( + environment, headers, headerSuppliers, httpClient, this.timeout.get(), this.maxRetries, version); + } + + /** + * Create a new Builder initialized with values from an existing ClientOptions + */ + public static Builder from(ClientOptions clientOptions) { + Builder builder = new Builder(); + builder.environment = clientOptions.environment(); + builder.timeout = Optional.of(clientOptions.timeout(null)); + builder.httpClient = clientOptions.httpClient(); + if (clientOptions.version != null) { + builder.version = Optional.ofNullable(clientOptions.version); + } else { + builder.version = Optional.of(ApiVersion._2_14); + } + return builder; } } } diff --git a/src/main/java/com/intercom/api/core/InputStreamRequestBody.java b/src/main/java/com/intercom/api/core/InputStreamRequestBody.java index 58c63ee..e412135 100644 --- a/src/main/java/com/intercom/api/core/InputStreamRequestBody.java +++ b/src/main/java/com/intercom/api/core/InputStreamRequestBody.java @@ -8,7 +8,6 @@ import java.util.Objects; import okhttp3.MediaType; import okhttp3.RequestBody; -import okhttp3.internal.Util; import okio.BufferedSink; import okio.Okio; import okio.Source; @@ -68,12 +67,8 @@ public long contentLength() throws IOException { */ @Override public void writeTo(BufferedSink sink) throws IOException { - Source source = null; - try { - source = Okio.source(inputStream); + try (Source source = Okio.source(inputStream)) { sink.writeAll(source); - } finally { - Util.closeQuietly(Objects.requireNonNull(source)); } } } diff --git a/src/main/java/com/intercom/api/core/IntercomApiException.java b/src/main/java/com/intercom/api/core/IntercomApiException.java index f99fe97..0694888 100644 --- a/src/main/java/com/intercom/api/core/IntercomApiException.java +++ b/src/main/java/com/intercom/api/core/IntercomApiException.java @@ -65,9 +65,9 @@ public Map> headers() { return this.headers; } - @java.lang.Override + @Override public String toString() { - return "IntercomApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body - + "}"; + return "IntercomApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + + ObjectMappers.stringify(body) + "}"; } } diff --git a/src/main/java/com/intercom/api/core/NullableNonemptyFilter.java b/src/main/java/com/intercom/api/core/NullableNonemptyFilter.java index bb17a34..484db26 100644 --- a/src/main/java/com/intercom/api/core/NullableNonemptyFilter.java +++ b/src/main/java/com/intercom/api/core/NullableNonemptyFilter.java @@ -14,6 +14,9 @@ public boolean equals(Object o) { } private boolean isOptionalEmpty(Object o) { - return o instanceof Optional && !((Optional) o).isPresent(); + if (o instanceof Optional) { + return !((Optional) o).isPresent(); + } + return false; } } diff --git a/src/main/java/com/intercom/api/core/ObjectMappers.java b/src/main/java/com/intercom/api/core/ObjectMappers.java index 52d73aa..e7c4c7a 100644 --- a/src/main/java/com/intercom/api/core/ObjectMappers.java +++ b/src/main/java/com/intercom/api/core/ObjectMappers.java @@ -4,6 +4,7 @@ package com.intercom.api.core; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -33,4 +34,12 @@ public static String stringify(Object o) { return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); } } + + public static Object parseErrorBody(String responseBodyString) { + try { + return JSON_MAPPER.readValue(responseBodyString, Object.class); + } catch (JsonProcessingException ignored) { + return responseBodyString; + } + } } diff --git a/src/main/java/com/intercom/api/core/RequestOptions.java b/src/main/java/com/intercom/api/core/RequestOptions.java index b264d6b..e4e13fe 100644 --- a/src/main/java/com/intercom/api/core/RequestOptions.java +++ b/src/main/java/com/intercom/api/core/RequestOptions.java @@ -74,7 +74,7 @@ public static Builder builder() { return new Builder(); } - public static final class Builder { + public static class Builder { private String token = null; private Optional timeout = Optional.empty(); diff --git a/src/main/java/com/intercom/api/core/RetryInterceptor.java b/src/main/java/com/intercom/api/core/RetryInterceptor.java index 0c1e4ec..399e017 100644 --- a/src/main/java/com/intercom/api/core/RetryInterceptor.java +++ b/src/main/java/com/intercom/api/core/RetryInterceptor.java @@ -5,6 +5,9 @@ import java.io.IOException; import java.time.Duration; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Optional; import java.util.Random; import okhttp3.Interceptor; @@ -12,7 +15,10 @@ public class RetryInterceptor implements Interceptor { - private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private static final Duration INITIAL_RETRY_DELAY = Duration.ofMillis(1000); + private static final Duration MAX_RETRY_DELAY = Duration.ofMillis(60000); + private static final double JITTER_FACTOR = 0.2; + private final ExponentialBackoff backoff; private final Random random = new Random(); @@ -32,7 +38,7 @@ public Response intercept(Chain chain) throws IOException { } private Response retryChain(Response response, Chain chain) throws IOException { - Optional nextBackoff = this.backoff.nextBackoff(); + Optional nextBackoff = this.backoff.nextBackoff(response); while (nextBackoff.isPresent()) { try { Thread.sleep(nextBackoff.get().toMillis()); @@ -42,7 +48,7 @@ private Response retryChain(Response response, Chain chain) throws IOException { response.close(); response = chain.proceed(chain.request()); if (shouldRetry(response.code())) { - nextBackoff = this.backoff.nextBackoff(); + nextBackoff = this.backoff.nextBackoff(response); } else { return response; } @@ -51,6 +57,102 @@ private Response retryChain(Response response, Chain chain) throws IOException { return response; } + /** + * Calculates the retry delay from response headers, with fallback to exponential backoff. + * Priority: Retry-After > X-RateLimit-Reset > Exponential Backoff + */ + private Duration getRetryDelayFromHeaders(Response response, int retryAttempt) { + // Check for Retry-After header first (RFC 7231), with no jitter + String retryAfter = response.header("Retry-After"); + if (retryAfter != null) { + // Parse as number of seconds... + Optional secondsDelay = tryParseLong(retryAfter) + .map(seconds -> seconds * 1000) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (secondsDelay.isPresent()) { + return secondsDelay.get(); + } + + // ...or as an HTTP date; both are valid + Optional dateDelay = tryParseHttpDate(retryAfter) + .map(resetTime -> resetTime.toInstant().toEpochMilli() - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (dateDelay.isPresent()) { + return dateDelay.get(); + } + } + + // Then check for industry-standard X-RateLimit-Reset header, with positive jitter + String rateLimitReset = response.header("X-RateLimit-Reset"); + if (rateLimitReset != null) { + // Assume Unix timestamp in epoch seconds + Optional rateLimitDelay = tryParseLong(rateLimitReset) + .map(resetTimeSeconds -> (resetTimeSeconds * 1000) - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(this::addPositiveJitter) + .map(Duration::ofMillis); + if (rateLimitDelay.isPresent()) { + return rateLimitDelay.get(); + } + } + + // Fall back to exponential backoff, with symmetric jitter + long baseDelay = INITIAL_RETRY_DELAY.toMillis() * (1L << retryAttempt); // 2^retryAttempt + long cappedDelay = Math.min(baseDelay, MAX_RETRY_DELAY.toMillis()); + return Duration.ofMillis(addSymmetricJitter(cappedDelay)); + } + + /** + * Attempts to parse a string as a long, returning empty Optional on failure. + */ + private Optional tryParseLong(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(Long.parseLong(value)); + } catch (NumberFormatException e) { + return Optional.empty(); + } + } + + /** + * Attempts to parse a string as an HTTP date (RFC 1123), returning empty Optional on failure. + */ + private Optional tryParseHttpDate(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME)); + } catch (DateTimeParseException e) { + return Optional.empty(); + } + } + + /** + * Adds positive jitter (100-120% of original value) to prevent thundering herd. + * Used for X-RateLimit-Reset header delays. + */ + private long addPositiveJitter(long delayMs) { + double jitterMultiplier = 1.0 + (random.nextDouble() * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + + /** + * Adds symmetric jitter (90-110% of original value) to prevent thundering herd. + * Used for exponential backoff delays. + */ + private long addSymmetricJitter(long delayMs) { + double jitterMultiplier = 1.0 + ((random.nextDouble() - 0.5) * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + private static boolean shouldRetry(int statusCode) { return statusCode == 408 || statusCode == 429 || statusCode >= 500; } @@ -65,14 +167,14 @@ private final class ExponentialBackoff { this.maxNumRetries = maxNumRetries; } - public Optional nextBackoff() { - retryNumber += 1; - if (retryNumber > maxNumRetries) { + public Optional nextBackoff(Response response) { + if (retryNumber >= maxNumRetries) { return Optional.empty(); } - int upperBound = (int) Math.pow(2, retryNumber); - return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + Duration delay = getRetryDelayFromHeaders(response, retryNumber); + retryNumber += 1; + return Optional.of(delay); } } } diff --git a/src/main/java/com/intercom/api/core/Stream.java b/src/main/java/com/intercom/api/core/Stream.java index 9c6b3ef..f8aa1fb 100644 --- a/src/main/java/com/intercom/api/core/Stream.java +++ b/src/main/java/com/intercom/api/core/Stream.java @@ -3,6 +3,8 @@ */ package com.intercom.api.core; +import java.io.Closeable; +import java.io.IOException; import java.io.Reader; import java.util.Iterator; import java.util.NoSuchElementException; @@ -14,18 +16,28 @@ *

* {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a * {@code Scanner} to block during iteration if the next object is not available. + * Iterable stream for parsing JSON and Server-Sent Events (SSE) data. + * Supports both newline-delimited JSON and SSE with optional stream termination. * * @param The type of objects in the stream. */ -public final class Stream implements Iterable { - /** - * The {@link Class} of the objects in the stream. - */ +public final class Stream implements Iterable, Closeable { + + private static final String NEWLINE = "\n"; + private static final String DATA_PREFIX = "data:"; + + public enum StreamType { + JSON, + SSE + } + private final Class valueType; - /** - * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. - */ private final Scanner scanner; + private final StreamType streamType; + private final String messageTerminator; + private final String streamTerminator; + private final Reader sseReader; + private boolean isClosed = false; /** * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. @@ -35,8 +47,61 @@ public final class Stream implements Iterable { * @param delimiter The delimiter used to separate elements in the stream. */ public Stream(Class valueType, Reader reader, String delimiter) { + this.valueType = valueType; this.scanner = new Scanner(reader).useDelimiter(delimiter); + this.streamType = StreamType.JSON; + this.messageTerminator = delimiter; + this.streamTerminator = null; + this.sseReader = null; + } + + private Stream(Class valueType, StreamType type, Reader reader, String terminator) { this.valueType = valueType; + this.streamType = type; + if (type == StreamType.JSON) { + this.scanner = new Scanner(reader).useDelimiter(terminator); + this.messageTerminator = terminator; + this.streamTerminator = null; + this.sseReader = null; + } else { + this.scanner = null; + this.messageTerminator = NEWLINE; + this.streamTerminator = terminator; + this.sseReader = reader; + } + } + + public static Stream fromJson(Class valueType, Reader reader, String delimiter) { + return new Stream<>(valueType, reader, delimiter); + } + + public static Stream fromJson(Class valueType, Reader reader) { + return new Stream<>(valueType, reader, NEWLINE); + } + + public static Stream fromSse(Class valueType, Reader sseReader) { + return new Stream<>(valueType, StreamType.SSE, sseReader, null); + } + + public static Stream fromSse(Class valueType, Reader sseReader, String streamTerminator) { + return new Stream<>(valueType, StreamType.SSE, sseReader, streamTerminator); + } + + @Override + public void close() throws IOException { + if (!isClosed) { + isClosed = true; + if (scanner != null) { + scanner.close(); + } + if (sseReader != null) { + sseReader.close(); + } + } + } + + private boolean isStreamClosed() { + return isClosed; } /** @@ -47,51 +112,191 @@ public Stream(Class valueType, Reader reader, String delimiter) { */ @Override public Iterator iterator() { - return new Iterator() { - /** - * Returns {@code true} if there are more elements in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return {@code true} if there are more elements, {@code false} otherwise. - */ - @Override - public boolean hasNext() { - return scanner.hasNext(); + if (streamType == StreamType.SSE) { + return new SSEIterator(); + } else { + return new JsonIterator(); + } + } + + private final class JsonIterator implements Iterator { + + /** + * Returns {@code true} if there are more elements in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return {@code true} if there are more elements, {@code false} otherwise. + */ + @Override + public boolean hasNext() { + if (isStreamClosed()) { + return false; + } + return scanner.hasNext(); + } + + /** + * Returns the next element in the stream. + *

+ * Will block and wait for input if the stream has not ended and the next object is not yet available. + * + * @return The next element in the stream. + * @throws NoSuchElementException If there are no more elements in the stream. + */ + @Override + public T next() { + if (isStreamClosed()) { + throw new NoSuchElementException("Stream is closed"); + } + + if (!scanner.hasNext()) { + throw new NoSuchElementException(); + } else { + try { + T parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(scanner.next().trim(), valueType); + return parsedResponse; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + } + + private final class SSEIterator implements Iterator { + private Scanner sseScanner; + private T nextItem; + private boolean hasNextItem = false; + private boolean endOfStream = false; + private StringBuilder eventDataBuffer = new StringBuilder(); + private String currentEventType = null; + + private SSEIterator() { + if (sseReader != null && !isStreamClosed()) { + this.sseScanner = new Scanner(sseReader); + } else { + this.endOfStream = true; + } + } + + @Override + public boolean hasNext() { + if (isStreamClosed() || endOfStream) { + return false; + } + + if (hasNextItem) { + return true; + } + + return readNextMessage(); + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements in stream"); + } + + T result = nextItem; + nextItem = null; + hasNextItem = false; + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + private boolean readNextMessage() { + if (sseScanner == null || isStreamClosed()) { + endOfStream = true; + return false; } - /** - * Returns the next element in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return The next element in the stream. - * @throws NoSuchElementException If there are no more elements in the stream. - */ - @Override - public T next() { - if (!scanner.hasNext()) { - throw new NoSuchElementException(); - } else { + try { + while (sseScanner.hasNextLine()) { + String line = sseScanner.nextLine(); + + if (line.trim().isEmpty()) { + if (eventDataBuffer.length() > 0) { + try { + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; + continue; + } + } + continue; + } + + if (line.startsWith(DATA_PREFIX)) { + String dataContent = line.substring(DATA_PREFIX.length()); + if (dataContent.startsWith(" ")) { + dataContent = dataContent.substring(1); + } + + if (eventDataBuffer.length() == 0 + && streamTerminator != null + && dataContent.trim().equals(streamTerminator)) { + endOfStream = true; + return false; + } + + if (eventDataBuffer.length() > 0) { + eventDataBuffer.append('\n'); + } + eventDataBuffer.append(dataContent); + } else if (line.startsWith("event:")) { + String eventValue = line.length() > 6 ? line.substring(6) : ""; + if (eventValue.startsWith(" ")) { + eventValue = eventValue.substring(1); + } + currentEventType = eventValue; + } else if (line.startsWith("id:")) { + // Event ID field (ignored) + } else if (line.startsWith("retry:")) { + // Retry field (ignored) + } else if (line.startsWith(":")) { + // Comment line (ignored) + } + } + + if (eventDataBuffer.length() > 0) { try { - T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - scanner.next().trim(), valueType); - return parsedResponse; - } catch (Exception e) { - throw new RuntimeException(e); + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse final SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; } } - } - /** - * Removing elements from {@code Stream} is not supported. - * - * @throws UnsupportedOperationException Always, as removal is not supported. - */ - @Override - public void remove() { - throw new UnsupportedOperationException(); + endOfStream = true; + return false; + + } catch (Exception e) { + System.err.println("Failed to parse SSE stream: " + e.getMessage()); + endOfStream = true; + return false; } - }; + } } } diff --git a/src/main/java/com/intercom/api/core/pagination/AsyncCustomPager.java b/src/main/java/com/intercom/api/core/pagination/AsyncCustomPager.java new file mode 100644 index 0000000..001643f --- /dev/null +++ b/src/main/java/com/intercom/api/core/pagination/AsyncCustomPager.java @@ -0,0 +1,164 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core.pagination; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +/** + * Skeleton implementation for custom asynchronous bidirectional pagination. + * + * THIS CLASS MUST BE IMPLEMENTED BY THE USER. + * + * This file is added to .fernignore and will not be regenerated. + * Replace this skeleton implementation with your custom async pagination logic + * that handles your API's specific pagination structure (e.g., HATEOAS links). + * + * Example implementation for HATEOAS-style async pagination: + *

{@code
+ * public class AsyncCustomPager implements BiDirectionalPage {
+ *     private final List items;
+ *     private final String nextUrl;
+ *     private final String previousUrl;
+ *     private final AsyncHttpClient client;
+ *
+ *     public AsyncCustomPager(Response response, AsyncHttpClient client, ...) {
+ *         this.items = response.getData();
+ *         this.nextUrl = response.getLinks().getNext();
+ *         this.previousUrl = response.getLinks().getPrevious();
+ *         // ... store other needed context
+ *     }
+ *
+ *     @Override
+ *     public boolean hasNext() {
+ *         return nextUrl != null;
+ *     }
+ *
+ *     @Override
+ *     public CompletableFuture> nextPageAsync() {
+ *         if (!hasNext()) {
+ *             CompletableFuture> future = new CompletableFuture<>();
+ *             future.completeExceptionally(new NoSuchElementException("No next page available"));
+ *             return future;
+ *         }
+ *         // Make async HTTP request to nextUrl
+ *         return client.getAsync(nextUrl)
+ *             .thenApply(response -> new AsyncCustomPager<>(response, client, ...));
+ *     }
+ *
+ *     // ... implement other methods
+ * }
+ * }
+ * + * @param The type of items in the page + */ +public class AsyncCustomPager implements BiDirectionalPage { + + /** + * Create an AsyncCustomPager from an initial response. + * + * @param initialResponse The first page response from the API + * @param client The async HTTP client to use for subsequent requests + * @param requestOptions Request options for authentication, headers, etc. + * @return A CompletableFuture containing the new AsyncCustomPager instance + */ + public static CompletableFuture> createAsync( + Object initialResponse, okhttp3.OkHttpClient client, Object requestOptions) { + throw new UnsupportedOperationException("AsyncCustomPager must be implemented. " + + "Please implement this class in core/AsyncCustomPager.java to define your async pagination logic. " + + "This file has been added to .fernignore and will not be overwritten. " + + "See the class documentation for implementation examples."); + } + + @Override + public boolean hasNext() { + throw new UnsupportedOperationException("AsyncCustomPager.hasNext() must be implemented. " + + "This method should return true if a next page is available."); + } + + @Override + public boolean hasPrevious() { + throw new UnsupportedOperationException("AsyncCustomPager.hasPrevious() must be implemented. " + + "This method should return true if a previous page is available."); + } + + /** + * Asynchronously fetch the next page. + * + * @return A CompletableFuture that completes with the next page + * @throws java.util.NoSuchElementException if no next page exists (wrapped in CompletableFuture) + */ + public CompletableFuture> nextPageAsync() { + CompletableFuture> future = new CompletableFuture<>(); + future.completeExceptionally( + new UnsupportedOperationException("AsyncCustomPager.nextPageAsync() must be implemented. " + + "This method should asynchronously fetch and return the next page of results.")); + return future; + } + + /** + * Asynchronously fetch the previous page. + * + * @return A CompletableFuture that completes with the previous page + * @throws java.util.NoSuchElementException if no previous page exists (wrapped in CompletableFuture) + */ + public CompletableFuture> previousPageAsync() { + CompletableFuture> future = new CompletableFuture<>(); + future.completeExceptionally( + new UnsupportedOperationException("AsyncCustomPager.previousPageAsync() must be implemented. " + + "This method should asynchronously fetch and return the previous page of results.")); + return future; + } + + @Override + public BiDirectionalPage nextPage() throws IOException { + throw new UnsupportedOperationException("AsyncCustomPager.nextPage() must be implemented. " + + "Consider using nextPageAsync() for async operations, or implement synchronous blocking version."); + } + + @Override + public BiDirectionalPage previousPage() throws IOException { + throw new UnsupportedOperationException( + "AsyncCustomPager.previousPage() must be implemented. " + + "Consider using previousPageAsync() for async operations, or implement synchronous blocking version."); + } + + @Override + public List getItems() { + throw new UnsupportedOperationException("AsyncCustomPager.getItems() must be implemented. " + + "This method should return the items in the current page."); + } + + @Override + public Optional getResponse() { + throw new UnsupportedOperationException("AsyncCustomPager.getResponse() must be implemented. " + + "This method should return the full response object for accessing pagination metadata."); + } + + /** + * Asynchronously iterate through all pages starting from current. + * Returns a CompletableFuture that completes with all items from all pages. + * + * @return CompletableFuture containing all items across all pages + */ + public CompletableFuture> getAllItemsAsync() { + throw new UnsupportedOperationException("AsyncCustomPager.getAllItemsAsync() must be implemented. " + + "This method should asynchronously fetch all pages and return all items."); + } + + /** + * Process each page asynchronously as it arrives. + * + * @param pageProcessor Function to process each page + * @return CompletableFuture that completes when all pages are processed + */ + public CompletableFuture forEachPageAsync( + java.util.function.Function, CompletionStage> pageProcessor) { + throw new UnsupportedOperationException("AsyncCustomPager.forEachPageAsync() must be implemented. " + + "This method should asynchronously process each page with the given function."); + } +} diff --git a/src/main/java/com/intercom/api/core/pagination/BasePage.java b/src/main/java/com/intercom/api/core/pagination/BasePage.java index cbc2098..f7118ab 100644 --- a/src/main/java/com/intercom/api/core/pagination/BasePage.java +++ b/src/main/java/com/intercom/api/core/pagination/BasePage.java @@ -4,14 +4,17 @@ package com.intercom.api.core.pagination; import java.util.List; +import java.util.Optional; public abstract class BasePage { private final boolean hasNext; private final List items; + private final Object response; - public BasePage(boolean hasNext, List items) { + public BasePage(boolean hasNext, List items, Object response) { this.hasNext = hasNext; this.items = items; + this.response = response; } public boolean hasNext() { @@ -21,4 +24,15 @@ public boolean hasNext() { public List getItems() { return items; } + + /** + * Returns the full response object for accessing pagination metadata like cursor tokens. + * + * @return Optional containing the response, or empty if unavailable + */ + public Optional getResponse() { + @SuppressWarnings("unchecked") + R typedResponse = (R) response; + return Optional.ofNullable(typedResponse); + } } diff --git a/src/main/java/com/intercom/api/core/pagination/BiDirectionalPage.java b/src/main/java/com/intercom/api/core/pagination/BiDirectionalPage.java new file mode 100644 index 0000000..8c7fe53 --- /dev/null +++ b/src/main/java/com/intercom/api/core/pagination/BiDirectionalPage.java @@ -0,0 +1,60 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core.pagination; + +import java.util.List; + +/** + * Interface for pages that support bidirectional pagination (both forward and backward navigation). + * This is used for custom pagination scenarios where the API provides both next and previous page links. + * + * @param The type of items in the page + */ +public interface BiDirectionalPage { + /** + * Returns whether there is a next page available. + * + * @return true if next page exists and can be fetched + */ + boolean hasNext(); + + /** + * Returns whether there is a previous page available. + * + * @return true if previous page exists and can be fetched + */ + boolean hasPrevious(); + + /** + * Fetches and returns the next page. + * + * @return the next page + * @throws java.util.NoSuchElementException if no next page exists + * @throws java.io.IOException if the HTTP request fails + */ + BiDirectionalPage nextPage() throws java.io.IOException; + + /** + * Fetches and returns the previous page. + * + * @return the previous page + * @throws java.util.NoSuchElementException if no previous page exists + * @throws java.io.IOException if the HTTP request fails + */ + BiDirectionalPage previousPage() throws java.io.IOException; + + /** + * Returns the items in the current page. + * + * @return list of items in this page + */ + List getItems(); + + /** + * Returns the full response object for accessing pagination metadata. + * + * @return Optional containing the response, or empty if unavailable + */ + java.util.Optional getResponse(); +} diff --git a/src/main/java/com/intercom/api/core/pagination/CustomPager.java b/src/main/java/com/intercom/api/core/pagination/CustomPager.java new file mode 100644 index 0000000..519d821 --- /dev/null +++ b/src/main/java/com/intercom/api/core/pagination/CustomPager.java @@ -0,0 +1,117 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.core.pagination; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; + +/** + * Skeleton implementation for custom bidirectional pagination. + * + * THIS CLASS MUST BE IMPLEMENTED BY THE USER. + * + * This file is added to .fernignore and will not be regenerated. + * Replace this skeleton implementation with your custom pagination logic + * that handles your API's specific pagination structure (e.g., HATEOAS links). + * + * Example implementation for HATEOAS-style pagination: + *
{@code
+ * public class CustomPager implements BiDirectionalPage, Iterable {
+ *     private final List items;
+ *     private final String nextUrl;
+ *     private final String previousUrl;
+ *     private final OkHttpClient client;
+ *     private final TypeReference> responseType;
+ *
+ *     public CustomPager(Response response, OkHttpClient client, ...) {
+ *         this.items = response.getData();
+ *         this.nextUrl = response.getLinks().getNext();
+ *         this.previousUrl = response.getLinks().getPrevious();
+ *         // ... store other needed context
+ *     }
+ *
+ *     @Override
+ *     public boolean hasNext() {
+ *         return nextUrl != null;
+ *     }
+ *
+ *     @Override
+ *     public CustomPager nextPage() throws IOException {
+ *         if (!hasNext()) {
+ *             throw new NoSuchElementException("No next page available");
+ *         }
+ *         // Make HTTP request to nextUrl
+ *         // Parse response
+ *         // Return new CustomPager instance
+ *     }
+ *
+ *     // ... implement other methods
+ * }
+ * }
+ * + * @param The type of items in the page + */ +public class CustomPager implements BiDirectionalPage, Iterable { + + /** + * Create a CustomPager from an initial response. + * + * @param initialResponse The first page response from the API + * @param client The HTTP client to use for subsequent requests + * @param requestOptions Request options for authentication, headers, etc. + * @return A new CustomPager instance + * @throws IOException if the request fails + */ + public static CustomPager create(Object initialResponse, okhttp3.OkHttpClient client, Object requestOptions) + throws IOException { + throw new UnsupportedOperationException("CustomPager must be implemented. " + + "Please implement this class in core/CustomPager.java to define your pagination logic. " + + "This file has been added to .fernignore and will not be overwritten. " + + "See the class documentation for implementation examples."); + } + + @Override + public boolean hasNext() { + throw new UnsupportedOperationException("CustomPager.hasNext() must be implemented. " + + "This method should return true if a next page is available."); + } + + @Override + public boolean hasPrevious() { + throw new UnsupportedOperationException("CustomPager.hasPrevious() must be implemented. " + + "This method should return true if a previous page is available."); + } + + @Override + public BiDirectionalPage nextPage() throws IOException { + throw new UnsupportedOperationException("CustomPager.nextPage() must be implemented. " + + "This method should fetch and return the next page of results."); + } + + @Override + public BiDirectionalPage previousPage() throws IOException { + throw new UnsupportedOperationException("CustomPager.previousPage() must be implemented. " + + "This method should fetch and return the previous page of results."); + } + + @Override + public List getItems() { + throw new UnsupportedOperationException("CustomPager.getItems() must be implemented. " + + "This method should return the items in the current page."); + } + + @Override + public Optional getResponse() { + throw new UnsupportedOperationException("CustomPager.getResponse() must be implemented. " + + "This method should return the full response object for accessing pagination metadata."); + } + + @Override + public Iterator iterator() { + throw new UnsupportedOperationException("CustomPager.iterator() must be implemented. " + + "This method should return an iterator that traverses all items across all pages."); + } +} diff --git a/src/main/java/com/intercom/api/core/pagination/SyncPage.java b/src/main/java/com/intercom/api/core/pagination/SyncPage.java index 59c8bf7..86bb718 100644 --- a/src/main/java/com/intercom/api/core/pagination/SyncPage.java +++ b/src/main/java/com/intercom/api/core/pagination/SyncPage.java @@ -10,8 +10,8 @@ public class SyncPage extends BasePage { protected final Supplier> nextSupplier; - public SyncPage(boolean hasNext, List items, Supplier> nextSupplier) { - super(hasNext, items); + public SyncPage(boolean hasNext, List items, Object response, Supplier> nextSupplier) { + super(hasNext, items, response); this.nextSupplier = nextSupplier; } diff --git a/src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java b/src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java index cf05eeb..ae29262 100644 --- a/src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java +++ b/src/main/java/com/intercom/api/core/pagination/SyncPagingIterable.java @@ -14,12 +14,14 @@ public class SyncPagingIterable extends SyncPage implements Iterable { - public SyncPagingIterable(boolean hasNext, List items, Supplier> getNext) { - super(hasNext, items, getNext); + public SyncPagingIterable( + boolean hasNext, List items, Object response, Supplier> getNext) { + super(hasNext, items, response, getNext); } - public SyncPagingIterable(boolean hasNext, Optional> items, Supplier> getNext) { - super(hasNext, items.orElse(new ArrayList<>()), getNext); + public SyncPagingIterable( + boolean hasNext, Optional> items, Object response, Supplier> getNext) { + super(hasNext, items.orElse(new ArrayList<>()), response, getNext); } public Stream streamItems() { diff --git a/src/main/java/com/intercom/api/errors/TooManyRequestsError.java b/src/main/java/com/intercom/api/errors/TooManyRequestsError.java new file mode 100644 index 0000000..f6dc658 --- /dev/null +++ b/src/main/java/com/intercom/api/errors/TooManyRequestsError.java @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.errors; + +import com.intercom.api.core.IntercomApiException; +import com.intercom.api.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/admins/AdminsClient.java b/src/main/java/com/intercom/api/resources/admins/AdminsClient.java index bc494a2..702eb09 100644 --- a/src/main/java/com/intercom/api/resources/admins/AdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/AdminsClient.java @@ -12,6 +12,7 @@ import com.intercom.api.types.ActivityLogList; import com.intercom.api.types.AdminList; import com.intercom.api.types.AdminWithApp; +import java.util.Optional; public class AdminsClient { protected final ClientOptions clientOptions; @@ -37,7 +38,7 @@ public RawAdminsClient withRawResponse() { *

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 AdminWithApp identify() { + public Optional identify() { return this.rawClient.identify().body(); } @@ -48,21 +49,21 @@ public AdminWithApp identify() { *

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 AdminWithApp identify(RequestOptions requestOptions) { + public Optional identify(RequestOptions requestOptions) { return this.rawClient.identify(requestOptions).body(); } /** * You can set an Admin as away for the Inbox. */ - public Admin away(ConfigureAwayAdminRequest request) { + public Optional away(ConfigureAwayAdminRequest request) { return this.rawClient.away(request).body(); } /** * You can set an Admin as away for the Inbox. */ - public Admin away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + public Optional away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { return this.rawClient.away(request, requestOptions).body(); } @@ -97,14 +98,14 @@ public AdminList list(RequestOptions requestOptions) { /** * You can retrieve the details of a single admin. */ - public Admin find(FindAdminRequest request) { + public Optional find(FindAdminRequest request) { return this.rawClient.find(request).body(); } /** * You can retrieve the details of a single admin. */ - public Admin find(FindAdminRequest request, RequestOptions requestOptions) { + public Optional find(FindAdminRequest request, RequestOptions requestOptions) { return this.rawClient.find(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java b/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java index 6a00a05..f06b0ab 100644 --- a/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/AsyncAdminsClient.java @@ -12,6 +12,7 @@ import com.intercom.api.types.ActivityLogList; import com.intercom.api.types.AdminList; import com.intercom.api.types.AdminWithApp; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncAdminsClient { @@ -38,7 +39,7 @@ public AsyncRawAdminsClient withRawResponse() { *

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 identify() { + public CompletableFuture> identify() { return this.rawClient.identify().thenApply(response -> response.body()); } @@ -49,21 +50,21 @@ public CompletableFuture identify() { *

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 identify(RequestOptions requestOptions) { + public CompletableFuture> identify(RequestOptions requestOptions) { return this.rawClient.identify(requestOptions).thenApply(response -> response.body()); } /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture away(ConfigureAwayAdminRequest request) { + public CompletableFuture> away(ConfigureAwayAdminRequest request) { return this.rawClient.away(request).thenApply(response -> response.body()); } /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + public CompletableFuture> away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { return this.rawClient.away(request, requestOptions).thenApply(response -> response.body()); } @@ -99,14 +100,14 @@ public CompletableFuture list(RequestOptions requestOptions) { /** * You can retrieve the details of a single admin. */ - public CompletableFuture find(FindAdminRequest request) { + public CompletableFuture> find(FindAdminRequest request) { return this.rawClient.find(request).thenApply(response -> response.body()); } /** * You can retrieve the details of a single admin. */ - public CompletableFuture find(FindAdminRequest request, RequestOptions requestOptions) { + public CompletableFuture> find(FindAdminRequest request, RequestOptions requestOptions) { return this.rawClient.find(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java b/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java index 91b3115..2190adb 100644 --- a/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/AsyncRawAdminsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -12,6 +13,7 @@ import com.intercom.api.core.ObjectMappers; import com.intercom.api.core.QueryStringMapper; import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.admins.requests.ConfigureAwayAdminRequest; @@ -23,6 +25,7 @@ import com.intercom.api.types.AdminWithApp; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -49,7 +52,7 @@ public AsyncRawAdminsClient(ClientOptions clientOptions) { *

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> identify() { + public CompletableFuture>> identify() { return identify(null); } @@ -60,7 +63,7 @@ public CompletableFuture> identify() { *

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> identify(RequestOptions requestOptions) { + public CompletableFuture>> identify(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("me") @@ -69,30 +72,28 @@ public CompletableFuture> identify(RequestOpt .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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminWithApp.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -110,19 +111,19 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture> away(ConfigureAwayAdminRequest request) { + public CompletableFuture>> away(ConfigureAwayAdminRequest request) { return away(request, null); } /** * You can set an Admin as away for the Inbox. */ - public CompletableFuture> away( + public CompletableFuture>> away( ConfigureAwayAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .addPathSegments("away") .build(); RequestBody body; @@ -143,19 +144,26 @@ public CompletableFuture> away( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, 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), @@ -170,11 +178,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -214,7 +220,6 @@ public CompletableFuture> listAllActivityL .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(); @@ -226,13 +231,13 @@ public CompletableFuture> listAllActivityL @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityLogList.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ActivityLogList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -242,11 +247,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -280,7 +283,6 @@ public CompletableFuture> list(RequestOptions re .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(); @@ -292,12 +294,12 @@ public CompletableFuture> list(RequestOptions re @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminList.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AdminList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -307,11 +309,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -329,42 +329,43 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can retrieve the details of a single admin. */ - public CompletableFuture> find(FindAdminRequest request) { + public CompletableFuture>> find(FindAdminRequest request) { return find(request, null); } /** * You can retrieve the details of a single admin. */ - public CompletableFuture> find( + public CompletableFuture>> find( FindAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -381,11 +382,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java b/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java index e34c4c2..efee53e 100644 --- a/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java +++ b/src/main/java/com/intercom/api/resources/admins/RawAdminsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -12,6 +13,7 @@ import com.intercom.api.core.ObjectMappers; import com.intercom.api.core.QueryStringMapper; import com.intercom.api.core.RequestOptions; +import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.admins.requests.ConfigureAwayAdminRequest; @@ -23,6 +25,7 @@ import com.intercom.api.types.AdminWithApp; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -45,7 +48,7 @@ public RawAdminsClient(ClientOptions clientOptions) { *

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 identify() { + public IntercomHttpResponse> identify() { return identify(null); } @@ -56,7 +59,7 @@ public IntercomHttpResponse identify() { *

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 identify(RequestOptions requestOptions) { + public IntercomHttpResponse> identify(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("me") @@ -65,7 +68,6 @@ public IntercomHttpResponse identify(RequestOptions requestOptions .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(); @@ -74,16 +76,16 @@ public IntercomHttpResponse identify(RequestOptions requestOptions } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminWithApp.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -92,18 +94,19 @@ public IntercomHttpResponse identify(RequestOptions requestOptions /** * You can set an Admin as away for the Inbox. */ - public IntercomHttpResponse away(ConfigureAwayAdminRequest request) { + public IntercomHttpResponse> away(ConfigureAwayAdminRequest request) { return away(request, null); } /** * You can set an Admin as away for the Inbox. */ - public IntercomHttpResponse away(ConfigureAwayAdminRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> away( + ConfigureAwayAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .addPathSegments("away") .build(); RequestBody body; @@ -126,13 +129,18 @@ public IntercomHttpResponse away(ConfigureAwayAdminRequest request, Reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, 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); @@ -143,11 +151,9 @@ public IntercomHttpResponse away(ConfigureAwayAdminRequest request, Reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -177,7 +183,6 @@ public IntercomHttpResponse listAllActivityLogs( .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(); @@ -186,11 +191,11 @@ public IntercomHttpResponse listAllActivityLogs( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityLogList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ActivityLogList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -199,11 +204,9 @@ public IntercomHttpResponse listAllActivityLogs( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -228,7 +231,6 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { .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(); @@ -237,11 +239,11 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AdminList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AdminList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -250,11 +252,9 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -263,24 +263,23 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { /** * You can retrieve the details of a single admin. */ - public IntercomHttpResponse find(FindAdminRequest request) { + public IntercomHttpResponse> find(FindAdminRequest request) { return find(request, null); } /** * You can retrieve the details of a single admin. */ - public IntercomHttpResponse find(FindAdminRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> find(FindAdminRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("admins") - .addPathSegment(request.getAdminId()) + .addPathSegment(Integer.toString(request.getAdminId())) .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(); @@ -289,11 +288,13 @@ public IntercomHttpResponse find(FindAdminRequest request, RequestOptions } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Admin.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -306,11 +307,9 @@ public IntercomHttpResponse find(FindAdminRequest request, RequestOptions } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 bd7c8f1..b539e82 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 @@ -9,32 +9,37 @@ 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 org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConfigureAwayAdminRequest.Builder.class) public final class ConfigureAwayAdminRequest { - private final String adminId; + private final int adminId; private final boolean awayModeEnabled; private final boolean awayModeReassign; + private final Optional awayStatusReasonId; + private final Map additionalProperties; private ConfigureAwayAdminRequest( - String adminId, + int adminId, boolean awayModeEnabled, boolean awayModeReassign, + Optional awayStatusReasonId, Map additionalProperties) { this.adminId = adminId; this.awayModeEnabled = awayModeEnabled; this.awayModeReassign = awayModeReassign; + this.awayStatusReasonId = awayStatusReasonId; this.additionalProperties = additionalProperties; } @@ -42,7 +47,7 @@ private ConfigureAwayAdminRequest( * @return The unique identifier of a given admin */ @JsonProperty("admin_id") - public String getAdminId() { + public int getAdminId() { return adminId; } @@ -62,6 +67,14 @@ 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; @@ -74,14 +87,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConfigureAwayAdminRequest other) { - return adminId.equals(other.adminId) + return adminId == other.adminId && awayModeEnabled == other.awayModeEnabled - && awayModeReassign == other.awayModeReassign; + && awayModeReassign == other.awayModeReassign + && awayStatusReasonId.equals(other.awayStatusReasonId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.adminId, this.awayModeEnabled, this.awayModeReassign); + return Objects.hash(this.adminId, this.awayModeEnabled, this.awayModeReassign, this.awayStatusReasonId); } @java.lang.Override @@ -95,40 +109,49 @@ public static AdminIdStage builder() { public interface AdminIdStage { /** - * The unique identifier of a given admin + *

The unique identifier of a given admin

*/ - AwayModeEnabledStage adminId(@NotNull String adminId); + AwayModeEnabledStage adminId(int adminId); Builder from(ConfigureAwayAdminRequest other); } public interface AwayModeEnabledStage { /** - * Set to "true" to change the status of the admin to away. + *

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. + *

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

*/ _FinalStage awayModeReassign(boolean awayModeReassign); } public interface _FinalStage { ConfigureAwayAdminRequest 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 AdminIdStage, AwayModeEnabledStage, AwayModeReassignStage, _FinalStage { - private String adminId; + private int adminId; private boolean awayModeEnabled; private boolean awayModeReassign; + private Optional awayStatusReasonId = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -139,22 +162,25 @@ public Builder from(ConfigureAwayAdminRequest other) { adminId(other.getAdminId()); 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

+ *

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("admin_id") - public AwayModeEnabledStage adminId(@NotNull String adminId) { - this.adminId = Objects.requireNonNull(adminId, "adminId must not be null"); + public AwayModeEnabledStage adminId(int adminId) { + this.adminId = adminId; 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.

+ *

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 @@ -165,7 +191,8 @@ 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.

+ *

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 @@ -175,9 +202,30 @@ public _FinalStage awayModeReassign(boolean 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 ConfigureAwayAdminRequest build() { - return new ConfigureAwayAdminRequest(adminId, awayModeEnabled, awayModeReassign, additionalProperties); + return new ConfigureAwayAdminRequest( + adminId, awayModeEnabled, awayModeReassign, awayStatusReasonId, additionalProperties); } } } 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 c843ffb..211ec34 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindAdminRequest.Builder.class) public final class FindAdminRequest { - private final String adminId; + private final int adminId; private final Map additionalProperties; - private FindAdminRequest(String adminId, Map additionalProperties) { + private FindAdminRequest(int adminId, Map additionalProperties) { this.adminId = adminId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindAdminRequest(String adminId, Map additionalPropertie * @return The unique identifier of a given admin */ @JsonProperty("admin_id") - public String getAdminId() { + public int getAdminId() { return adminId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindAdminRequest other) { - return adminId.equals(other.adminId); + return adminId == other.adminId; } @java.lang.Override @@ -67,9 +66,9 @@ public static AdminIdStage builder() { public interface AdminIdStage { /** - * The unique identifier of a given admin + *

The unique identifier of a given admin

*/ - _FinalStage adminId(@NotNull String adminId); + _FinalStage adminId(int adminId); Builder from(FindAdminRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements AdminIdStage, _FinalStage { - private String adminId; + private int adminId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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

+ *

The unique identifier of a given admin

* @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"); + public _FinalStage adminId(int adminId) { + this.adminId = adminId; return this; } 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 5d882ad..fca340b 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 @@ -81,7 +81,7 @@ public static CreatedAtAfterStage builder() { public interface CreatedAtAfterStage { /** - * 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.

*/ _FinalStage createdAtAfter(@NotNull String createdAtAfter); @@ -118,7 +118,8 @@ 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.

+ *

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 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 74e3849..ff8727c 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 @@ -32,12 +32,14 @@ public final class Admin { private final String email; - private final String jobTitle; + private final Optional jobTitle; private final boolean awayModeEnabled; private final boolean awayModeReassign; + private final Optional awayStatusReasonId; + private final boolean hasInboxSeat; private final List teamIds; @@ -53,9 +55,10 @@ private Admin( String id, String name, String email, - String jobTitle, + Optional jobTitle, boolean awayModeEnabled, boolean awayModeReassign, + Optional awayStatusReasonId, boolean hasInboxSeat, List teamIds, Optional avatar, @@ -68,6 +71,7 @@ private Admin( this.jobTitle = jobTitle; this.awayModeEnabled = awayModeEnabled; this.awayModeReassign = awayModeReassign; + this.awayStatusReasonId = awayStatusReasonId; this.hasInboxSeat = hasInboxSeat; this.teamIds = teamIds; this.avatar = avatar; @@ -111,7 +115,7 @@ public String getEmail() { * @return The job title of the admin. */ @JsonProperty("job_title") - public String getJobTitle() { + public Optional getJobTitle() { return jobTitle; } @@ -131,6 +135,14 @@ public boolean 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. */ @@ -179,6 +191,7 @@ private boolean equalTo(Admin other) { && jobTitle.equals(other.jobTitle) && awayModeEnabled == other.awayModeEnabled && awayModeReassign == other.awayModeReassign + && awayStatusReasonId.equals(other.awayStatusReasonId) && hasInboxSeat == other.hasInboxSeat && teamIds.equals(other.teamIds) && avatar.equals(other.avatar) @@ -195,6 +208,7 @@ public int hashCode() { this.jobTitle, this.awayModeEnabled, this.awayModeReassign, + this.awayStatusReasonId, this.hasInboxSeat, this.teamIds, this.avatar, @@ -212,7 +226,7 @@ public static IdStage builder() { public interface IdStage { /** - * The id representing the admin. + *

The id representing the admin.

*/ NameStage id(@NotNull String id); @@ -221,42 +235,35 @@ public interface IdStage { public interface NameStage { /** - * The name of the admin. + *

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. + *

The email of the admin.

*/ - AwayModeEnabledStage jobTitle(@NotNull String jobTitle); + AwayModeEnabledStage email(@NotNull String email); } public interface AwayModeEnabledStage { /** - * Identifies if this admin is currently set in away mode. + *

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. + *

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. + *

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

*/ _FinalStage hasInboxSeat(boolean hasInboxSeat); } @@ -271,6 +278,20 @@ public interface _FinalStage { _FinalStage type(String type); + /** + *

The job title of the admin.

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

The unique identifier of the away status reason

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

This object represents the avatar associated with the admin.

*/ @@ -297,7 +318,6 @@ public static final class Builder implements IdStage, NameStage, EmailStage, - JobTitleStage, AwayModeEnabledStage, AwayModeReassignStage, HasInboxSeatStage, @@ -308,8 +328,6 @@ public static final class Builder private String email; - private String jobTitle; - private boolean awayModeEnabled; private boolean awayModeReassign; @@ -322,6 +340,10 @@ public static final class Builder private List teamIds = new ArrayList<>(); + private Optional awayStatusReasonId = Optional.empty(); + + private Optional jobTitle = Optional.empty(); + private Optional type = Optional.empty(); @JsonAnySetter @@ -338,6 +360,7 @@ public Builder from(Admin other) { jobTitle(other.getJobTitle()); awayModeEnabled(other.getAwayModeEnabled()); awayModeReassign(other.getAwayModeReassign()); + awayStatusReasonId(other.getAwayStatusReasonId()); hasInboxSeat(other.getHasInboxSeat()); teamIds(other.getTeamIds()); avatar(other.getAvatar()); @@ -346,7 +369,8 @@ public Builder from(Admin other) { } /** - * The id representing the admin.

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 @@ -357,7 +381,8 @@ public NameStage id(@NotNull String id) { } /** - * The name of the admin.

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 @@ -368,29 +393,20 @@ public EmailStage name(@NotNull String name) { } /** - * The email of the admin.

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 @JsonSetter("email") - public JobTitleStage email(@NotNull String email) { + public AwayModeEnabledStage email(@NotNull String email) { this.email = Objects.requireNonNull(email, "email must not be null"); return this; } /** - * 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 - @JsonSetter("job_title") - public AwayModeEnabledStage jobTitle(@NotNull String jobTitle) { - this.jobTitle = Objects.requireNonNull(jobTitle, "jobTitle must not be null"); - return this; - } - - /** - * 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.

+ *

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 @@ -401,7 +417,8 @@ 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.

+ *

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 @@ -412,7 +429,8 @@ 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.

+ *

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 @@ -461,7 +479,9 @@ public _FinalStage avatar(Optional avatar) { */ @java.lang.Override public _FinalStage addAllTeamIds(List teamIds) { - this.teamIds.addAll(teamIds); + if (teamIds != null) { + this.teamIds.addAll(teamIds); + } return this; } @@ -482,7 +502,49 @@ public _FinalStage addTeamIds(Integer teamIds) { @JsonSetter(value = "team_ids", nulls = Nulls.SKIP) public _FinalStage teamIds(List teamIds) { this.teamIds.clear(); - this.teamIds.addAll(teamIds); + if (teamIds != null) { + this.teamIds.addAll(teamIds); + } + 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; + } + + /** + *

The job title of the admin.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage jobTitle(String jobTitle) { + this.jobTitle = Optional.ofNullable(jobTitle); + return this; + } + + /** + *

The job title of the admin.

+ */ + @java.lang.Override + @JsonSetter(value = "job_title", nulls = Nulls.SKIP) + public _FinalStage jobTitle(Optional jobTitle) { + this.jobTitle = jobTitle; return this; } @@ -516,6 +578,7 @@ public Admin build() { jobTitle, awayModeEnabled, awayModeReassign, + awayStatusReasonId, hasInboxSeat, teamIds, avatar, @@ -575,7 +638,7 @@ public static ImageUrlStage builder() { public interface ImageUrlStage { /** - * URL of the admin's avatar image + *

URL of the admin's avatar image

*/ _FinalStage imageUrl(@NotNull String imageUrl); @@ -602,7 +665,8 @@ 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

+ *

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 75995d7..47dc351 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 @@ -19,34 +19,39 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AiAgent.Builder.class) public final class AiAgent { - private final SourceType sourceType; + private final Optional sourceType; private final Optional sourceTitle; - private final Optional lastAnswerType; + private final Optional lastAnswerType; - private final Optional resolutionState; + private final Optional resolutionState; private final Optional rating; private final Optional ratingRemark; + private final Optional createdAt; + + private final Optional updatedAt; + private final Optional contentSources; private final Map additionalProperties; private AiAgent( - SourceType sourceType, + Optional sourceType, Optional sourceTitle, - Optional lastAnswerType, - Optional resolutionState, + Optional lastAnswerType, + Optional resolutionState, Optional rating, Optional ratingRemark, + Optional createdAt, + Optional updatedAt, Optional contentSources, Map additionalProperties) { this.sourceType = sourceType; @@ -55,6 +60,8 @@ private AiAgent( this.resolutionState = resolutionState; this.rating = rating; this.ratingRemark = ratingRemark; + this.createdAt = createdAt; + this.updatedAt = updatedAt; this.contentSources = contentSources; this.additionalProperties = additionalProperties; } @@ -63,7 +70,7 @@ private AiAgent( * @return The type of the source that triggered AI Agent involvement in the conversation. */ @JsonProperty("source_type") - public SourceType getSourceType() { + public Optional getSourceType() { return sourceType; } @@ -79,7 +86,7 @@ public Optional getSourceTitle() { * @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() { + public Optional getLastAnswerType() { return lastAnswerType; } @@ -87,7 +94,7 @@ public Optional getLastAnswerType() { * @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() { + public Optional getResolutionState() { return resolutionState; } @@ -107,6 +114,22 @@ public Optional getRatingRemark() { return ratingRemark; } + /** + * @return The time when the AI agent rating was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the AI agent rating was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + @JsonProperty("content_sources") public Optional getContentSources() { return contentSources; @@ -130,6 +153,8 @@ private boolean equalTo(AiAgent other) { && resolutionState.equals(other.resolutionState) && rating.equals(other.rating) && ratingRemark.equals(other.ratingRemark) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) && contentSources.equals(other.contentSources); } @@ -142,6 +167,8 @@ public int hashCode() { this.resolutionState, this.rating, this.ratingRemark, + this.createdAt, + this.updatedAt, this.contentSources); } @@ -150,84 +177,35 @@ public String toString() { return ObjectMappers.stringify(this); } - public static SourceTypeStage builder() { + public static Builder builder() { return new 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); - } - - 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); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional sourceType = Optional.empty(); - _FinalStage contentSources(Optional contentSources); + private Optional sourceTitle = Optional.empty(); - _FinalStage contentSources(ContentSourcesList contentSources); - } + private Optional lastAnswerType = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SourceTypeStage, _FinalStage { - private SourceType sourceType; + private Optional resolutionState = Optional.empty(); - private Optional contentSources = Optional.empty(); + private Optional rating = Optional.empty(); private Optional ratingRemark = Optional.empty(); - private Optional rating = Optional.empty(); - - private Optional resolutionState = Optional.empty(); + private Optional createdAt = Optional.empty(); - private Optional lastAnswerType = Optional.empty(); + private Optional updatedAt = Optional.empty(); - private Optional sourceTitle = Optional.empty(); + private Optional contentSources = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(AiAgent other) { sourceType(other.getSourceType()); sourceTitle(other.getSourceTitle()); @@ -235,135 +213,135 @@ public Builder from(AiAgent other) { resolutionState(other.getResolutionState()); rating(other.getRating()); ratingRemark(other.getRatingRemark()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); contentSources(other.getContentSources()); return this; } /** - * 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. + *

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

*/ - @java.lang.Override - @JsonSetter("source_type") - public _FinalStage sourceType(@NotNull SourceType sourceType) { - this.sourceType = Objects.requireNonNull(sourceType, "sourceType must not be null"); + @JsonSetter(value = "source_type", nulls = Nulls.SKIP) + public Builder sourceType(Optional sourceType) { + this.sourceType = sourceType; return this; } - @java.lang.Override - public _FinalStage contentSources(ContentSourcesList contentSources) { - this.contentSources = Optional.ofNullable(contentSources); + public Builder sourceType(SourceType sourceType) { + this.sourceType = Optional.ofNullable(sourceType); return this; } - @java.lang.Override - @JsonSetter(value = "content_sources", nulls = Nulls.SKIP) - public _FinalStage contentSources(Optional contentSources) { - this.contentSources = contentSources; + /** + *

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; } - /** - *

The customer satisfaction rating remark given to AI Agent.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage ratingRemark(String ratingRemark) { - this.ratingRemark = Optional.ofNullable(ratingRemark); + public Builder sourceTitle(String sourceTitle) { + this.sourceTitle = Optional.ofNullable(sourceTitle); return this; } /** - *

The customer satisfaction rating remark given to AI Agent.

+ *

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 = "rating_remark", nulls = Nulls.SKIP) - public _FinalStage ratingRemark(Optional ratingRemark) { - this.ratingRemark = ratingRemark; + @JsonSetter(value = "last_answer_type", nulls = Nulls.SKIP) + public Builder lastAnswerType(Optional lastAnswerType) { + this.lastAnswerType = lastAnswerType; + return this; + } + + public Builder lastAnswerType(LastAnswerType lastAnswerType) { + this.lastAnswerType = Optional.ofNullable(lastAnswerType); return this; } /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. + *

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

*/ - @java.lang.Override - public _FinalStage rating(Integer rating) { - this.rating = Optional.ofNullable(rating); + @JsonSetter(value = "resolution_state", nulls = Nulls.SKIP) + public Builder resolutionState(Optional resolutionState) { + this.resolutionState = resolutionState; + return this; + } + + public Builder resolutionState(ResolutionState resolutionState) { + this.resolutionState = Optional.ofNullable(resolutionState); 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) { + public Builder rating(Optional rating) { this.rating = rating; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage resolutionState(String resolutionState) { - this.resolutionState = Optional.ofNullable(resolutionState); + public Builder rating(Integer rating) { + this.rating = Optional.ofNullable(rating); return this; } /** - *

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

+ *

The customer satisfaction rating remark given to AI Agent.

*/ - @java.lang.Override - @JsonSetter(value = "resolution_state", nulls = Nulls.SKIP) - public _FinalStage resolutionState(Optional resolutionState) { - this.resolutionState = resolutionState; + @JsonSetter(value = "rating_remark", nulls = Nulls.SKIP) + public Builder ratingRemark(Optional ratingRemark) { + this.ratingRemark = ratingRemark; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastAnswerType(String lastAnswerType) { - this.lastAnswerType = Optional.ofNullable(lastAnswerType); + public Builder ratingRemark(String ratingRemark) { + this.ratingRemark = Optional.ofNullable(ratingRemark); return this; } /** - *

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

+ *

The time when the AI agent rating was created.

*/ - @java.lang.Override - @JsonSetter(value = "last_answer_type", nulls = Nulls.SKIP) - public _FinalStage lastAnswerType(Optional lastAnswerType) { - this.lastAnswerType = lastAnswerType; + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; 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.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sourceTitle(String sourceTitle) { - this.sourceTitle = Optional.ofNullable(sourceTitle); + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); 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.

+ *

The time when the AI agent rating was last updated.

*/ - @java.lang.Override - @JsonSetter(value = "source_title", nulls = Nulls.SKIP) - public _FinalStage sourceTitle(Optional sourceTitle) { - this.sourceTitle = sourceTitle; + @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; + } + + @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; } - @java.lang.Override public AiAgent build() { return new AiAgent( sourceType, @@ -372,11 +350,112 @@ public AiAgent build() { resolutionState, rating, ratingRemark, + createdAt, + updatedAt, contentSources, additionalProperties); } } + public static final class ResolutionState { + public static final ResolutionState ASSUMED_RESOLUTION = + new ResolutionState(Value.ASSUMED_RESOLUTION, "assumed_resolution"); + + public static final ResolutionState ABANDONED = new ResolutionState(Value.ABANDONED, "abandoned"); + + public static final ResolutionState ROUTED_TO_TEAM = + new ResolutionState(Value.ROUTED_TO_TEAM, "routed_to_team"); + + public static final ResolutionState CONFIRMED_RESOLUTION = + new ResolutionState(Value.CONFIRMED_RESOLUTION, "confirmed_resolution"); + + private final Value value; + + private final String string; + + ResolutionState(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 ResolutionState && this.string.equals(((ResolutionState) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case ASSUMED_RESOLUTION: + return visitor.visitAssumedResolution(); + case ABANDONED: + return visitor.visitAbandoned(); + case ROUTED_TO_TEAM: + return visitor.visitRoutedToTeam(); + case CONFIRMED_RESOLUTION: + return visitor.visitConfirmedResolution(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ResolutionState valueOf(String value) { + switch (value) { + case "assumed_resolution": + return ASSUMED_RESOLUTION; + case "abandoned": + return ABANDONED; + case "routed_to_team": + return ROUTED_TO_TEAM; + case "confirmed_resolution": + return CONFIRMED_RESOLUTION; + default: + return new ResolutionState(Value.UNKNOWN, value); + } + } + + public enum Value { + ASSUMED_RESOLUTION, + + CONFIRMED_RESOLUTION, + + ROUTED_TO_TEAM, + + ABANDONED, + + UNKNOWN + } + + public interface Visitor { + T visitAssumedResolution(); + + T visitConfirmedResolution(); + + T visitRoutedToTeam(); + + T visitAbandoned(); + + T visitUnknown(String unknownType); + } + } + public static final class SourceType { public static final SourceType WORKFLOW = new SourceType(Value.WORKFLOW, "workflow"); @@ -482,4 +561,80 @@ public interface Visitor { T visitUnknown(String unknownType); } } + + public static final class LastAnswerType { + public static final LastAnswerType AI_ANSWER = new LastAnswerType(Value.AI_ANSWER, "ai_answer"); + + public static final LastAnswerType CUSTOM_ANSWER = new LastAnswerType(Value.CUSTOM_ANSWER, "custom_answer"); + + private final Value value; + + private final String string; + + LastAnswerType(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 LastAnswerType && this.string.equals(((LastAnswerType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case AI_ANSWER: + return visitor.visitAiAnswer(); + case CUSTOM_ANSWER: + return visitor.visitCustomAnswer(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static LastAnswerType valueOf(String value) { + switch (value) { + case "ai_answer": + return AI_ANSWER; + case "custom_answer": + return CUSTOM_ANSWER; + default: + return new LastAnswerType(Value.UNKNOWN, value); + } + } + + public enum Value { + AI_ANSWER, + + CUSTOM_ANSWER, + + UNKNOWN + } + + public interface Visitor { + T visitAiAnswer(); + + T visitCustomAnswer(); + + T visitUnknown(String unknownType); + } + } } diff --git a/src/main/java/com/intercom/api/resources/aicontent/AiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/AiContentClient.java new file mode 100644 index 0000000..495fbdf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/AiContentClient.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.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/aicontent/AsyncAiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/AsyncAiContentClient.java new file mode 100644 index 0000000..0043a84 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/AsyncAiContentClient.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.aicontent; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.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/aicontent/AsyncRawAiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/AsyncRawAiContentClient.java new file mode 100644 index 0000000..5ff9023 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/AsyncRawAiContentClient.java @@ -0,0 +1,716 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.UnauthorizedError; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.aicontent.types.ExternalPagesList; +import com.intercom.api.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("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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSourcesList.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSource.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getSourceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSource.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getSourceId()) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSource.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getSourceId()) + .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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPagesList.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getPageId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getPageId()) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getPageId()) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/aicontent/RawAiContentClient.java b/src/main/java/com/intercom/api/resources/aicontent/RawAiContentClient.java new file mode 100644 index 0000000..1aa4e95 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/RawAiContentClient.java @@ -0,0 +1,565 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.UnauthorizedError; +import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.CreateExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.DeleteContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.DeleteExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.GetContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.GetExternalPageRequest; +import com.intercom.api.resources.aicontent.requests.UpdateContentImportSourceRequest; +import com.intercom.api.resources.aicontent.requests.UpdateExternalPageRequest; +import com.intercom.api.resources.aicontent.types.ContentImportSource; +import com.intercom.api.resources.aicontent.types.ContentImportSourcesList; +import com.intercom.api.resources.aicontent.types.ExternalPage; +import com.intercom.api.resources.aicontent.types.ExternalPagesList; +import com.intercom.api.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("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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSourcesList.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSource.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getSourceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSource.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getSourceId()) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContentImportSource.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getSourceId()) + .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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPagesList.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getPageId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getPageId()) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getPageId()) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ExternalPage.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/CreateContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateContentImportSourceRequest.java new file mode 100644 index 0000000..4dd82e8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateContentImportSourceRequest.java @@ -0,0 +1,242 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/aicontent/requests/CreateExternalPageRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateExternalPageRequest.java new file mode 100644 index 0000000..7b6470d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/CreateExternalPageRequest.java @@ -0,0 +1,374 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/aicontent/requests/DeleteContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteContentImportSourceRequest.java new file mode 100644 index 0000000..ce2ca3b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteContentImportSourceRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 sourceId; + + private final Map additionalProperties; + + private DeleteContentImportSourceRequest(String sourceId, Map additionalProperties) { + this.sourceId = sourceId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("source_id") + public String getSourceId() { + return sourceId; + } + + @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 sourceId.equals(other.sourceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceIdStage builder() { + return new Builder(); + } + + public interface SourceIdStage { + /** + *

The unique identifier for the content import source which is given by Intercom.

+ */ + _FinalStage sourceId(@NotNull String sourceId); + + Builder from(DeleteContentImportSourceRequest other); + } + + public interface _FinalStage { + DeleteContentImportSourceRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourceIdStage, _FinalStage { + private String sourceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteContentImportSourceRequest other) { + sourceId(other.getSourceId()); + 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("source_id") + public _FinalStage sourceId(@NotNull String sourceId) { + this.sourceId = Objects.requireNonNull(sourceId, "sourceId must not be null"); + return this; + } + + @java.lang.Override + public DeleteContentImportSourceRequest build() { + return new DeleteContentImportSourceRequest(sourceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/CurrentCanvas.java b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteExternalPageRequest.java similarity index 50% rename from src/main/java/com/intercom/api/types/CurrentCanvas.java rename to src/main/java/com/intercom/api/resources/aicontent/requests/DeleteExternalPageRequest.java index e3373a7..103728c 100644 --- a/src/main/java/com/intercom/api/types/CurrentCanvas.java +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/DeleteExternalPageRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.aicontent.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -17,29 +17,29 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = CurrentCanvas.Builder.class) -public final class CurrentCanvas { - private final CanvasObject currentCanvas; +@JsonDeserialize(builder = DeleteExternalPageRequest.Builder.class) +public final class DeleteExternalPageRequest { + private final String pageId; private final Map additionalProperties; - private CurrentCanvas(CanvasObject currentCanvas, Map additionalProperties) { - this.currentCanvas = currentCanvas; + private DeleteExternalPageRequest(String pageId, Map additionalProperties) { + this.pageId = pageId; this.additionalProperties = additionalProperties; } /** - * @return The canvas object representing the current canvas state. + * @return The unique identifier for the external page which is given by Intercom. */ - @JsonProperty("current_canvas") - public CanvasObject getCurrentCanvas() { - return currentCanvas; + @JsonProperty("page_id") + public String getPageId() { + return pageId; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof CurrentCanvas && equalTo((CurrentCanvas) other); + return other instanceof DeleteExternalPageRequest && equalTo((DeleteExternalPageRequest) other); } @JsonAnyGetter @@ -47,13 +47,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(CurrentCanvas other) { - return currentCanvas.equals(other.currentCanvas); + private boolean equalTo(DeleteExternalPageRequest other) { + return pageId.equals(other.pageId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.currentCanvas); + return Objects.hash(this.pageId); } @java.lang.Override @@ -61,26 +61,26 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CurrentCanvasStage builder() { + public static PageIdStage builder() { return new Builder(); } - public interface CurrentCanvasStage { + public interface PageIdStage { /** - * The canvas object representing the current canvas state. + *

The unique identifier for the external page which is given by Intercom.

*/ - _FinalStage currentCanvas(@NotNull CanvasObject currentCanvas); + _FinalStage pageId(@NotNull String pageId); - Builder from(CurrentCanvas other); + Builder from(DeleteExternalPageRequest other); } public interface _FinalStage { - CurrentCanvas build(); + DeleteExternalPageRequest build(); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements CurrentCanvasStage, _FinalStage { - private CanvasObject currentCanvas; + public static final class Builder implements PageIdStage, _FinalStage { + private String pageId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -88,25 +88,26 @@ public static final class Builder implements CurrentCanvasStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(CurrentCanvas other) { - currentCanvas(other.getCurrentCanvas()); + public Builder from(DeleteExternalPageRequest other) { + pageId(other.getPageId()); return this; } /** - * The canvas object representing the current canvas state.

The canvas object representing the current canvas state.

+ *

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("current_canvas") - public _FinalStage currentCanvas(@NotNull CanvasObject currentCanvas) { - this.currentCanvas = Objects.requireNonNull(currentCanvas, "currentCanvas must not be null"); + @JsonSetter("page_id") + public _FinalStage pageId(@NotNull String pageId) { + this.pageId = Objects.requireNonNull(pageId, "pageId must not be null"); return this; } @java.lang.Override - public CurrentCanvas build() { - return new CurrentCanvas(currentCanvas, additionalProperties); + public DeleteExternalPageRequest build() { + return new DeleteExternalPageRequest(pageId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/GetContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/GetContentImportSourceRequest.java new file mode 100644 index 0000000..888f2ce --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/GetContentImportSourceRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 sourceId; + + private final Map additionalProperties; + + private GetContentImportSourceRequest(String sourceId, Map additionalProperties) { + this.sourceId = sourceId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the content import source which is given by Intercom. + */ + @JsonProperty("source_id") + public String getSourceId() { + return sourceId; + } + + @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 sourceId.equals(other.sourceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceIdStage builder() { + return new Builder(); + } + + public interface SourceIdStage { + /** + *

The unique identifier for the content import source which is given by Intercom.

+ */ + _FinalStage sourceId(@NotNull String sourceId); + + Builder from(GetContentImportSourceRequest other); + } + + public interface _FinalStage { + GetContentImportSourceRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements SourceIdStage, _FinalStage { + private String sourceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetContentImportSourceRequest other) { + sourceId(other.getSourceId()); + 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("source_id") + public _FinalStage sourceId(@NotNull String sourceId) { + this.sourceId = Objects.requireNonNull(sourceId, "sourceId must not be null"); + return this; + } + + @java.lang.Override + public GetContentImportSourceRequest build() { + return new GetContentImportSourceRequest(sourceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/GetExternalPageRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/GetExternalPageRequest.java new file mode 100644 index 0000000..c281ba2 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/GetExternalPageRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 pageId; + + private final Map additionalProperties; + + private GetExternalPageRequest(String pageId, Map additionalProperties) { + this.pageId = pageId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the external page which is given by Intercom. + */ + @JsonProperty("page_id") + public String getPageId() { + return pageId; + } + + @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 pageId.equals(other.pageId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.pageId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PageIdStage builder() { + return new Builder(); + } + + public interface PageIdStage { + /** + *

The unique identifier for the external page which is given by Intercom.

+ */ + _FinalStage pageId(@NotNull String pageId); + + Builder from(GetExternalPageRequest other); + } + + public interface _FinalStage { + GetExternalPageRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements PageIdStage, _FinalStage { + private String pageId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetExternalPageRequest other) { + pageId(other.getPageId()); + 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("page_id") + public _FinalStage pageId(@NotNull String pageId) { + this.pageId = Objects.requireNonNull(pageId, "pageId must not be null"); + return this; + } + + @java.lang.Override + public GetExternalPageRequest build() { + return new GetExternalPageRequest(pageId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateContentImportSourceRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateContentImportSourceRequest.java new file mode 100644 index 0000000..3d48656 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateContentImportSourceRequest.java @@ -0,0 +1,393 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 sourceId; + + private final SyncBehavior syncBehavior; + + private final Optional status; + + private final String url; + + private final Map additionalProperties; + + private UpdateContentImportSourceRequest( + String sourceId, + SyncBehavior syncBehavior, + Optional status, + String url, + Map additionalProperties) { + this.sourceId = sourceId; + 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("source_id") + public String getSourceId() { + return sourceId; + } + + /** + * @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 sourceId.equals(other.sourceId) + && syncBehavior.equals(other.syncBehavior) + && status.equals(other.status) + && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.sourceId, this.syncBehavior, this.status, this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static SourceIdStage builder() { + return new Builder(); + } + + public interface SourceIdStage { + /** + *

The unique identifier for the content import source which is given by Intercom.

+ */ + SyncBehaviorStage sourceId(@NotNull String sourceId); + + 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 SourceIdStage, SyncBehaviorStage, UrlStage, _FinalStage { + private String sourceId; + + 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) { + sourceId(other.getSourceId()); + 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("source_id") + public SyncBehaviorStage sourceId(@NotNull String sourceId) { + this.sourceId = Objects.requireNonNull(sourceId, "sourceId 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(sourceId, syncBehavior, status, url, additionalProperties); + } + } + + 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); + } + } + + 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/aicontent/requests/UpdateExternalPageRequest.java b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateExternalPageRequest.java new file mode 100644 index 0000000..70c6df7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/requests/UpdateExternalPageRequest.java @@ -0,0 +1,354 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 pageId; + + 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 pageId, + String title, + String html, + String url, + Optional finAvailability, + int sourceId, + Optional externalId, + Map additionalProperties) { + this.pageId = pageId; + 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("page_id") + public String getPageId() { + return pageId; + } + + /** + * @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 pageId.equals(other.pageId) + && 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.pageId, this.title, this.html, this.url, this.finAvailability, this.sourceId, this.externalId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static PageIdStage builder() { + return new Builder(); + } + + public interface PageIdStage { + /** + *

The unique identifier for the external page which is given by Intercom.

+ */ + TitleStage pageId(@NotNull String pageId); + + 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 PageIdStage, TitleStage, HtmlStage, UrlStage, SourceIdStage, _FinalStage { + private String pageId; + + 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) { + pageId(other.getPageId()); + 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("page_id") + public TitleStage pageId(@NotNull String pageId) { + this.pageId = Objects.requireNonNull(pageId, "pageId 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( + pageId, title, html, url, finAvailability, sourceId, externalId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSource.java b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSource.java new file mode 100644 index 0000000..50f5a6b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSource.java @@ -0,0 +1,506 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/aicontent/types/ContentImportSourcesList.java b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSourcesList.java new file mode 100644 index 0000000..2828601 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ContentImportSourcesList.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.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/aicontent/types/ExternalPage.java b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPage.java new file mode 100644 index 0000000..ed1ae2b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPage.java @@ -0,0 +1,570 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/aicontent/types/ExternalPagesList.java b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPagesList.java new file mode 100644 index 0000000..fbeef33 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/aicontent/types/ExternalPagesList.java @@ -0,0 +1,189 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.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/aicontentsource/types/ContentSource.java b/src/main/java/com/intercom/api/resources/aicontentsource/types/ContentSource.java index cdfb998..db9483c 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 @@ -9,25 +9,34 @@ 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 org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContentSource.Builder.class) public final class ContentSource { - private final String url; + private final Optional contentType; - private final String title; + private final Optional url; - private final String locale; + private final Optional title; + + private final Optional locale; private final Map additionalProperties; - private ContentSource(String url, String title, String locale, 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; @@ -38,15 +47,15 @@ private ContentSource(String url, String title, String locale, Map getContentType() { + return contentType; } /** * @return The internal URL linking to the content source for teammates. */ @JsonProperty("url") - public String getUrl() { + public Optional getUrl() { return url; } @@ -54,7 +63,7 @@ public String getUrl() { * @return The title of the content source. */ @JsonProperty("title") - public String getTitle() { + public Optional getTitle() { return title; } @@ -62,7 +71,7 @@ public String getTitle() { * @return The ISO 639 language code of the content source. */ @JsonProperty("locale") - public String getLocale() { + public Optional getLocale() { return locale; } @@ -78,12 +87,15 @@ public Map getAdditionalProperties() { } private boolean equalTo(ContentSource other) { - return url.equals(other.url) && title.equals(other.title) && locale.equals(other.locale); + 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.url, this.title, this.locale); + return Objects.hash(this.contentType, this.url, this.title, this.locale); } @java.lang.Override @@ -91,52 +103,27 @@ public String toString() { return ObjectMappers.stringify(this); } - public static UrlStage builder() { + public static Builder builder() { return new 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); - } - - public interface _FinalStage { - ContentSource build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UrlStage, TitleStage, LocaleStage, _FinalStage { - private String url; + public static final class Builder { + private Optional contentType = Optional.empty(); + + private Optional url = Optional.empty(); - private String title; + private Optional title = Optional.empty(); - private String locale; + private Optional locale = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(ContentSource other) { + contentType(other.getContentType()); url(other.getUrl()); title(other.getTitle()); locale(other.getLocale()); @@ -144,41 +131,63 @@ 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.

- * @return Reference to {@code this} so that method calls can be chained together. + *

The type of the content source.

*/ - @java.lang.Override - @JsonSetter("url") - public TitleStage url(@NotNull String url) { - this.url = Objects.requireNonNull(url, "url must not be null"); + @JsonSetter(value = "content_type", nulls = Nulls.SKIP) + public Builder contentType(Optional contentType) { + this.contentType = contentType; + return this; + } + + public Builder contentType(String contentType) { + this.contentType = Optional.ofNullable(contentType); return this; } /** - * 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. + *

The internal URL linking to the content source for teammates.

*/ - @java.lang.Override - @JsonSetter("title") - public LocaleStage title(@NotNull String title) { - this.title = Objects.requireNonNull(title, "title must not be null"); + @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 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. + *

The title of the content source.

*/ - @java.lang.Override - @JsonSetter("locale") - public _FinalStage locale(@NotNull String locale) { - this.locale = Objects.requireNonNull(locale, "locale must not be null"); + @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; } - @java.lang.Override public ContentSource build() { - return new ContentSource(url, title, locale, additionalProperties); + return new ContentSource(contentType, url, title, locale, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java index e7d0664..0feb90f 100644 --- a/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/ArticlesClient.java @@ -6,7 +6,6 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -14,8 +13,10 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; +import java.util.Optional; public class ArticlesClient { protected final ClientOptions clientOptions; @@ -70,14 +71,21 @@ public SyncPagingIterable list(ListArticlesRequest request, Req /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public Article create(CreateArticleRequest request) { + public Article create() { + return this.rawClient.create().body(); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public Article create(Optional request) { return this.rawClient.create(request).body(); } /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public Article create(CreateArticleRequest request, RequestOptions requestOptions) { + public Article create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } @@ -126,21 +134,21 @@ public DeletedArticleObject delete(DeleteArticleRequest request, RequestOptions /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public SearchArticlesResponse search() { + public ArticleSearchResponse search() { return this.rawClient.search().body(); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public SearchArticlesResponse search(SearchArticlesRequest request) { + public ArticleSearchResponse search(SearchArticlesRequest request) { return this.rawClient.search(request).body(); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public SearchArticlesResponse search(SearchArticlesRequest request, RequestOptions requestOptions) { + public ArticleSearchResponse search(SearchArticlesRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java index b0c29c4..ddafa89 100644 --- a/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/AsyncArticlesClient.java @@ -6,7 +6,6 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -14,8 +13,10 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncArticlesClient { @@ -72,14 +73,21 @@ public CompletableFuture> list( /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public CompletableFuture
create(CreateArticleRequest request) { + public CompletableFuture
create() { + return this.rawClient.create().thenApply(response -> response.body()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture
create(Optional request) { return this.rawClient.create(request).thenApply(response -> response.body()); } /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public CompletableFuture
create(CreateArticleRequest request, RequestOptions requestOptions) { + public CompletableFuture
create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } @@ -128,21 +136,21 @@ public CompletableFuture delete(DeleteArticleRequest reque /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture search() { + public CompletableFuture search() { return this.rawClient.search().thenApply(response -> response.body()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture search(SearchArticlesRequest request) { + public CompletableFuture search(SearchArticlesRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture search( + public CompletableFuture search( SearchArticlesRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java index f7b5511..38e7462 100644 --- a/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/AsyncRawArticlesClient.java @@ -16,7 +16,6 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -24,12 +23,15 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; import com.intercom.api.types.ArticleList; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import okhttp3.Call; @@ -87,17 +89,16 @@ public CompletableFuture page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ArticleList.class); + int newPageNumber = request.getPage() + .map((Integer page) -> page + 1) + .orElse(1); ListArticlesRequest nextRequest = ListArticlesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> { + new SyncPagingIterable(true, result, parsedResponse, () -> { try { return list(nextRequest, requestOptions) .get() @@ -132,7 +135,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -142,11 +144,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -164,7 +164,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public CompletableFuture> create(CreateArticleRequest request) { + public CompletableFuture> create() { + return create(Optional.empty()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public CompletableFuture> create(Optional request) { return create(request, null); } @@ -172,15 +179,18 @@ public CompletableFuture> create(CreateArticleRequ * You can create a new article by making a POST request to https://api.intercom.io/articles. */ public CompletableFuture> create( - CreateArticleRequest request, RequestOptions requestOptions) { + Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -200,12 +210,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Article.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -222,11 +232,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -256,13 +264,12 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .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(); @@ -274,12 +281,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Article.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -296,11 +303,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -330,7 +335,7 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); RequestBody body; try { @@ -355,12 +360,12 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Article.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -377,11 +382,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -411,13 +414,12 @@ public CompletableFuture> delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .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(); @@ -429,13 +431,13 @@ public CompletableFuture> delete( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedArticleObject.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedArticleObject.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -452,11 +454,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -474,21 +474,21 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture> search() { + public CompletableFuture> search() { return search(SearchArticlesRequest.builder().build()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture> search(SearchArticlesRequest request) { + public CompletableFuture> search(SearchArticlesRequest request) { return search(request, null); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public CompletableFuture> search( + public CompletableFuture> search( SearchArticlesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -503,36 +503,34 @@ public CompletableFuture> search( } if (request.getHelpCenterId().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "help_center_id", request.getHelpCenterId().get().toString(), false); + httpUrl, "help_center_id", request.getHelpCenterId().get(), false); } if (request.getHighlight().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "highlight", request.getHighlight().get().toString(), false); + httpUrl, "highlight", request.getHighlight().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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchArticlesResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ArticleSearchResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -542,11 +540,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java b/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java index 85302d6..f21c6ac 100644 --- a/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java +++ b/src/main/java/com/intercom/api/resources/articles/RawArticlesClient.java @@ -16,7 +16,6 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; -import com.intercom.api.resources.articles.requests.CreateArticleRequest; import com.intercom.api.resources.articles.requests.DeleteArticleRequest; import com.intercom.api.resources.articles.requests.FindArticleRequest; import com.intercom.api.resources.articles.requests.ListArticlesRequest; @@ -24,12 +23,15 @@ import com.intercom.api.resources.articles.requests.UpdateArticleRequest; import com.intercom.api.resources.articles.types.Article; import com.intercom.api.resources.articles.types.ArticleListItem; -import com.intercom.api.resources.articles.types.SearchArticlesResponse; +import com.intercom.api.resources.articles.types.ArticleSearchResponse; import com.intercom.api.types.ArticleList; +import com.intercom.api.types.CreateArticleRequest; import com.intercom.api.types.DeletedArticleObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -81,17 +83,16 @@ public IntercomHttpResponse> list( .addPathSegments("articles"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -100,21 +101,22 @@ public IntercomHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - ArticleList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ArticleList.class); - int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ArticleList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ArticleList.class); + int newPageNumber = + request.getPage().map((Integer page) -> page + 1).orElse(1); ListArticlesRequest nextRequest = ListArticlesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable( + true, result, parsedResponse, () -> list(nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -123,11 +125,9 @@ public IntercomHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -136,22 +136,32 @@ public IntercomHttpResponse> list( /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public IntercomHttpResponse
create(CreateArticleRequest request) { + public IntercomHttpResponse
create() { + return create(Optional.empty()); + } + + /** + * You can create a new article by making a POST request to https://api.intercom.io/articles. + */ + public IntercomHttpResponse
create(Optional request) { return create(request, null); } /** * You can create a new article by making a POST request to https://api.intercom.io/articles. */ - public IntercomHttpResponse
create(CreateArticleRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse
create(Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -168,11 +178,11 @@ public IntercomHttpResponse
create(CreateArticleRequest request, Reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Article.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -185,11 +195,9 @@ public IntercomHttpResponse
create(CreateArticleRequest request, Reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -209,13 +217,12 @@ public IntercomHttpResponse
find(FindArticleRequest request, RequestOpt HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .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(); @@ -224,11 +231,11 @@ public IntercomHttpResponse
find(FindArticleRequest request, RequestOpt } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Article.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -241,11 +248,9 @@ public IntercomHttpResponse
find(FindArticleRequest request, RequestOpt } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -265,7 +270,7 @@ public IntercomHttpResponse
update(UpdateArticleRequest request, Reques HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .build(); RequestBody body; try { @@ -287,11 +292,11 @@ public IntercomHttpResponse
update(UpdateArticleRequest request, Reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Article.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Article.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -304,11 +309,9 @@ public IntercomHttpResponse
update(UpdateArticleRequest request, Reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -329,13 +332,12 @@ public IntercomHttpResponse delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("articles") - .addPathSegment(request.getArticleId()) + .addPathSegment(Integer.toString(request.getArticleId())) .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(); @@ -344,12 +346,11 @@ public IntercomHttpResponse delete( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedArticleObject.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedArticleObject.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -362,11 +363,9 @@ public IntercomHttpResponse delete( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -375,21 +374,21 @@ public IntercomHttpResponse delete( /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public IntercomHttpResponse search() { + public IntercomHttpResponse search() { return search(SearchArticlesRequest.builder().build()); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public IntercomHttpResponse search(SearchArticlesRequest request) { + public IntercomHttpResponse search(SearchArticlesRequest request) { return search(request, null); } /** * You can search for articles by making a GET request to https://api.intercom.io/articles/search. */ - public IntercomHttpResponse search( + public IntercomHttpResponse search( SearchArticlesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -404,17 +403,16 @@ public IntercomHttpResponse search( } if (request.getHelpCenterId().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "help_center_id", request.getHelpCenterId().get().toString(), false); + httpUrl, "help_center_id", request.getHelpCenterId().get(), false); } if (request.getHighlight().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "highlight", request.getHighlight().get().toString(), false); + httpUrl, "highlight", request.getHighlight().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(); @@ -423,12 +421,11 @@ public IntercomHttpResponse search( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchArticlesResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ArticleSearchResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -437,11 +434,9 @@ public IntercomHttpResponse search( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 dd09632..1f748e3 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeleteArticleRequest.Builder.class) public final class DeleteArticleRequest { - private final String articleId; + private final int articleId; private final Map additionalProperties; - private DeleteArticleRequest(String articleId, Map additionalProperties) { + private DeleteArticleRequest(int articleId, Map additionalProperties) { this.articleId = articleId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private DeleteArticleRequest(String articleId, Map additionalPro * @return The unique identifier for the article which is given by Intercom. */ @JsonProperty("article_id") - public String getArticleId() { + public int getArticleId() { return articleId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(DeleteArticleRequest other) { - return articleId.equals(other.articleId); + return articleId == other.articleId; } @java.lang.Override @@ -67,9 +66,9 @@ public static ArticleIdStage builder() { public interface ArticleIdStage { /** - * The unique identifier for the article which is given by Intercom. + *

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

*/ - _FinalStage articleId(@NotNull String articleId); + _FinalStage articleId(int articleId); Builder from(DeleteArticleRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + private int articleId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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.

+ *

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("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + public _FinalStage articleId(int articleId) { + this.articleId = articleId; return this; } 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 66535e1..dd30adb 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindArticleRequest.Builder.class) public final class FindArticleRequest { - private final String articleId; + private final int articleId; private final Map additionalProperties; - private FindArticleRequest(String articleId, Map additionalProperties) { + private FindArticleRequest(int articleId, Map additionalProperties) { this.articleId = articleId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindArticleRequest(String articleId, Map additionalPrope * @return The unique identifier for the article which is given by Intercom. */ @JsonProperty("article_id") - public String getArticleId() { + public int getArticleId() { return articleId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindArticleRequest other) { - return articleId.equals(other.articleId); + return articleId == other.articleId; } @java.lang.Override @@ -67,9 +66,9 @@ public static ArticleIdStage builder() { public interface ArticleIdStage { /** - * The unique identifier for the article which is given by Intercom. + *

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

*/ - _FinalStage articleId(@NotNull String articleId); + _FinalStage articleId(int articleId); Builder from(FindArticleRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + private int articleId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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.

+ *

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("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + public _FinalStage articleId(int articleId) { + this.articleId = articleId; return this; } 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 fb1bf1c..613c064 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 @@ -19,12 +19,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateArticleRequest.Builder.class) public final class UpdateArticleRequest { - private final String articleId; + private final int articleId; private final Optional title; @@ -38,21 +37,21 @@ public final class UpdateArticleRequest { private final Optional parentId; - private final Optional parentType; + private final Optional parentType; private final Optional translatedContent; private final Map additionalProperties; private UpdateArticleRequest( - String articleId, + int articleId, Optional title, Optional description, Optional body, Optional authorId, Optional state, Optional parentId, - Optional parentType, + Optional parentType, Optional translatedContent, Map additionalProperties) { this.articleId = articleId; @@ -71,7 +70,7 @@ private UpdateArticleRequest( * @return The unique identifier for the article which is given by Intercom. */ @JsonProperty("article_id") - public String getArticleId() { + public int getArticleId() { return articleId; } @@ -127,7 +126,7 @@ public Optional getParentId() { * @return The type of parent, which can either be a collection or section. */ @JsonProperty("parent_type") - public Optional getParentType() { + public Optional getParentType() { return parentType; } @@ -148,7 +147,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateArticleRequest other) { - return articleId.equals(other.articleId) + return articleId == other.articleId && title.equals(other.title) && description.equals(other.description) && body.equals(other.body) @@ -184,9 +183,9 @@ public static ArticleIdStage builder() { public interface ArticleIdStage { /** - * The unique identifier for the article which is given by Intercom. + *

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

*/ - _FinalStage articleId(@NotNull String articleId); + _FinalStage articleId(int articleId); Builder from(UpdateArticleRequest other); } @@ -239,9 +238,9 @@ public interface _FinalStage { /** *

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

*/ - _FinalStage parentType(Optional parentType); + _FinalStage parentType(Optional parentType); - _FinalStage parentType(ParentType parentType); + _FinalStage parentType(String parentType); _FinalStage translatedContent(Optional translatedContent); @@ -250,11 +249,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + private int articleId; private Optional translatedContent = Optional.empty(); - private Optional parentType = Optional.empty(); + private Optional parentType = Optional.empty(); private Optional parentId = Optional.empty(); @@ -288,13 +287,14 @@ 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.

+ *

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("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + public _FinalStage articleId(int articleId) { + this.articleId = articleId; return this; } @@ -316,7 +316,7 @@ public _FinalStage translatedContent(Optional translat * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage parentType(ParentType parentType) { + public _FinalStage parentType(String parentType) { this.parentType = Optional.ofNullable(parentType); return this; } @@ -326,7 +326,7 @@ public _FinalStage parentType(ParentType parentType) { */ @java.lang.Override @JsonSetter(value = "parent_type", nulls = Nulls.SKIP) - public _FinalStage parentType(Optional parentType) { + public _FinalStage parentType(Optional parentType) { this.parentType = parentType; return this; } @@ -467,81 +467,6 @@ public UpdateArticleRequest build() { } } - public static final class ParentType { - public static final ParentType SECTION = new ParentType(Value.SECTION, "section"); - - public static final ParentType COLLECTION = new ParentType(Value.COLLECTION, "collection"); - - private final Value value; - - private final String string; - - ParentType(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 ParentType && this.string.equals(((ParentType) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case SECTION: - return visitor.visitSection(); - case COLLECTION: - return visitor.visitCollection(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static ParentType valueOf(String value) { - switch (value) { - case "section": - return SECTION; - case "collection": - return COLLECTION; - default: - return new ParentType(Value.UNKNOWN, value); - } - } - - public enum Value { - COLLECTION, - - SECTION, - - UNKNOWN - } - - public interface Visitor { - T visitCollection(); - - T visitSection(); - - T visitUnknown(String unknownType); - } - } - public static final class State { public static final State PUBLISHED = new State(Value.PUBLISHED, "published"); 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 aee34c2..ce4691d 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 @@ -54,9 +54,9 @@ public final class Article implements IArticleListItem { private final Optional parentType; - private final String defaultLocale; + private final Optional defaultLocale; - private final ArticleTranslatedContent translatedContent; + private final Optional translatedContent; private final Optional statistics; @@ -77,8 +77,8 @@ private Article( Optional parentId, Optional> parentIds, Optional parentType, - String defaultLocale, - ArticleTranslatedContent translatedContent, + Optional defaultLocale, + Optional translatedContent, Optional statistics, Map additionalProperties) { this.type = type; @@ -217,12 +217,12 @@ public Optional getParentType() { * @return The default locale of the help center. This field is only returned for multilingual help centers. */ @JsonProperty("default_locale") - public String getDefaultLocale() { + public Optional getDefaultLocale() { return defaultLocale; } @JsonProperty("translated_content") - public ArticleTranslatedContent getTranslatedContent() { + public Optional getTranslatedContent() { return translatedContent; } @@ -295,7 +295,7 @@ public static IdStage builder() { public interface IdStage { /** - * The unique identifier for the article which is given by Intercom. + *

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

*/ WorkspaceIdStage id(@NotNull String id); @@ -304,55 +304,44 @@ public interface IdStage { public interface WorkspaceIdStage { /** - * The id of the workspace which the article belongs to. + *

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. + *

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. + *

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. + *

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. + *

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. + *

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); - } - - public interface TranslatedContentStage { - _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent); + _FinalStage updatedAt(int updatedAt); } public interface _FinalStage { @@ -407,6 +396,17 @@ public interface _FinalStage { _FinalStage parentType(String parentType); + /** + *

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

+ */ + _FinalStage defaultLocale(Optional defaultLocale); + + _FinalStage defaultLocale(String defaultLocale); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(ArticleTranslatedContent translatedContent); + _FinalStage statistics(Optional statistics); _FinalStage statistics(ArticleStatistics statistics); @@ -421,8 +421,6 @@ public static final class Builder StateStage, CreatedAtStage, UpdatedAtStage, - DefaultLocaleStage, - TranslatedContentStage, _FinalStage { private String id; @@ -438,11 +436,11 @@ public static final class Builder private int updatedAt; - private String defaultLocale; + private Optional statistics = Optional.empty(); - private ArticleTranslatedContent translatedContent; + private Optional translatedContent = Optional.empty(); - private Optional statistics = Optional.empty(); + private Optional defaultLocale = Optional.empty(); private Optional parentType = Optional.empty(); @@ -486,7 +484,8 @@ 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.

+ *

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 @@ -497,7 +496,8 @@ 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.

+ *

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 @@ -508,7 +508,8 @@ 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.

+ *

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 @@ -519,7 +520,8 @@ 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.

+ *

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 @@ -530,7 +532,8 @@ 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.

+ *

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 @@ -541,7 +544,8 @@ 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.

+ *

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 @@ -552,44 +556,60 @@ 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.

+ *

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 @JsonSetter("updated_at") - public DefaultLocaleStage updatedAt(int updatedAt) { + public _FinalStage updatedAt(int updatedAt) { this.updatedAt = updatedAt; return this; } - /** - * 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 - @JsonSetter("default_locale") - public TranslatedContentStage defaultLocale(@NotNull String defaultLocale) { - this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); + public _FinalStage statistics(ArticleStatistics statistics) { + this.statistics = Optional.ofNullable(statistics); + return this; + } + + @java.lang.Override + @JsonSetter(value = "statistics", nulls = Nulls.SKIP) + public _FinalStage statistics(Optional statistics) { + this.statistics = statistics; return this; } @java.lang.Override - @JsonSetter("translated_content") - public _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent) { - this.translatedContent = Objects.requireNonNull(translatedContent, "translatedContent must not be null"); + public _FinalStage translatedContent(ArticleTranslatedContent translatedContent) { + this.translatedContent = Optional.ofNullable(translatedContent); return this; } @java.lang.Override - public _FinalStage statistics(ArticleStatistics statistics) { - this.statistics = Optional.ofNullable(statistics); + @JsonSetter(value = "translated_content", nulls = Nulls.SKIP) + public _FinalStage translatedContent(Optional translatedContent) { + this.translatedContent = translatedContent; + return this; + } + + /** + *

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 + public _FinalStage defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); return this; } + /** + *

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

+ */ @java.lang.Override - @JsonSetter(value = "statistics", nulls = Nulls.SKIP) - public _FinalStage statistics(Optional statistics) { - this.statistics = statistics; + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public _FinalStage defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; return this; } 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 ec33c25..ffbfa9f 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 @@ -53,9 +53,9 @@ public final class ArticleListItem implements IArticleListItem { private final Optional parentType; - private final String defaultLocale; + private final Optional defaultLocale; - private final ArticleTranslatedContent translatedContent; + private final Optional translatedContent; private final Map additionalProperties; @@ -74,8 +74,8 @@ private ArticleListItem( Optional parentId, Optional> parentIds, Optional parentType, - String defaultLocale, - ArticleTranslatedContent translatedContent, + Optional defaultLocale, + Optional translatedContent, Map additionalProperties) { this.type = type; this.id = id; @@ -212,12 +212,12 @@ public Optional getParentType() { * @return The default locale of the help center. This field is only returned for multilingual help centers. */ @JsonProperty("default_locale") - public String getDefaultLocale() { + public Optional getDefaultLocale() { return defaultLocale; } @JsonProperty("translated_content") - public ArticleTranslatedContent getTranslatedContent() { + public Optional getTranslatedContent() { return translatedContent; } @@ -283,7 +283,7 @@ public static IdStage builder() { public interface IdStage { /** - * The unique identifier for the article which is given by Intercom. + *

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

*/ WorkspaceIdStage id(@NotNull String id); @@ -292,55 +292,44 @@ public interface IdStage { public interface WorkspaceIdStage { /** - * The id of the workspace which the article belongs to. + *

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. + *

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. + *

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. + *

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. + *

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. + *

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); - } - - public interface TranslatedContentStage { - _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent); + _FinalStage updatedAt(int updatedAt); } public interface _FinalStage { @@ -394,6 +383,17 @@ public interface _FinalStage { _FinalStage parentType(Optional parentType); _FinalStage parentType(String parentType); + + /** + *

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

+ */ + _FinalStage defaultLocale(Optional defaultLocale); + + _FinalStage defaultLocale(String defaultLocale); + + _FinalStage translatedContent(Optional translatedContent); + + _FinalStage translatedContent(ArticleTranslatedContent translatedContent); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -405,8 +405,6 @@ public static final class Builder StateStage, CreatedAtStage, UpdatedAtStage, - DefaultLocaleStage, - TranslatedContentStage, _FinalStage { private String id; @@ -422,9 +420,9 @@ public static final class Builder private int updatedAt; - private String defaultLocale; + private Optional translatedContent = Optional.empty(); - private ArticleTranslatedContent translatedContent; + private Optional defaultLocale = Optional.empty(); private Optional parentType = Optional.empty(); @@ -467,7 +465,8 @@ 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.

+ *

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 @@ -478,7 +477,8 @@ 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.

+ *

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 @@ -489,7 +489,8 @@ 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.

+ *

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 @@ -500,7 +501,8 @@ 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.

+ *

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 @@ -511,7 +513,8 @@ 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.

+ *

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 @@ -522,7 +525,8 @@ 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.

+ *

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 @@ -533,31 +537,47 @@ 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.

+ *

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 @JsonSetter("updated_at") - public DefaultLocaleStage updatedAt(int updatedAt) { + public _FinalStage updatedAt(int updatedAt) { this.updatedAt = updatedAt; return this; } + @java.lang.Override + public _FinalStage translatedContent(ArticleTranslatedContent 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 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 - @JsonSetter("default_locale") - public TranslatedContentStage defaultLocale(@NotNull String defaultLocale) { - this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); + public _FinalStage defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); return this; } + /** + *

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

+ */ @java.lang.Override - @JsonSetter("translated_content") - public _FinalStage translatedContent(@NotNull ArticleTranslatedContent translatedContent) { - this.translatedContent = Objects.requireNonNull(translatedContent, "translatedContent must not be null"); + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public _FinalStage defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; return this; } 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 dbb6bc6..c429741 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 @@ -14,29 +14,27 @@ 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 java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ArticleSearchHighlights.Builder.class) public final class ArticleSearchHighlights { - private final String articleId; + private final Optional articleId; - private final List highlightedTitle; + private final Optional> highlightedTitle; - private final List> highlightedSummary; + private final Optional>> highlightedSummary; private final Map additionalProperties; private ArticleSearchHighlights( - String articleId, - List highlightedTitle, - List> highlightedSummary, + Optional articleId, + Optional> highlightedTitle, + Optional>> highlightedSummary, Map additionalProperties) { this.articleId = articleId; this.highlightedTitle = highlightedTitle; @@ -48,7 +46,7 @@ private ArticleSearchHighlights( * @return The ID of the corresponding article. */ @JsonProperty("article_id") - public String getArticleId() { + public Optional getArticleId() { return articleId; } @@ -56,7 +54,7 @@ public String getArticleId() { * @return An Article title highlighted. */ @JsonProperty("highlighted_title") - public List getHighlightedTitle() { + public Optional> getHighlightedTitle() { return highlightedTitle; } @@ -64,7 +62,7 @@ public List getHighlightedTitle() { * @return An Article description and body text highlighted. */ @JsonProperty("highlighted_summary") - public List> getHighlightedSummary() { + public Optional>> getHighlightedSummary() { return highlightedSummary; } @@ -95,55 +93,23 @@ public String toString() { return ObjectMappers.stringify(this); } - public static ArticleIdStage builder() { + public static Builder builder() { return new Builder(); } - public interface ArticleIdStage { - /** - * The ID of the corresponding article. - */ - _FinalStage articleId(@NotNull String articleId); - - Builder from(ArticleSearchHighlights other); - } - - 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); - - _FinalStage addAllHighlightedSummary(List> highlightedSummary); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ArticleIdStage, _FinalStage { - private String articleId; + public static final class Builder { + private Optional articleId = Optional.empty(); - private List> highlightedSummary = new ArrayList<>(); + private Optional> highlightedTitle = Optional.empty(); - private List highlightedTitle = new ArrayList<>(); + private Optional>> highlightedSummary = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(ArticleSearchHighlights other) { articleId(other.getArticleId()); highlightedTitle(other.getHighlightedTitle()); @@ -152,79 +118,47 @@ public Builder from(ArticleSearchHighlights other) { } /** - * 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. + *

The ID of the corresponding article.

*/ - @java.lang.Override - @JsonSetter("article_id") - public _FinalStage articleId(@NotNull String articleId) { - this.articleId = Objects.requireNonNull(articleId, "articleId must not be null"); + @JsonSetter(value = "article_id", nulls = Nulls.SKIP) + public Builder articleId(Optional articleId) { + this.articleId = articleId; return this; } - /** - *

An Article description and body text highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllHighlightedSummary(List> highlightedSummary) { - this.highlightedSummary.addAll(highlightedSummary); + public Builder articleId(String articleId) { + this.articleId = Optional.ofNullable(articleId); return this; } /** - *

An Article description and body text highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. + *

An Article title highlighted.

*/ - @java.lang.Override - public _FinalStage addHighlightedSummary(List highlightedSummary) { - this.highlightedSummary.add(highlightedSummary); + @JsonSetter(value = "highlighted_title", nulls = Nulls.SKIP) + public Builder highlightedTitle(Optional> highlightedTitle) { + this.highlightedTitle = highlightedTitle; return this; } - /** - *

An Article description and body text highlighted.

- */ - @java.lang.Override - @JsonSetter(value = "highlighted_summary", nulls = Nulls.SKIP) - public _FinalStage highlightedSummary(List> highlightedSummary) { - this.highlightedSummary.clear(); - this.highlightedSummary.addAll(highlightedSummary); + public Builder highlightedTitle(List highlightedTitle) { + this.highlightedTitle = Optional.ofNullable(highlightedTitle); return this; } /** - *

An Article title highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllHighlightedTitle(List highlightedTitle) { - this.highlightedTitle.addAll(highlightedTitle); - return this; - } - - /** - *

An Article title highlighted.

- * @return Reference to {@code this} so that method calls can be chained together. + *

An Article description and body text highlighted.

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

An Article title highlighted.

- */ - @java.lang.Override - @JsonSetter(value = "highlighted_title", nulls = Nulls.SKIP) - public _FinalStage highlightedTitle(List highlightedTitle) { - this.highlightedTitle.clear(); - this.highlightedTitle.addAll(highlightedTitle); + public Builder highlightedSummary(List> highlightedSummary) { + this.highlightedSummary = Optional.ofNullable(highlightedSummary); return this; } - @java.lang.Override public ArticleSearchHighlights build() { return new ArticleSearchHighlights(articleId, highlightedTitle, highlightedSummary, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchResponse.java similarity index 70% rename from src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java rename to src/main/java/com/intercom/api/resources/articles/types/ArticleSearchResponse.java index 173874f..c188596 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/SearchArticlesResponse.java +++ b/src/main/java/com/intercom/api/resources/articles/types/ArticleSearchResponse.java @@ -18,21 +18,27 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchArticlesResponse.Builder.class) -public final class SearchArticlesResponse { - private final int totalCount; +@JsonDeserialize(builder = ArticleSearchResponse.Builder.class) +public final class ArticleSearchResponse { + private final Optional type; - private final Data data; + private final Optional totalCount; + + private final Optional data; private final Optional pages; private final Map additionalProperties; - private SearchArticlesResponse( - int totalCount, Data data, Optional pages, 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; @@ -43,15 +49,15 @@ private SearchArticlesResponse( * @return The type of the object - list. */ @JsonProperty("type") - public String getType() { - return "list"; + public Optional getType() { + return type; } /** * @return The total number of Articles matching the search query */ @JsonProperty("total_count") - public int getTotalCount() { + public Optional getTotalCount() { return totalCount; } @@ -59,7 +65,7 @@ public int getTotalCount() { * @return An object containing the results of the search. */ @JsonProperty("data") - public Data getData() { + public Optional getData() { return data; } @@ -71,7 +77,7 @@ public Optional getPages() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchArticlesResponse && equalTo((SearchArticlesResponse) other); + return other instanceof ArticleSearchResponse && equalTo((ArticleSearchResponse) other); } @JsonAnyGetter @@ -79,13 +85,16 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SearchArticlesResponse other) { - return totalCount == other.totalCount && data.equals(other.data) && pages.equals(other.pages); + 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.totalCount, this.data, this.pages); + return Objects.hash(this.type, this.totalCount, this.data, this.pages); } @java.lang.Override @@ -93,39 +102,17 @@ public String toString() { return ObjectMappers.stringify(this); } - public static TotalCountStage builder() { + public static Builder builder() { return new 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); - } - - public interface _FinalStage { - SearchArticlesResponse build(); - - _FinalStage pages(Optional pages); - - _FinalStage pages(CursorPages pages); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TotalCountStage, DataStage, _FinalStage { - private int totalCount; + public static final class Builder { + private Optional type = Optional.empty(); + + private Optional totalCount = Optional.empty(); - private Data data; + private Optional data = Optional.empty(); private Optional pages = Optional.empty(); @@ -134,8 +121,8 @@ public static final class Builder implements TotalCountStage, DataStage, _FinalS private Builder() {} - @java.lang.Override - public Builder from(SearchArticlesResponse other) { + public Builder from(ArticleSearchResponse other) { + type(other.getType()); totalCount(other.getTotalCount()); data(other.getData()); pages(other.getPages()); @@ -143,43 +130,60 @@ public Builder from(SearchArticlesResponse other) { } /** - * 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. + *

The type of the object - list.

*/ - @java.lang.Override - @JsonSetter("total_count") - public DataStage totalCount(int totalCount) { + @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.

An object containing the results of the search.

- * @return Reference to {@code this} so that method calls can be chained together. + *

An object containing the results of the search.

*/ - @java.lang.Override - @JsonSetter("data") - public _FinalStage data(@NotNull Data data) { - this.data = Objects.requireNonNull(data, "data must not be null"); + @JsonSetter(value = "data", nulls = Nulls.SKIP) + public Builder data(Optional data) { + this.data = data; return this; } - @java.lang.Override - public _FinalStage pages(CursorPages pages) { - this.pages = Optional.ofNullable(pages); + public Builder data(Data data) { + this.data = Optional.ofNullable(data); return this; } - @java.lang.Override @JsonSetter(value = "pages", nulls = Nulls.SKIP) - public _FinalStage pages(Optional pages) { + public Builder pages(Optional pages) { this.pages = pages; return this; } - @java.lang.Override - public SearchArticlesResponse build() { - return new SearchArticlesResponse(totalCount, data, pages, additionalProperties); + public Builder pages(CursorPages pages) { + this.pages = Optional.ofNullable(pages); + return this; + } + + public ArticleSearchResponse build() { + return new ArticleSearchResponse(type, totalCount, data, pages, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java b/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java index 8d53ce1..f43a4be 100644 --- a/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java +++ b/src/main/java/com/intercom/api/resources/articles/types/IArticleListItem.java @@ -34,7 +34,7 @@ public interface IArticleListItem { Optional getParentType(); - String getDefaultLocale(); + Optional getDefaultLocale(); - ArticleTranslatedContent getTranslatedContent(); + Optional getTranslatedContent(); } diff --git a/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncAwayStatusReasonsClient.java new file mode 100644 index 0000000..bc2b839 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncAwayStatusReasonsClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.awaystatusreasons; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.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/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java new file mode 100644 index 0000000..1e6efe0 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/AsyncRawAwayStatusReasonsClient.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.UnauthorizedError; +import com.intercom.api.types.AwayStatusReason; +import com.intercom.api.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("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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/awaystatusreasons/AwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/AwayStatusReasonsClient.java new file mode 100644 index 0000000..5aef2c5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/AwayStatusReasonsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.awaystatusreasons; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.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/awaystatusreasons/RawAwayStatusReasonsClient.java b/src/main/java/com/intercom/api/resources/awaystatusreasons/RawAwayStatusReasonsClient.java new file mode 100644 index 0000000..83ef2da --- /dev/null +++ b/src/main/java/com/intercom/api/resources/awaystatusreasons/RawAwayStatusReasonsClient.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.UnauthorizedError; +import com.intercom.api.types.AwayStatusReason; +import com.intercom.api.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("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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/AsyncCallsClient.java b/src/main/java/com/intercom/api/resources/calls/AsyncCallsClient.java new file mode 100644 index 0000000..3158eee --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/AsyncCallsClient.java @@ -0,0 +1,116 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.Call; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCallsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCallsClient rawClient; + + public AsyncCallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCallsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCallsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture listCalls() { + return this.rawClient.listCalls().thenApply(response -> response.body()); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture listCalls(ListCallsRequest request) { + return this.rawClient.listCalls(request).thenApply(response -> response.body()); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture listCalls(ListCallsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCalls(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture showCall(ShowCallRequest request) { + return this.rawClient.showCall(request).thenApply(response -> response.body()); + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture showCall(ShowCallRequest request, RequestOptions requestOptions) { + return this.rawClient.showCall(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture showCallRecording(ShowCallRecordingRequest request) { + return this.rawClient.showCallRecording(request).thenApply(response -> response.body()); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture showCallRecording(ShowCallRecordingRequest request, RequestOptions requestOptions) { + return this.rawClient.showCallRecording(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture showCallTranscript(ShowCallTranscriptRequest request) { + return this.rawClient.showCallTranscript(request).thenApply(response -> response.body()); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture showCallTranscript( + ShowCallTranscriptRequest request, RequestOptions requestOptions) { + return this.rawClient.showCallTranscript(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public CompletableFuture listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request) { + return this.rawClient.listCallsWithTranscripts(request).thenApply(response -> response.body()); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public CompletableFuture listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCallsWithTranscripts(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/AsyncRawCallsClient.java b/src/main/java/com/intercom/api/resources/calls/AsyncRawCallsClient.java new file mode 100644 index 0000000..af964d3 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/AsyncRawCallsClient.java @@ -0,0 +1,415 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +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.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; +import com.intercom.api.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 AsyncRawCallsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture> listCalls() { + return listCalls(ListCallsRequest.builder().build()); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture> listCalls(ListCallsRequest request) { + return listCalls(request, null); + } + + /** + * Retrieve a paginated list of calls. + */ + public CompletableFuture> listCalls( + ListCallsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CallList.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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; + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture> showCall( + ShowCallRequest request) { + return showCall(request, null); + } + + /** + * Retrieve a single call by id. + */ + public CompletableFuture> showCall( + ShowCallRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, com.intercom.api.resources.calls.types.Call.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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; + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture> showCallRecording(ShowCallRecordingRequest request) { + return showCallRecording(request, null); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public CompletableFuture> showCallRecording( + ShowCallRecordingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("recording") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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; + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture> showCallTranscript(ShowCallTranscriptRequest request) { + return showCallTranscript(request, null); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public CompletableFuture> showCallTranscript( + ShowCallTranscriptRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("transcript") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>(responseBodyString, 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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; + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public CompletableFuture> listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request) { + return listCallsWithTranscripts(request, null); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public CompletableFuture> listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls/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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, ListCallsWithTranscriptsResponse.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/calls/CallsClient.java b/src/main/java/com/intercom/api/resources/calls/CallsClient.java new file mode 100644 index 0000000..3375eb4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/CallsClient.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.Call; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; + +public class CallsClient { + protected final ClientOptions clientOptions; + + private final RawCallsClient rawClient; + + public CallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawCallsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCallsClient withRawResponse() { + return this.rawClient; + } + + /** + * Retrieve a paginated list of calls. + */ + public CallList listCalls() { + return this.rawClient.listCalls().body(); + } + + /** + * Retrieve a paginated list of calls. + */ + public CallList listCalls(ListCallsRequest request) { + return this.rawClient.listCalls(request).body(); + } + + /** + * Retrieve a paginated list of calls. + */ + public CallList listCalls(ListCallsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCalls(request, requestOptions).body(); + } + + /** + * Retrieve a single call by id. + */ + public Call showCall(ShowCallRequest request) { + return this.rawClient.showCall(request).body(); + } + + /** + * Retrieve a single call by id. + */ + public Call showCall(ShowCallRequest request, RequestOptions requestOptions) { + return this.rawClient.showCall(request, requestOptions).body(); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public void showCallRecording(ShowCallRecordingRequest request) { + this.rawClient.showCallRecording(request).body(); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public void showCallRecording(ShowCallRecordingRequest request, RequestOptions requestOptions) { + this.rawClient.showCallRecording(request, requestOptions).body(); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public String showCallTranscript(ShowCallTranscriptRequest request) { + return this.rawClient.showCallTranscript(request).body(); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public String showCallTranscript(ShowCallTranscriptRequest request, RequestOptions requestOptions) { + return this.rawClient.showCallTranscript(request, requestOptions).body(); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public ListCallsWithTranscriptsResponse listCallsWithTranscripts(ListCallsWithTranscriptsRequest request) { + return this.rawClient.listCallsWithTranscripts(request).body(); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public ListCallsWithTranscriptsResponse listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + return this.rawClient.listCallsWithTranscripts(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/RawCallsClient.java b/src/main/java/com/intercom/api/resources/calls/RawCallsClient.java new file mode 100644 index 0000000..97bc0ed --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/RawCallsClient.java @@ -0,0 +1,326 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls; + +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.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.calls.requests.ListCallsRequest; +import com.intercom.api.resources.calls.requests.ListCallsWithTranscriptsRequest; +import com.intercom.api.resources.calls.requests.ShowCallRecordingRequest; +import com.intercom.api.resources.calls.requests.ShowCallRequest; +import com.intercom.api.resources.calls.requests.ShowCallTranscriptRequest; +import com.intercom.api.resources.calls.types.Call; +import com.intercom.api.resources.calls.types.ListCallsWithTranscriptsResponse; +import com.intercom.api.types.CallList; +import com.intercom.api.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 RawCallsClient { + protected final ClientOptions clientOptions; + + public RawCallsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Retrieve a paginated list of calls. + */ + public IntercomHttpResponse listCalls() { + return listCalls(ListCallsRequest.builder().build()); + } + + /** + * Retrieve a paginated list of calls. + */ + public IntercomHttpResponse listCalls(ListCallsRequest request) { + return listCalls(request, null); + } + + /** + * Retrieve a paginated list of calls. + */ + public IntercomHttpResponse listCalls(ListCallsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls"); + if (request.getPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page", request.getPage().get(), false); + } + if (request.getPerPage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "per_page", request.getPerPage().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CallList.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Retrieve a single call by id. + */ + public IntercomHttpResponse showCall(ShowCallRequest request) { + return showCall(request, null); + } + + /** + * Retrieve a single call by id. + */ + public IntercomHttpResponse showCall(ShowCallRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Call.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public IntercomHttpResponse showCallRecording(ShowCallRecordingRequest request) { + return showCallRecording(request, null); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + */ + public IntercomHttpResponse showCallRecording( + ShowCallRecordingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("recording") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public IntercomHttpResponse showCallTranscript(ShowCallTranscriptRequest request) { + return showCallTranscript(request, null); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + */ + public IntercomHttpResponse showCallTranscript( + ShowCallTranscriptRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls") + .addPathSegment(request.getCallId()) + .addPathSegments("transcript") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>(responseBodyString, response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public IntercomHttpResponse listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request) { + return listCallsWithTranscripts(request, null); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 conversation_ids can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + */ + public IntercomHttpResponse listCallsWithTranscripts( + ListCallsWithTranscriptsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("calls/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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ListCallsWithTranscriptsResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ListCallsRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsRequest.java new file mode 100644 index 0000000..06d43b4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsRequest.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.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 = ListCallsRequest.Builder.class) +public final class ListCallsRequest { + private final Optional page; + + private final Optional perPage; + + private final Map additionalProperties; + + private ListCallsRequest( + Optional page, Optional perPage, Map additionalProperties) { + this.page = page; + this.perPage = perPage; + 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 display per page. Defaults to 25. Max 25. + */ + @JsonProperty("per_page") + public Optional getPerPage() { + return perPage; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCallsRequest && equalTo((ListCallsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCallsRequest other) { + return page.equals(other.page) && perPage.equals(other.perPage); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(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 page = Optional.empty(); + + private Optional perPage = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCallsRequest other) { + page(other.getPage()); + perPage(other.getPerPage()); + 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 25. Max 25.

+ */ + @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 ListCallsRequest build() { + return new ListCallsRequest(page, perPage, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ListCallsWithTranscriptsRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsWithTranscriptsRequest.java new file mode 100644 index 0000000..c16ced5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ListCallsWithTranscriptsRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.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; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListCallsWithTranscriptsRequest.Builder.class) +public final class ListCallsWithTranscriptsRequest { + private final List conversationIds; + + private final Map additionalProperties; + + private ListCallsWithTranscriptsRequest(List conversationIds, Map additionalProperties) { + this.conversationIds = conversationIds; + this.additionalProperties = additionalProperties; + } + + /** + * @return A list of conversation ids to fetch calls for. Maximum 20. + */ + @JsonProperty("conversation_ids") + public List getConversationIds() { + return conversationIds; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListCallsWithTranscriptsRequest && equalTo((ListCallsWithTranscriptsRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCallsWithTranscriptsRequest other) { + return conversationIds.equals(other.conversationIds); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationIds); + } + + @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 List conversationIds = new ArrayList<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListCallsWithTranscriptsRequest other) { + conversationIds(other.getConversationIds()); + return this; + } + + /** + *

A list of conversation ids to fetch calls for. Maximum 20.

+ */ + @JsonSetter(value = "conversation_ids", nulls = Nulls.SKIP) + public Builder conversationIds(List conversationIds) { + this.conversationIds.clear(); + if (conversationIds != null) { + this.conversationIds.addAll(conversationIds); + } + return this; + } + + public Builder addConversationIds(String conversationIds) { + this.conversationIds.add(conversationIds); + return this; + } + + public Builder addAllConversationIds(List conversationIds) { + if (conversationIds != null) { + this.conversationIds.addAll(conversationIds); + } + return this; + } + + public ListCallsWithTranscriptsRequest build() { + return new ListCallsWithTranscriptsRequest(conversationIds, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/InitializeResponse.java b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRecordingRequest.java similarity index 54% rename from src/main/java/com/intercom/api/types/InitializeResponse.java rename to src/main/java/com/intercom/api/resources/calls/requests/ShowCallRecordingRequest.java index bdaf38c..349261f 100644 --- a/src/main/java/com/intercom/api/types/InitializeResponse.java +++ b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRecordingRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.calls.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -17,29 +17,29 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = InitializeResponse.Builder.class) -public final class InitializeResponse { - private final CanvasObject canvas; +@JsonDeserialize(builder = ShowCallRecordingRequest.Builder.class) +public final class ShowCallRecordingRequest { + private final String callId; private final Map additionalProperties; - private InitializeResponse(CanvasObject canvas, Map additionalProperties) { - this.canvas = canvas; + private ShowCallRecordingRequest(String callId, Map additionalProperties) { + this.callId = callId; this.additionalProperties = additionalProperties; } /** - * @return The canvas object that defines the UI to be shown for the app. + * @return The id of the call */ - @JsonProperty("canvas") - public CanvasObject getCanvas() { - return canvas; + @JsonProperty("call_id") + public String getCallId() { + return callId; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof InitializeResponse && equalTo((InitializeResponse) other); + return other instanceof ShowCallRecordingRequest && equalTo((ShowCallRecordingRequest) other); } @JsonAnyGetter @@ -47,13 +47,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(InitializeResponse other) { - return canvas.equals(other.canvas); + private boolean equalTo(ShowCallRecordingRequest other) { + return callId.equals(other.callId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.canvas); + return Objects.hash(this.callId); } @java.lang.Override @@ -61,26 +61,26 @@ public String toString() { return ObjectMappers.stringify(this); } - public static CanvasStage builder() { + public static CallIdStage builder() { return new Builder(); } - public interface CanvasStage { + public interface CallIdStage { /** - * The canvas object that defines the UI to be shown for the app. + *

The id of the call

*/ - _FinalStage canvas(@NotNull CanvasObject canvas); + _FinalStage callId(@NotNull String callId); - Builder from(InitializeResponse other); + Builder from(ShowCallRecordingRequest other); } public interface _FinalStage { - InitializeResponse build(); + ShowCallRecordingRequest build(); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements CanvasStage, _FinalStage { - private CanvasObject canvas; + public static final class Builder implements CallIdStage, _FinalStage { + private String callId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -88,25 +88,26 @@ public static final class Builder implements CanvasStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(InitializeResponse other) { - canvas(other.getCanvas()); + public Builder from(ShowCallRecordingRequest other) { + callId(other.getCallId()); return this; } /** - * The canvas object that defines the UI to be shown for the app.

The canvas object that defines the UI to be shown for the app.

+ *

The id of the call

+ *

The id of the call

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("canvas") - public _FinalStage canvas(@NotNull CanvasObject canvas) { - this.canvas = Objects.requireNonNull(canvas, "canvas must not be null"); + @JsonSetter("call_id") + public _FinalStage callId(@NotNull String callId) { + this.callId = Objects.requireNonNull(callId, "callId must not be null"); return this; } @java.lang.Override - public InitializeResponse build() { - return new InitializeResponse(canvas, additionalProperties); + public ShowCallRecordingRequest build() { + return new ShowCallRecordingRequest(callId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRequest.java new file mode 100644 index 0000000..676f6cc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.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 = ShowCallRequest.Builder.class) +public final class ShowCallRequest { + private final String callId; + + private final Map additionalProperties; + + private ShowCallRequest(String callId, Map additionalProperties) { + this.callId = callId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the call to retrieve + */ + @JsonProperty("call_id") + public String getCallId() { + return callId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowCallRequest && equalTo((ShowCallRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowCallRequest other) { + return callId.equals(other.callId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.callId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CallIdStage builder() { + return new Builder(); + } + + public interface CallIdStage { + /** + *

The id of the call to retrieve

+ */ + _FinalStage callId(@NotNull String callId); + + Builder from(ShowCallRequest other); + } + + public interface _FinalStage { + ShowCallRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CallIdStage, _FinalStage { + private String callId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ShowCallRequest other) { + callId(other.getCallId()); + return this; + } + + /** + *

The id of the call to retrieve

+ *

The id of the call to retrieve

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("call_id") + public _FinalStage callId(@NotNull String callId) { + this.callId = Objects.requireNonNull(callId, "callId must not be null"); + return this; + } + + @java.lang.Override + public ShowCallRequest build() { + return new ShowCallRequest(callId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/requests/ShowCallTranscriptRequest.java b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallTranscriptRequest.java new file mode 100644 index 0000000..c9ed20e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/requests/ShowCallTranscriptRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.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 = ShowCallTranscriptRequest.Builder.class) +public final class ShowCallTranscriptRequest { + private final String callId; + + private final Map additionalProperties; + + private ShowCallTranscriptRequest(String callId, Map additionalProperties) { + this.callId = callId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The id of the call + */ + @JsonProperty("call_id") + public String getCallId() { + return callId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ShowCallTranscriptRequest && equalTo((ShowCallTranscriptRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ShowCallTranscriptRequest other) { + return callId.equals(other.callId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.callId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CallIdStage builder() { + return new Builder(); + } + + public interface CallIdStage { + /** + *

The id of the call

+ */ + _FinalStage callId(@NotNull String callId); + + Builder from(ShowCallTranscriptRequest other); + } + + public interface _FinalStage { + ShowCallTranscriptRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CallIdStage, _FinalStage { + private String callId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ShowCallTranscriptRequest other) { + callId(other.getCallId()); + return this; + } + + /** + *

The id of the call

+ *

The id of the call

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("call_id") + public _FinalStage callId(@NotNull String callId) { + this.callId = Objects.requireNonNull(callId, "callId must not be null"); + return this; + } + + @java.lang.Override + public ShowCallTranscriptRequest build() { + return new ShowCallTranscriptRequest(callId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/types/Call.java b/src/main/java/com/intercom/api/resources/calls/types/Call.java new file mode 100644 index 0000000..fa2b8cd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/types/Call.java @@ -0,0 +1,653 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.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.types.Datetime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = Call.Builder.class) +public final class Call implements ICall { + private final Optional type; + + private final Optional id; + + private final Optional conversationId; + + private final Optional adminId; + + private final Optional contactId; + + private final Optional state; + + private final Optional initiatedAt; + + private final Optional answeredAt; + + private final Optional endedAt; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional recordingUrl; + + private final Optional transcriptionUrl; + + private final Optional callType; + + private final Optional direction; + + private final Optional endedReason; + + private final Optional phone; + + private final Optional finRecordingUrl; + + private final Optional finTranscriptionUrl; + + private final Map additionalProperties; + + private Call( + Optional type, + Optional id, + Optional conversationId, + Optional adminId, + Optional contactId, + Optional state, + Optional initiatedAt, + Optional answeredAt, + Optional endedAt, + Optional createdAt, + Optional updatedAt, + Optional recordingUrl, + Optional transcriptionUrl, + Optional callType, + Optional direction, + Optional endedReason, + Optional phone, + Optional finRecordingUrl, + Optional finTranscriptionUrl, + Map additionalProperties) { + this.type = type; + this.id = id; + this.conversationId = conversationId; + this.adminId = adminId; + this.contactId = contactId; + this.state = state; + this.initiatedAt = initiatedAt; + this.answeredAt = answeredAt; + this.endedAt = endedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.recordingUrl = recordingUrl; + this.transcriptionUrl = transcriptionUrl; + this.callType = callType; + this.direction = direction; + this.endedReason = endedReason; + this.phone = phone; + this.finRecordingUrl = finRecordingUrl; + this.finTranscriptionUrl = finTranscriptionUrl; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value call. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the call. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the conversation associated with the call, if any. + */ + @JsonProperty("conversation_id") + public Optional getConversationId() { + return conversationId; + } + + /** + * @return The id of the admin associated with the call, if any. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + /** + * @return The id of the contact associated with the call, if any. + */ + @JsonProperty("contact_id") + public Optional getContactId() { + return contactId; + } + + /** + * @return The current state of the call. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + @JsonProperty("initiated_at") + public Optional getInitiatedAt() { + return initiatedAt; + } + + @JsonProperty("answered_at") + public Optional getAnsweredAt() { + return answeredAt; + } + + @JsonProperty("ended_at") + public Optional getEndedAt() { + return endedAt; + } + + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return API URL to download or redirect to the call recording if available. + */ + @JsonProperty("recording_url") + public Optional getRecordingUrl() { + return recordingUrl; + } + + /** + * @return API URL to download or redirect to the call transcript if available. + */ + @JsonProperty("transcription_url") + public Optional getTranscriptionUrl() { + return transcriptionUrl; + } + + /** + * @return The type of call. + */ + @JsonProperty("call_type") + public Optional getCallType() { + return callType; + } + + /** + * @return The direction of the call. + */ + @JsonProperty("direction") + public Optional getDirection() { + return direction; + } + + /** + * @return The reason for the call end, if applicable. + */ + @JsonProperty("ended_reason") + public Optional getEndedReason() { + return endedReason; + } + + /** + * @return The phone number involved in the call, in E.164 format. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return API URL to the AI Agent (Fin) call recording if available. + */ + @JsonProperty("fin_recording_url") + public Optional getFinRecordingUrl() { + return finRecordingUrl; + } + + /** + * @return API URL to the AI Agent (Fin) call transcript if available. + */ + @JsonProperty("fin_transcription_url") + public Optional getFinTranscriptionUrl() { + return finTranscriptionUrl; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Call && equalTo((Call) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Call other) { + return type.equals(other.type) + && id.equals(other.id) + && conversationId.equals(other.conversationId) + && adminId.equals(other.adminId) + && contactId.equals(other.contactId) + && state.equals(other.state) + && initiatedAt.equals(other.initiatedAt) + && answeredAt.equals(other.answeredAt) + && endedAt.equals(other.endedAt) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && recordingUrl.equals(other.recordingUrl) + && transcriptionUrl.equals(other.transcriptionUrl) + && callType.equals(other.callType) + && direction.equals(other.direction) + && endedReason.equals(other.endedReason) + && phone.equals(other.phone) + && finRecordingUrl.equals(other.finRecordingUrl) + && finTranscriptionUrl.equals(other.finTranscriptionUrl); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.conversationId, + this.adminId, + this.contactId, + this.state, + this.initiatedAt, + this.answeredAt, + this.endedAt, + this.createdAt, + this.updatedAt, + this.recordingUrl, + this.transcriptionUrl, + this.callType, + this.direction, + this.endedReason, + this.phone, + this.finRecordingUrl, + this.finTranscriptionUrl); + } + + @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 conversationId = Optional.empty(); + + private Optional adminId = Optional.empty(); + + private Optional contactId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional initiatedAt = Optional.empty(); + + private Optional answeredAt = Optional.empty(); + + private Optional endedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional recordingUrl = Optional.empty(); + + private Optional transcriptionUrl = Optional.empty(); + + private Optional callType = Optional.empty(); + + private Optional direction = Optional.empty(); + + private Optional endedReason = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional finRecordingUrl = Optional.empty(); + + private Optional finTranscriptionUrl = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Call other) { + type(other.getType()); + id(other.getId()); + conversationId(other.getConversationId()); + adminId(other.getAdminId()); + contactId(other.getContactId()); + state(other.getState()); + initiatedAt(other.getInitiatedAt()); + answeredAt(other.getAnsweredAt()); + endedAt(other.getEndedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + recordingUrl(other.getRecordingUrl()); + transcriptionUrl(other.getTranscriptionUrl()); + callType(other.getCallType()); + direction(other.getDirection()); + endedReason(other.getEndedReason()); + phone(other.getPhone()); + finRecordingUrl(other.getFinRecordingUrl()); + finTranscriptionUrl(other.getFinTranscriptionUrl()); + return this; + } + + /** + *

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

+ */ + @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 call.

+ */ + @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 conversation associated with the call, if any.

+ */ + @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) + public Builder conversationId(Optional conversationId) { + this.conversationId = conversationId; + return this; + } + + public Builder conversationId(String conversationId) { + this.conversationId = Optional.ofNullable(conversationId); + return this; + } + + /** + *

The id of the admin associated with the call, if any.

+ */ + @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; + } + + /** + *

The id of the contact associated with the call, if any.

+ */ + @JsonSetter(value = "contact_id", nulls = Nulls.SKIP) + public Builder contactId(Optional contactId) { + this.contactId = contactId; + return this; + } + + public Builder contactId(String contactId) { + this.contactId = Optional.ofNullable(contactId); + return this; + } + + /** + *

The current state of the call.

+ */ + @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; + } + + @JsonSetter(value = "initiated_at", nulls = Nulls.SKIP) + public Builder initiatedAt(Optional initiatedAt) { + this.initiatedAt = initiatedAt; + return this; + } + + public Builder initiatedAt(Datetime initiatedAt) { + this.initiatedAt = Optional.ofNullable(initiatedAt); + return this; + } + + @JsonSetter(value = "answered_at", nulls = Nulls.SKIP) + public Builder answeredAt(Optional answeredAt) { + this.answeredAt = answeredAt; + return this; + } + + public Builder answeredAt(Datetime answeredAt) { + this.answeredAt = Optional.ofNullable(answeredAt); + return this; + } + + @JsonSetter(value = "ended_at", nulls = Nulls.SKIP) + public Builder endedAt(Optional endedAt) { + this.endedAt = endedAt; + return this; + } + + public Builder endedAt(Datetime endedAt) { + this.endedAt = Optional.ofNullable(endedAt); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Datetime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Datetime updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

API URL to download or redirect to the call recording if available.

+ */ + @JsonSetter(value = "recording_url", nulls = Nulls.SKIP) + public Builder recordingUrl(Optional recordingUrl) { + this.recordingUrl = recordingUrl; + return this; + } + + public Builder recordingUrl(String recordingUrl) { + this.recordingUrl = Optional.ofNullable(recordingUrl); + return this; + } + + /** + *

API URL to download or redirect to the call transcript if available.

+ */ + @JsonSetter(value = "transcription_url", nulls = Nulls.SKIP) + public Builder transcriptionUrl(Optional transcriptionUrl) { + this.transcriptionUrl = transcriptionUrl; + return this; + } + + public Builder transcriptionUrl(String transcriptionUrl) { + this.transcriptionUrl = Optional.ofNullable(transcriptionUrl); + return this; + } + + /** + *

The type of call.

+ */ + @JsonSetter(value = "call_type", nulls = Nulls.SKIP) + public Builder callType(Optional callType) { + this.callType = callType; + return this; + } + + public Builder callType(String callType) { + this.callType = Optional.ofNullable(callType); + return this; + } + + /** + *

The direction of the call.

+ */ + @JsonSetter(value = "direction", nulls = Nulls.SKIP) + public Builder direction(Optional direction) { + this.direction = direction; + return this; + } + + public Builder direction(String direction) { + this.direction = Optional.ofNullable(direction); + return this; + } + + /** + *

The reason for the call end, if applicable.

+ */ + @JsonSetter(value = "ended_reason", nulls = Nulls.SKIP) + public Builder endedReason(Optional endedReason) { + this.endedReason = endedReason; + return this; + } + + public Builder endedReason(String endedReason) { + this.endedReason = Optional.ofNullable(endedReason); + return this; + } + + /** + *

The phone number involved in the call, in E.164 format.

+ */ + @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; + } + + /** + *

API URL to the AI Agent (Fin) call recording if available.

+ */ + @JsonSetter(value = "fin_recording_url", nulls = Nulls.SKIP) + public Builder finRecordingUrl(Optional finRecordingUrl) { + this.finRecordingUrl = finRecordingUrl; + return this; + } + + public Builder finRecordingUrl(String finRecordingUrl) { + this.finRecordingUrl = Optional.ofNullable(finRecordingUrl); + return this; + } + + /** + *

API URL to the AI Agent (Fin) call transcript if available.

+ */ + @JsonSetter(value = "fin_transcription_url", nulls = Nulls.SKIP) + public Builder finTranscriptionUrl(Optional finTranscriptionUrl) { + this.finTranscriptionUrl = finTranscriptionUrl; + return this; + } + + public Builder finTranscriptionUrl(String finTranscriptionUrl) { + this.finTranscriptionUrl = Optional.ofNullable(finTranscriptionUrl); + return this; + } + + public Call build() { + return new Call( + type, + id, + conversationId, + adminId, + contactId, + state, + initiatedAt, + answeredAt, + endedAt, + createdAt, + updatedAt, + recordingUrl, + transcriptionUrl, + callType, + direction, + endedReason, + phone, + finRecordingUrl, + finTranscriptionUrl, + additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/calls/types/ICall.java b/src/main/java/com/intercom/api/resources/calls/types/ICall.java new file mode 100644 index 0000000..d6bbf5f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/types/ICall.java @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.types; + +import com.intercom.api.types.Datetime; +import java.util.Optional; + +public interface ICall { + Optional getType(); + + Optional getId(); + + Optional getConversationId(); + + Optional getAdminId(); + + Optional getContactId(); + + Optional getState(); + + Optional getInitiatedAt(); + + Optional getAnsweredAt(); + + Optional getEndedAt(); + + Optional getCreatedAt(); + + Optional getUpdatedAt(); + + Optional getRecordingUrl(); + + Optional getTranscriptionUrl(); + + Optional getCallType(); + + Optional getDirection(); + + Optional getEndedReason(); + + Optional getPhone(); + + Optional getFinRecordingUrl(); + + Optional getFinTranscriptionUrl(); +} diff --git a/src/main/java/com/intercom/api/resources/calls/types/ListCallsWithTranscriptsResponse.java b/src/main/java/com/intercom/api/resources/calls/types/ListCallsWithTranscriptsResponse.java new file mode 100644 index 0000000..36e30c5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/calls/types/ListCallsWithTranscriptsResponse.java @@ -0,0 +1,818 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.calls.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.types.Datetime; +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 = ListCallsWithTranscriptsResponse.Builder.class) +public final class ListCallsWithTranscriptsResponse { + private final Optional type; + + private final Optional> data; + + private final Map additionalProperties; + + private ListCallsWithTranscriptsResponse( + 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 ListCallsWithTranscriptsResponse && equalTo((ListCallsWithTranscriptsResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListCallsWithTranscriptsResponse 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(ListCallsWithTranscriptsResponse 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 ListCallsWithTranscriptsResponse build() { + return new ListCallsWithTranscriptsResponse(type, data, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = DataItem.Builder.class) + public static final class DataItem implements ICall { + private final Optional type; + + private final Optional id; + + private final Optional conversationId; + + private final Optional adminId; + + private final Optional contactId; + + private final Optional state; + + private final Optional initiatedAt; + + private final Optional answeredAt; + + private final Optional endedAt; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional recordingUrl; + + private final Optional transcriptionUrl; + + private final Optional callType; + + private final Optional direction; + + private final Optional endedReason; + + private final Optional phone; + + private final Optional finRecordingUrl; + + private final Optional finTranscriptionUrl; + + private final Optional>> transcript; + + private final Optional transcriptStatus; + + private final Map additionalProperties; + + private DataItem( + Optional type, + Optional id, + Optional conversationId, + Optional adminId, + Optional contactId, + Optional state, + Optional initiatedAt, + Optional answeredAt, + Optional endedAt, + Optional createdAt, + Optional updatedAt, + Optional recordingUrl, + Optional transcriptionUrl, + Optional callType, + Optional direction, + Optional endedReason, + Optional phone, + Optional finRecordingUrl, + Optional finTranscriptionUrl, + Optional>> transcript, + Optional transcriptStatus, + Map additionalProperties) { + this.type = type; + this.id = id; + this.conversationId = conversationId; + this.adminId = adminId; + this.contactId = contactId; + this.state = state; + this.initiatedAt = initiatedAt; + this.answeredAt = answeredAt; + this.endedAt = endedAt; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.recordingUrl = recordingUrl; + this.transcriptionUrl = transcriptionUrl; + this.callType = callType; + this.direction = direction; + this.endedReason = endedReason; + this.phone = phone; + this.finRecordingUrl = finRecordingUrl; + this.finTranscriptionUrl = finTranscriptionUrl; + this.transcript = transcript; + this.transcriptStatus = transcriptStatus; + this.additionalProperties = additionalProperties; + } + + /** + * @return String representing the object's type. Always has the value call. + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the call. + */ + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The id of the conversation associated with the call, if any. + */ + @JsonProperty("conversation_id") + public Optional getConversationId() { + return conversationId; + } + + /** + * @return The id of the admin associated with the call, if any. + */ + @JsonProperty("admin_id") + public Optional getAdminId() { + return adminId; + } + + /** + * @return The id of the contact associated with the call, if any. + */ + @JsonProperty("contact_id") + public Optional getContactId() { + return contactId; + } + + /** + * @return The current state of the call. + */ + @JsonProperty("state") + public Optional getState() { + return state; + } + + @JsonProperty("initiated_at") + public Optional getInitiatedAt() { + return initiatedAt; + } + + @JsonProperty("answered_at") + public Optional getAnsweredAt() { + return answeredAt; + } + + @JsonProperty("ended_at") + public Optional getEndedAt() { + return endedAt; + } + + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return API URL to download or redirect to the call recording if available. + */ + @JsonProperty("recording_url") + public Optional getRecordingUrl() { + return recordingUrl; + } + + /** + * @return API URL to download or redirect to the call transcript if available. + */ + @JsonProperty("transcription_url") + public Optional getTranscriptionUrl() { + return transcriptionUrl; + } + + /** + * @return The type of call. + */ + @JsonProperty("call_type") + public Optional getCallType() { + return callType; + } + + /** + * @return The direction of the call. + */ + @JsonProperty("direction") + public Optional getDirection() { + return direction; + } + + /** + * @return The reason for the call end, if applicable. + */ + @JsonProperty("ended_reason") + public Optional getEndedReason() { + return endedReason; + } + + /** + * @return The phone number involved in the call, in E.164 format. + */ + @JsonProperty("phone") + public Optional getPhone() { + return phone; + } + + /** + * @return API URL to the AI Agent (Fin) call recording if available. + */ + @JsonProperty("fin_recording_url") + public Optional getFinRecordingUrl() { + return finRecordingUrl; + } + + /** + * @return API URL to the AI Agent (Fin) call transcript if available. + */ + @JsonProperty("fin_transcription_url") + public Optional getFinTranscriptionUrl() { + return finTranscriptionUrl; + } + + /** + * @return The call transcript if available, otherwise an empty array. + */ + @JsonProperty("transcript") + public Optional>> getTranscript() { + return transcript; + } + + /** + * @return The status of the transcript if available. + */ + @JsonProperty("transcript_status") + public Optional getTranscriptStatus() { + return transcriptStatus; + } + + @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 type.equals(other.type) + && id.equals(other.id) + && conversationId.equals(other.conversationId) + && adminId.equals(other.adminId) + && contactId.equals(other.contactId) + && state.equals(other.state) + && initiatedAt.equals(other.initiatedAt) + && answeredAt.equals(other.answeredAt) + && endedAt.equals(other.endedAt) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && recordingUrl.equals(other.recordingUrl) + && transcriptionUrl.equals(other.transcriptionUrl) + && callType.equals(other.callType) + && direction.equals(other.direction) + && endedReason.equals(other.endedReason) + && phone.equals(other.phone) + && finRecordingUrl.equals(other.finRecordingUrl) + && finTranscriptionUrl.equals(other.finTranscriptionUrl) + && transcript.equals(other.transcript) + && transcriptStatus.equals(other.transcriptStatus); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.conversationId, + this.adminId, + this.contactId, + this.state, + this.initiatedAt, + this.answeredAt, + this.endedAt, + this.createdAt, + this.updatedAt, + this.recordingUrl, + this.transcriptionUrl, + this.callType, + this.direction, + this.endedReason, + this.phone, + this.finRecordingUrl, + this.finTranscriptionUrl, + this.transcript, + this.transcriptStatus); + } + + @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 conversationId = Optional.empty(); + + private Optional adminId = Optional.empty(); + + private Optional contactId = Optional.empty(); + + private Optional state = Optional.empty(); + + private Optional initiatedAt = Optional.empty(); + + private Optional answeredAt = Optional.empty(); + + private Optional endedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional recordingUrl = Optional.empty(); + + private Optional transcriptionUrl = Optional.empty(); + + private Optional callType = Optional.empty(); + + private Optional direction = Optional.empty(); + + private Optional endedReason = Optional.empty(); + + private Optional phone = Optional.empty(); + + private Optional finRecordingUrl = Optional.empty(); + + private Optional finTranscriptionUrl = Optional.empty(); + + private Optional>> transcript = Optional.empty(); + + private Optional transcriptStatus = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(DataItem other) { + type(other.getType()); + id(other.getId()); + conversationId(other.getConversationId()); + adminId(other.getAdminId()); + contactId(other.getContactId()); + state(other.getState()); + initiatedAt(other.getInitiatedAt()); + answeredAt(other.getAnsweredAt()); + endedAt(other.getEndedAt()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + recordingUrl(other.getRecordingUrl()); + transcriptionUrl(other.getTranscriptionUrl()); + callType(other.getCallType()); + direction(other.getDirection()); + endedReason(other.getEndedReason()); + phone(other.getPhone()); + finRecordingUrl(other.getFinRecordingUrl()); + finTranscriptionUrl(other.getFinTranscriptionUrl()); + transcript(other.getTranscript()); + transcriptStatus(other.getTranscriptStatus()); + return this; + } + + /** + *

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

+ */ + @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 call.

+ */ + @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 conversation associated with the call, if any.

+ */ + @JsonSetter(value = "conversation_id", nulls = Nulls.SKIP) + public Builder conversationId(Optional conversationId) { + this.conversationId = conversationId; + return this; + } + + public Builder conversationId(String conversationId) { + this.conversationId = Optional.ofNullable(conversationId); + return this; + } + + /** + *

The id of the admin associated with the call, if any.

+ */ + @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; + } + + /** + *

The id of the contact associated with the call, if any.

+ */ + @JsonSetter(value = "contact_id", nulls = Nulls.SKIP) + public Builder contactId(Optional contactId) { + this.contactId = contactId; + return this; + } + + public Builder contactId(String contactId) { + this.contactId = Optional.ofNullable(contactId); + return this; + } + + /** + *

The current state of the call.

+ */ + @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; + } + + @JsonSetter(value = "initiated_at", nulls = Nulls.SKIP) + public Builder initiatedAt(Optional initiatedAt) { + this.initiatedAt = initiatedAt; + return this; + } + + public Builder initiatedAt(Datetime initiatedAt) { + this.initiatedAt = Optional.ofNullable(initiatedAt); + return this; + } + + @JsonSetter(value = "answered_at", nulls = Nulls.SKIP) + public Builder answeredAt(Optional answeredAt) { + this.answeredAt = answeredAt; + return this; + } + + public Builder answeredAt(Datetime answeredAt) { + this.answeredAt = Optional.ofNullable(answeredAt); + return this; + } + + @JsonSetter(value = "ended_at", nulls = Nulls.SKIP) + public Builder endedAt(Optional endedAt) { + this.endedAt = endedAt; + return this; + } + + public Builder endedAt(Datetime endedAt) { + this.endedAt = Optional.ofNullable(endedAt); + return this; + } + + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder createdAt(Datetime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder updatedAt(Datetime updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + + /** + *

API URL to download or redirect to the call recording if available.

+ */ + @JsonSetter(value = "recording_url", nulls = Nulls.SKIP) + public Builder recordingUrl(Optional recordingUrl) { + this.recordingUrl = recordingUrl; + return this; + } + + public Builder recordingUrl(String recordingUrl) { + this.recordingUrl = Optional.ofNullable(recordingUrl); + return this; + } + + /** + *

API URL to download or redirect to the call transcript if available.

+ */ + @JsonSetter(value = "transcription_url", nulls = Nulls.SKIP) + public Builder transcriptionUrl(Optional transcriptionUrl) { + this.transcriptionUrl = transcriptionUrl; + return this; + } + + public Builder transcriptionUrl(String transcriptionUrl) { + this.transcriptionUrl = Optional.ofNullable(transcriptionUrl); + return this; + } + + /** + *

The type of call.

+ */ + @JsonSetter(value = "call_type", nulls = Nulls.SKIP) + public Builder callType(Optional callType) { + this.callType = callType; + return this; + } + + public Builder callType(String callType) { + this.callType = Optional.ofNullable(callType); + return this; + } + + /** + *

The direction of the call.

+ */ + @JsonSetter(value = "direction", nulls = Nulls.SKIP) + public Builder direction(Optional direction) { + this.direction = direction; + return this; + } + + public Builder direction(String direction) { + this.direction = Optional.ofNullable(direction); + return this; + } + + /** + *

The reason for the call end, if applicable.

+ */ + @JsonSetter(value = "ended_reason", nulls = Nulls.SKIP) + public Builder endedReason(Optional endedReason) { + this.endedReason = endedReason; + return this; + } + + public Builder endedReason(String endedReason) { + this.endedReason = Optional.ofNullable(endedReason); + return this; + } + + /** + *

The phone number involved in the call, in E.164 format.

+ */ + @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; + } + + /** + *

API URL to the AI Agent (Fin) call recording if available.

+ */ + @JsonSetter(value = "fin_recording_url", nulls = Nulls.SKIP) + public Builder finRecordingUrl(Optional finRecordingUrl) { + this.finRecordingUrl = finRecordingUrl; + return this; + } + + public Builder finRecordingUrl(String finRecordingUrl) { + this.finRecordingUrl = Optional.ofNullable(finRecordingUrl); + return this; + } + + /** + *

API URL to the AI Agent (Fin) call transcript if available.

+ */ + @JsonSetter(value = "fin_transcription_url", nulls = Nulls.SKIP) + public Builder finTranscriptionUrl(Optional finTranscriptionUrl) { + this.finTranscriptionUrl = finTranscriptionUrl; + return this; + } + + public Builder finTranscriptionUrl(String finTranscriptionUrl) { + this.finTranscriptionUrl = Optional.ofNullable(finTranscriptionUrl); + return this; + } + + /** + *

The call transcript if available, otherwise an empty array.

+ */ + @JsonSetter(value = "transcript", nulls = Nulls.SKIP) + public Builder transcript(Optional>> transcript) { + this.transcript = transcript; + return this; + } + + public Builder transcript(List> transcript) { + this.transcript = Optional.ofNullable(transcript); + return this; + } + + /** + *

The status of the transcript if available.

+ */ + @JsonSetter(value = "transcript_status", nulls = Nulls.SKIP) + public Builder transcriptStatus(Optional transcriptStatus) { + this.transcriptStatus = transcriptStatus; + return this; + } + + public Builder transcriptStatus(String transcriptStatus) { + this.transcriptStatus = Optional.ofNullable(transcriptStatus); + return this; + } + + public DataItem build() { + return new DataItem( + type, + id, + conversationId, + adminId, + contactId, + state, + initiatedAt, + answeredAt, + endedAt, + createdAt, + updatedAt, + recordingUrl, + transcriptionUrl, + callType, + direction, + endedReason, + phone, + finRecordingUrl, + finTranscriptionUrl, + transcript, + transcriptStatus, + additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java index 39c37ff..a7167dc 100644 --- a/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java @@ -7,7 +7,6 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -21,7 +20,9 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncCompaniesClient { @@ -98,7 +99,7 @@ public CompletableFuture createOrUpdate() { * 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 createOrUpdate(CreateOrUpdateCompanyRequest request) { + public CompletableFuture createOrUpdate(Optional request) { return this.rawClient.createOrUpdate(request).thenApply(response -> response.body()); } @@ -111,7 +112,7 @@ public CompletableFuture createOrUpdate(CreateOrUpdateCompanyRequest re * {% /admonition %}

*/ public CompletableFuture createOrUpdate( - CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + Optional request, RequestOptions requestOptions) { return this.rawClient.createOrUpdate(request, requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java index eb44232..bebb228 100644 --- a/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -17,7 +18,6 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -33,9 +33,11 @@ import com.intercom.api.types.CompanyAttachedSegments; import com.intercom.api.types.CompanyList; import com.intercom.api.types.CompanyScroll; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -113,17 +115,16 @@ public CompletableFuture> retrie } if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -135,14 +136,14 @@ public CompletableFuture> retrie @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), CompaniesRetrieveResponse.class), + responseBodyString, CompaniesRetrieveResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -159,11 +160,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -187,7 +186,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * {% /admonition %}

*/ public CompletableFuture> createOrUpdate() { - return createOrUpdate(CreateOrUpdateCompanyRequest.builder().build()); + return createOrUpdate(Optional.empty()); } /** @@ -198,7 +197,8 @@ public CompletableFuture> createOrUpdate() { * 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> createOrUpdate(CreateOrUpdateCompanyRequest request) { + public CompletableFuture> createOrUpdate( + Optional request) { return createOrUpdate(request, null); } @@ -211,15 +211,18 @@ public CompletableFuture> createOrUpdate(CreateOrU * {% /admonition %}

*/ public CompletableFuture> createOrUpdate( - CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -239,12 +242,12 @@ public CompletableFuture> createOrUpdate( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -261,11 +264,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -301,7 +302,6 @@ public CompletableFuture> find( .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(); @@ -313,12 +313,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -335,11 +335,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -377,13 +375,25 @@ public CompletableFuture> update( .addPathSegments("companies") .addPathSegment(request.getCompanyId()) .build(); - Request.Builder _requestBuilder = new Request.Builder() + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.getBody().isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes( + request.getBody().get()), + MediaTypes.APPLICATION_JSON); + } + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() .url(httpUrl) - .method("PUT", RequestBody.create("", null)) + .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); + .addHeader("Accept", "application/json") + .build(); OkHttpClient client = clientOptions.httpClient(); if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); @@ -393,12 +403,12 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -415,11 +425,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -455,7 +463,6 @@ public CompletableFuture> delete( .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(); @@ -467,13 +474,13 @@ public CompletableFuture> delete( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCompanyObject.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedCompanyObject.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -490,11 +497,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -522,24 +527,16 @@ public CompletableFuture> listAtta */ public CompletableFuture> listAttachedContacts( ListAttachedContactsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies") .addPathSegment(request.getCompanyId()) - .addPathSegments("contacts"); - 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); - } + .addPathSegments("contacts") + .build(); Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) + .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(); @@ -551,14 +548,13 @@ public CompletableFuture> listAtta @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), CompanyAttachedContacts.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CompanyAttachedContacts.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -575,11 +571,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -617,7 +611,6 @@ public CompletableFuture> listAtta .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(); @@ -629,14 +622,13 @@ public CompletableFuture> listAtta @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), CompanyAttachedSegments.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CompanyAttachedSegments.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -653,11 +645,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -714,11 +704,11 @@ public CompletableFuture>> list .addPathSegments("companies/list"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().get(), false); } if (request.getOrder().isPresent()) { QueryStringMapper.addQueryParameter( @@ -728,7 +718,6 @@ public CompletableFuture>> list .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(); @@ -740,18 +729,20 @@ public CompletableFuture>> list @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { CompanyList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class); - int newPageNumber = - request.getPage().map(page -> page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CompanyList.class); + int newPageNumber = request.getPage() + .map((Integer page) -> page + 1) + .orElse(1); ListCompaniesRequest nextRequest = ListCompaniesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> { + new SyncPagingIterable(true, result, parsedResponse, () -> { try { return list(nextRequest, requestOptions) .get() @@ -763,7 +754,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -773,11 +763,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -864,7 +852,6 @@ public CompletableFuture>> scro .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(); @@ -876,29 +863,31 @@ public CompletableFuture>> scro @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - CompanyScroll parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyScroll.class); - Optional startingAfter = parsedResponse.getScrollParam(); + Optional parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}); + Optional startingAfter = parsedResponse.flatMap(CompanyScroll::getScrollParam); ScrollCompaniesRequest nextRequest = ScrollCompaniesRequest.builder() .from(request) .scrollParam(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = + parsedResponse.flatMap(CompanyScroll::getData).orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return scroll(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return scroll(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -908,11 +897,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -968,12 +955,12 @@ public CompletableFuture> attachContact( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -995,11 +982,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1037,7 +1022,6 @@ public CompletableFuture> detachContact( .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(); @@ -1049,12 +1033,12 @@ public CompletableFuture> detachContact( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -1071,11 +1055,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java index c3eef41..d187543 100644 --- a/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/CompaniesClient.java @@ -7,7 +7,6 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -21,7 +20,9 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.types.CompanyAttachedContacts; import com.intercom.api.types.CompanyAttachedSegments; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; +import java.util.Optional; public class CompaniesClient { protected final ClientOptions clientOptions; @@ -96,7 +97,7 @@ public Company createOrUpdate() { * 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 createOrUpdate(CreateOrUpdateCompanyRequest request) { + public Company createOrUpdate(Optional request) { return this.rawClient.createOrUpdate(request).body(); } @@ -108,7 +109,7 @@ public Company createOrUpdate(CreateOrUpdateCompanyRequest request) { * 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 createOrUpdate(CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + public Company createOrUpdate(Optional request, RequestOptions requestOptions) { return this.rawClient.createOrUpdate(request, requestOptions).body(); } diff --git a/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java b/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java index e156a5c..91a4f90 100644 --- a/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java +++ b/src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -17,7 +18,6 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.resources.companies.requests.AttachContactToCompanyRequest; -import com.intercom.api.resources.companies.requests.CreateOrUpdateCompanyRequest; import com.intercom.api.resources.companies.requests.DeleteCompanyRequest; import com.intercom.api.resources.companies.requests.DetachContactFromCompanyRequest; import com.intercom.api.resources.companies.requests.FindCompanyRequest; @@ -33,9 +33,11 @@ import com.intercom.api.types.CompanyAttachedSegments; import com.intercom.api.types.CompanyList; import com.intercom.api.types.CompanyScroll; +import com.intercom.api.types.CreateOrUpdateCompanyRequest; import com.intercom.api.types.DeletedCompanyObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import okhttp3.Headers; @@ -108,17 +110,16 @@ public IntercomHttpResponse retrieve( } if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -127,12 +128,12 @@ public IntercomHttpResponse retrieve( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompaniesRetrieveResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CompaniesRetrieveResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -145,11 +146,9 @@ public IntercomHttpResponse retrieve( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -164,7 +163,7 @@ public IntercomHttpResponse retrieve( * {% /admonition %}

*/ public IntercomHttpResponse createOrUpdate() { - return createOrUpdate(CreateOrUpdateCompanyRequest.builder().build()); + return createOrUpdate(Optional.empty()); } /** @@ -175,7 +174,7 @@ public IntercomHttpResponse createOrUpdate() { * 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 createOrUpdate(CreateOrUpdateCompanyRequest request) { + public IntercomHttpResponse createOrUpdate(Optional request) { return createOrUpdate(request, null); } @@ -188,15 +187,18 @@ public IntercomHttpResponse createOrUpdate(CreateOrUpdateCompanyRequest * {% /admonition %}

*/ public IntercomHttpResponse createOrUpdate( - CreateOrUpdateCompanyRequest request, RequestOptions requestOptions) { + Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -213,11 +215,11 @@ public IntercomHttpResponse createOrUpdate( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -230,11 +232,9 @@ public IntercomHttpResponse createOrUpdate( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -260,7 +260,6 @@ public IntercomHttpResponse find(FindCompanyRequest request, RequestOpt .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(); @@ -269,11 +268,11 @@ public IntercomHttpResponse find(FindCompanyRequest request, RequestOpt } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -286,11 +285,9 @@ public IntercomHttpResponse find(FindCompanyRequest request, RequestOpt } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -318,24 +315,36 @@ public IntercomHttpResponse update(UpdateCompanyRequest request, Reques .addPathSegments("companies") .addPathSegment(request.getCompanyId()) .build(); - Request.Builder _requestBuilder = new Request.Builder() + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.getBody().isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes( + request.getBody().get()), + MediaTypes.APPLICATION_JSON); + } + } catch (JsonProcessingException e) { + throw new IntercomException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() .url(httpUrl) - .method("PUT", RequestBody.create("", null)) + .method("PUT", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -348,11 +357,9 @@ public IntercomHttpResponse update(UpdateCompanyRequest request, Reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -379,7 +386,6 @@ public IntercomHttpResponse delete( .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(); @@ -388,12 +394,11 @@ public IntercomHttpResponse delete( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCompanyObject.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedCompanyObject.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -406,11 +411,9 @@ public IntercomHttpResponse delete( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -428,24 +431,16 @@ public IntercomHttpResponse listAttachedContacts(ListAt */ public IntercomHttpResponse listAttachedContacts( ListAttachedContactsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("companies") .addPathSegment(request.getCompanyId()) - .addPathSegments("contacts"); - 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); - } + .addPathSegments("contacts") + .build(); Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) + .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(); @@ -454,12 +449,12 @@ public IntercomHttpResponse listAttachedContacts( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyAttachedContacts.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CompanyAttachedContacts.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -472,11 +467,9 @@ public IntercomHttpResponse listAttachedContacts( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -505,7 +498,6 @@ public IntercomHttpResponse listAttachedSegments( .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(); @@ -514,12 +506,12 @@ public IntercomHttpResponse listAttachedSegments( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyAttachedSegments.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CompanyAttachedSegments.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -532,11 +524,9 @@ public IntercomHttpResponse listAttachedSegments( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -584,11 +574,11 @@ public IntercomHttpResponse> list( .addPathSegments("companies/list"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().get(), false); } if (request.getOrder().isPresent()) { QueryStringMapper.addQueryParameter( @@ -598,7 +588,6 @@ public IntercomHttpResponse> list( .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(); @@ -607,21 +596,22 @@ public IntercomHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - CompanyList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class); - int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + CompanyList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CompanyList.class); + int newPageNumber = + request.getPage().map((Integer page) -> page + 1).orElse(1); ListCompaniesRequest nextRequest = ListCompaniesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable( + true, result, parsedResponse, () -> list(nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -630,11 +620,9 @@ public IntercomHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -712,7 +700,6 @@ public IntercomHttpResponse> scroll( .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(); @@ -721,22 +708,23 @@ public IntercomHttpResponse> scroll( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - CompanyScroll parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyScroll.class); - Optional startingAfter = parsedResponse.getScrollParam(); + Optional parsedResponse = ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}); + Optional startingAfter = parsedResponse.flatMap(CompanyScroll::getScrollParam); ScrollCompaniesRequest nextRequest = ScrollCompaniesRequest.builder() .from(request) .scrollParam(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = + parsedResponse.flatMap(CompanyScroll::getData).orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> scroll(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> scroll( + nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -745,11 +733,9 @@ public IntercomHttpResponse> scroll( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -793,11 +779,11 @@ public IntercomHttpResponse attachContact( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -813,11 +799,9 @@ public IntercomHttpResponse attachContact( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -846,7 +830,6 @@ public IntercomHttpResponse detachContact( .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(); @@ -855,11 +838,11 @@ public IntercomHttpResponse detachContact( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Company.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -872,11 +855,9 @@ public IntercomHttpResponse detachContact( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 615bf52..caa5755 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 @@ -79,7 +79,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ CompanyIdStage contactId(@NotNull String contactId); @@ -88,7 +88,7 @@ public interface ContactIdStage { public interface CompanyIdStage { /** - * The unique identifier for the company which is given by Intercom + *

The unique identifier for the company which is given by Intercom

*/ _FinalStage companyId(@NotNull String companyId); } @@ -116,7 +116,8 @@ 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

+ *

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 @@ -127,7 +128,8 @@ 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

+ *

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/DeleteCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/DeleteCompanyRequest.java index 7ec0ea0..1a833e4 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 @@ -67,7 +67,7 @@ public static CompanyIdStage builder() { public interface CompanyIdStage { /** - * The unique identifier for the company which is given by Intercom + *

The unique identifier for the company which is given by Intercom

*/ _FinalStage companyId(@NotNull String companyId); @@ -94,7 +94,8 @@ 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

+ *

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 fd51def..46c5530 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 @@ -79,7 +79,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ CompanyIdStage contactId(@NotNull String contactId); @@ -88,7 +88,7 @@ public interface ContactIdStage { public interface CompanyIdStage { /** - * The unique identifier for the company which is given by Intercom + *

The unique identifier for the company which is given by Intercom

*/ _FinalStage companyId(@NotNull String companyId); } @@ -116,7 +116,8 @@ 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

+ *

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 @@ -127,7 +128,8 @@ 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

+ *

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 7b57351..08408af 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 @@ -67,7 +67,7 @@ public static CompanyIdStage builder() { public interface CompanyIdStage { /** - * The unique identifier for the company which is given by Intercom + *

The unique identifier for the company which is given by Intercom

*/ _FinalStage companyId(@NotNull String companyId); @@ -94,7 +94,8 @@ 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

+ *

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 9985bf0..1dcb9e6 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 @@ -9,13 +9,11 @@ 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) @@ -23,20 +21,10 @@ public final class ListAttachedContactsRequest { private final String companyId; - private final Optional page; - - private final Optional perPage; - private final Map additionalProperties; - private ListAttachedContactsRequest( - String companyId, - Optional page, - Optional perPage, - Map additionalProperties) { + private ListAttachedContactsRequest(String companyId, Map additionalProperties) { this.companyId = companyId; - this.page = page; - this.perPage = perPage; this.additionalProperties = additionalProperties; } @@ -48,22 +36,6 @@ public String getCompanyId() { return companyId; } - /** - * @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; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -76,12 +48,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ListAttachedContactsRequest other) { - return companyId.equals(other.companyId) && page.equals(other.page) && perPage.equals(other.perPage); + return companyId.equals(other.companyId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId, this.page, this.perPage); + return Objects.hash(this.companyId); } @java.lang.Override @@ -95,7 +67,7 @@ public static CompanyIdStage builder() { public interface CompanyIdStage { /** - * The unique identifier for the company which is given by Intercom + *

The unique identifier for the company which is given by Intercom

*/ _FinalStage companyId(@NotNull String companyId); @@ -104,30 +76,12 @@ 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); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CompanyIdStage, _FinalStage { private String companyId; - private Optional perPage = Optional.empty(); - - private Optional page = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -136,13 +90,12 @@ private Builder() {} @java.lang.Override public Builder from(ListAttachedContactsRequest other) { companyId(other.getCompanyId()); - page(other.getPage()); - perPage(other.getPerPage()); return this; } /** - * 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

+ *

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 @@ -152,49 +105,9 @@ public _FinalStage companyId(@NotNull String companyId) { return this; } - /** - *

How many results to return per page. Defaults to 15

- * @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; - } - - /** - *

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) { - this.perPage = perPage; - return this; - } - - /** - *

The page of results to fetch. Defaults to first page

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage page(Integer page) { - this.page = Optional.ofNullable(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) { - this.page = page; - return this; - } - @java.lang.Override public ListAttachedContactsRequest build() { - return new ListAttachedContactsRequest(companyId, page, perPage, additionalProperties); + return new ListAttachedContactsRequest(companyId, additionalProperties); } } } 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 def61ad..37ea0c1 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 @@ -68,7 +68,7 @@ public static CompanyIdStage builder() { public interface CompanyIdStage { /** - * The unique identifier for the company which is given by Intercom + *

The unique identifier for the company which is given by Intercom

*/ _FinalStage companyId(@NotNull String companyId); @@ -95,7 +95,8 @@ 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

+ *

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/UpdateCompanyRequest.java b/src/main/java/com/intercom/api/resources/companies/requests/UpdateCompanyRequest.java index 8d77e60..ad67986 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 @@ -9,11 +9,14 @@ 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.types.UpdateCompanyRequestBody; 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) @@ -21,10 +24,14 @@ public final class UpdateCompanyRequest { private final String companyId; + private final Optional body; + private final Map additionalProperties; - private UpdateCompanyRequest(String companyId, Map additionalProperties) { + private UpdateCompanyRequest( + String companyId, Optional body, Map additionalProperties) { this.companyId = companyId; + this.body = body; this.additionalProperties = additionalProperties; } @@ -36,6 +43,11 @@ public String getCompanyId() { return companyId; } + @JsonProperty("body") + public Optional getBody() { + return body; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -48,12 +60,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateCompanyRequest other) { - return companyId.equals(other.companyId); + return companyId.equals(other.companyId) && body.equals(other.body); } @java.lang.Override public int hashCode() { - return Objects.hash(this.companyId); + return Objects.hash(this.companyId, this.body); } @java.lang.Override @@ -67,7 +79,7 @@ public static CompanyIdStage builder() { public interface CompanyIdStage { /** - * The unique identifier for the company which is given by Intercom + *

The unique identifier for the company which is given by Intercom

*/ _FinalStage companyId(@NotNull String companyId); @@ -76,12 +88,18 @@ public interface CompanyIdStage { public interface _FinalStage { UpdateCompanyRequest build(); + + _FinalStage body(Optional body); + + _FinalStage body(UpdateCompanyRequestBody body); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CompanyIdStage, _FinalStage { private String companyId; + private Optional body = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -90,11 +108,13 @@ private Builder() {} @java.lang.Override public Builder from(UpdateCompanyRequest other) { companyId(other.getCompanyId()); + body(other.getBody()); return this; } /** - * 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

+ *

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 @@ -104,9 +124,22 @@ public _FinalStage companyId(@NotNull String companyId) { return this; } + @java.lang.Override + public _FinalStage body(UpdateCompanyRequestBody body) { + this.body = Optional.ofNullable(body); + return this; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + @java.lang.Override public UpdateCompanyRequest build() { - return new UpdateCompanyRequest(companyId, additionalProperties); + return new UpdateCompanyRequest(companyId, body, additionalProperties); } } } 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 4231d07..d600dc0 100644 --- a/src/main/java/com/intercom/api/resources/companies/types/Company.java +++ b/src/main/java/com/intercom/api/resources/companies/types/Company.java @@ -23,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Company.Builder.class) public final class Company { + private final Optional type; + private final String id; private final String name; @@ -33,19 +35,19 @@ public final class Company { private final String companyId; - private final int remoteCreatedAt; + private final Optional remoteCreatedAt; private final int createdAt; private final int updatedAt; - private final int lastRequestAt; + private final Optional lastRequestAt; - private final int size; + private final Optional size; - private final String website; + private final Optional website; - private final String industry; + private final Optional industry; private final int monthlySpend; @@ -62,18 +64,19 @@ public final class Company { private final Map additionalProperties; private Company( + Optional type, String id, String name, String appId, Optional plan, String companyId, - int remoteCreatedAt, + Optional remoteCreatedAt, int createdAt, int updatedAt, - int lastRequestAt, - int size, - String website, - String industry, + Optional lastRequestAt, + Optional size, + Optional website, + Optional industry, int monthlySpend, int sessionCount, int userCount, @@ -81,6 +84,7 @@ private Company( Optional tags, Optional segments, Map additionalProperties) { + this.type = type; this.id = id; this.name = name; this.appId = appId; @@ -102,6 +106,14 @@ private Company( this.additionalProperties = additionalProperties; } + /** + * @return Value is company + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + /** * @return The Intercom defined id representing the company. */ @@ -143,7 +155,7 @@ public String getCompanyId() { * @return The time the company was created by you. */ @JsonProperty("remote_created_at") - public int getRemoteCreatedAt() { + public Optional getRemoteCreatedAt() { return remoteCreatedAt; } @@ -167,7 +179,7 @@ public int getUpdatedAt() { * @return The time the company last recorded making a request. */ @JsonProperty("last_request_at") - public int getLastRequestAt() { + public Optional getLastRequestAt() { return lastRequestAt; } @@ -175,7 +187,7 @@ public int getLastRequestAt() { * @return The number of employees in the company. */ @JsonProperty("size") - public int getSize() { + public Optional getSize() { return size; } @@ -183,7 +195,7 @@ public int getSize() { * @return The URL for the company website. */ @JsonProperty("website") - public String getWebsite() { + public Optional getWebsite() { return website; } @@ -191,7 +203,7 @@ public String getWebsite() { * @return The industry that the company operates in. */ @JsonProperty("industry") - public String getIndustry() { + public Optional getIndustry() { return industry; } @@ -255,16 +267,17 @@ public Map getAdditionalProperties() { } private boolean equalTo(Company other) { - return id.equals(other.id) + 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 == other.remoteCreatedAt + && remoteCreatedAt.equals(other.remoteCreatedAt) && createdAt == other.createdAt && updatedAt == other.updatedAt - && lastRequestAt == other.lastRequestAt - && size == other.size + && lastRequestAt.equals(other.lastRequestAt) + && size.equals(other.size) && website.equals(other.website) && industry.equals(other.industry) && monthlySpend == other.monthlySpend @@ -278,6 +291,7 @@ private boolean equalTo(Company other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.type, this.id, this.name, this.appId, @@ -309,7 +323,7 @@ public static IdStage builder() { public interface IdStage { /** - * The Intercom defined id representing the company. + *

The Intercom defined id representing the company.

*/ NameStage id(@NotNull String id); @@ -318,101 +332,108 @@ public interface IdStage { public interface NameStage { /** - * The name of the company. + *

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. + *

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. + *

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); + CreatedAtStage companyId(@NotNull String companyId); } public interface CreatedAtStage { /** - * The time the company was added in Intercom. + *

The time the company was added in Intercom.

*/ UpdatedAtStage createdAt(int createdAt); } public interface UpdatedAtStage { /** - * The last time the company was updated. + *

The last time the company was updated.

*/ - LastRequestAtStage updatedAt(int updatedAt); + MonthlySpendStage updatedAt(int updatedAt); } - public interface LastRequestAtStage { + public interface MonthlySpendStage { /** - * The time the company last recorded making a request. + *

How much revenue the company generates for your business.

*/ - SizeStage lastRequestAt(int lastRequestAt); + SessionCountStage monthlySpend(int monthlySpend); } - public interface SizeStage { + public interface SessionCountStage { /** - * The number of employees in the company. + *

How many sessions the company has recorded.

*/ - WebsiteStage size(int size); + UserCountStage sessionCount(int sessionCount); } - public interface WebsiteStage { + public interface UserCountStage { /** - * The URL for the company website. + *

The number of users in the company.

*/ - IndustryStage website(@NotNull String website); + _FinalStage userCount(int userCount); } - public interface IndustryStage { + public interface _FinalStage { + Company build(); + /** - * The industry that the company operates in. + *

Value is company

*/ - MonthlySpendStage industry(@NotNull String industry); - } + _FinalStage type(Optional type); + + _FinalStage type(String type); + + _FinalStage plan(Optional plan); + + _FinalStage plan(Plan plan); - public interface MonthlySpendStage { /** - * How much revenue the company generates for your business. + *

The time the company was created by you.

*/ - SessionCountStage monthlySpend(int monthlySpend); - } + _FinalStage remoteCreatedAt(Optional remoteCreatedAt); + + _FinalStage remoteCreatedAt(Integer remoteCreatedAt); - public interface SessionCountStage { /** - * How many sessions the company has recorded. + *

The time the company last recorded making a request.

*/ - UserCountStage sessionCount(int sessionCount); - } + _FinalStage lastRequestAt(Optional lastRequestAt); + + _FinalStage lastRequestAt(Integer lastRequestAt); - public interface UserCountStage { /** - * The number of users in the company. + *

The number of employees in the company.

*/ - _FinalStage userCount(int userCount); - } + _FinalStage size(Optional size); - public interface _FinalStage { - Company build(); + _FinalStage size(Integer size); - _FinalStage plan(Optional plan); + /** + *

The URL for the company website.

+ */ + _FinalStage website(Optional website); - _FinalStage plan(Plan plan); + _FinalStage website(String website); + + /** + *

The industry that the company operates in.

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

The custom attributes you have set on the company.

@@ -442,13 +463,8 @@ public static final class Builder NameStage, AppIdStage, CompanyIdStage, - RemoteCreatedAtStage, CreatedAtStage, UpdatedAtStage, - LastRequestAtStage, - SizeStage, - WebsiteStage, - IndustryStage, MonthlySpendStage, SessionCountStage, UserCountStage, @@ -461,20 +477,10 @@ public static final class Builder private String companyId; - private int remoteCreatedAt; - private int createdAt; private int updatedAt; - private int lastRequestAt; - - private int size; - - private String website; - - private String industry; - private int monthlySpend; private int sessionCount; @@ -487,8 +493,20 @@ public static final class Builder private Optional> customAttributes = Optional.empty(); + private Optional industry = Optional.empty(); + + private Optional website = Optional.empty(); + + private Optional size = Optional.empty(); + + private Optional lastRequestAt = Optional.empty(); + + private Optional remoteCreatedAt = Optional.empty(); + private Optional plan = Optional.empty(); + private Optional type = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -496,6 +514,7 @@ private Builder() {} @java.lang.Override public Builder from(Company other) { + type(other.getType()); id(other.getId()); name(other.getName()); appId(other.getAppId()); @@ -518,7 +537,8 @@ 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.

+ *

The Intercom defined id representing the company.

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

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 @@ -540,7 +561,8 @@ 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.

+ *

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 @@ -551,29 +573,20 @@ 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.

+ *

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 @JsonSetter("company_id") - public RemoteCreatedAtStage companyId(@NotNull String companyId) { + public CreatedAtStage companyId(@NotNull String companyId) { this.companyId = Objects.requireNonNull(companyId, "companyId must not be null"); return this; } /** - * 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 - @JsonSetter("remote_created_at") - public CreatedAtStage remoteCreatedAt(int remoteCreatedAt) { - this.remoteCreatedAt = remoteCreatedAt; - return this; - } - - /** - * The time the company was added in Intercom.

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 @@ -584,62 +597,20 @@ 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.

+ *

The last time the company was updated.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @JsonSetter("updated_at") - public LastRequestAtStage updatedAt(int updatedAt) { + public MonthlySpendStage updatedAt(int updatedAt) { this.updatedAt = updatedAt; return this; } /** - * 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 - @JsonSetter("last_request_at") - public SizeStage lastRequestAt(int lastRequestAt) { - this.lastRequestAt = lastRequestAt; - return this; - } - - /** - * 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 - @JsonSetter("size") - public WebsiteStage size(int size) { - this.size = size; - return this; - } - - /** - * 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 - @JsonSetter("website") - public IndustryStage website(@NotNull String website) { - this.website = Objects.requireNonNull(website, "website must not be null"); - return this; - } - - /** - * 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 - @JsonSetter("industry") - public MonthlySpendStage industry(@NotNull String industry) { - this.industry = Objects.requireNonNull(industry, "industry must not be null"); - return this; - } - - /** - * 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.

+ *

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 @@ -650,7 +621,8 @@ 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.

+ *

How many sessions the company has recorded.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -661,7 +633,8 @@ 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.

+ *

The number of users in the company.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -731,6 +704,106 @@ public _FinalStage customAttributes(Optional> customAttribut return this; } + /** + *

The industry that the company operates in.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage industry(String industry) { + this.industry = Optional.ofNullable(industry); + return this; + } + + /** + *

The industry that the company operates in.

+ */ + @java.lang.Override + @JsonSetter(value = "industry", nulls = Nulls.SKIP) + public _FinalStage industry(Optional industry) { + this.industry = industry; + return this; + } + + /** + *

The URL for the company website.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage website(String website) { + this.website = Optional.ofNullable(website); + return this; + } + + /** + *

The URL for the company website.

+ */ + @java.lang.Override + @JsonSetter(value = "website", nulls = Nulls.SKIP) + public _FinalStage website(Optional website) { + this.website = website; + return this; + } + + /** + *

The number of employees in the company.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage size(Integer size) { + this.size = Optional.ofNullable(size); + return this; + } + + /** + *

The number of employees in the company.

+ */ + @java.lang.Override + @JsonSetter(value = "size", nulls = Nulls.SKIP) + public _FinalStage size(Optional size) { + this.size = size; + return this; + } + + /** + *

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 + public _FinalStage lastRequestAt(Integer lastRequestAt) { + this.lastRequestAt = Optional.ofNullable(lastRequestAt); + return this; + } + + /** + *

The time the company last recorded making a request.

+ */ + @java.lang.Override + @JsonSetter(value = "last_request_at", nulls = Nulls.SKIP) + public _FinalStage lastRequestAt(Optional lastRequestAt) { + this.lastRequestAt = lastRequestAt; + return this; + } + + /** + *

The time the company was created by you.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage remoteCreatedAt(Integer remoteCreatedAt) { + this.remoteCreatedAt = Optional.ofNullable(remoteCreatedAt); + return this; + } + + /** + *

The time the company was created by you.

+ */ + @java.lang.Override + @JsonSetter(value = "remote_created_at", nulls = Nulls.SKIP) + public _FinalStage remoteCreatedAt(Optional remoteCreatedAt) { + this.remoteCreatedAt = remoteCreatedAt; + return this; + } + @java.lang.Override public _FinalStage plan(Plan plan) { this.plan = Optional.ofNullable(plan); @@ -744,9 +817,30 @@ public _FinalStage plan(Optional plan) { return this; } + /** + *

Value is company

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage type(String type) { + this.type = Optional.ofNullable(type); + return this; + } + + /** + *

Value is company

+ */ + @java.lang.Override + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public _FinalStage type(Optional type) { + this.type = type; + return this; + } + @java.lang.Override public Company build() { return new Company( + type, id, name, appId, diff --git a/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java index f2a70d1..c9a2880 100644 --- a/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/AsyncContactsClient.java @@ -9,6 +9,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -18,11 +19,18 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactSegments; import com.intercom.api.types.ContactUnarchived; @@ -156,28 +164,37 @@ public CompletableFuture listAttachedTags( /** * You can fetch the details of a single contact. */ - public CompletableFuture find(FindContactRequest request) { + public CompletableFuture find(FindContactRequest request) { return this.rawClient.find(request).thenApply(response -> response.body()); } /** * You can fetch the details of a single contact. */ - public CompletableFuture find(FindContactRequest request, RequestOptions requestOptions) { + public CompletableFuture find(FindContactRequest request, RequestOptions requestOptions) { return this.rawClient.find(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 update(UpdateContactRequest request) { + public CompletableFuture update(UpdateContactRequest request) { return this.rawClient.update(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 update(UpdateContactRequest request, RequestOptions requestOptions) { + public CompletableFuture update( + UpdateContactRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).thenApply(response -> response.body()); } @@ -198,14 +215,22 @@ public CompletableFuture delete(DeleteContactRequest request, Re /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public CompletableFuture mergeLeadInUser(MergeContactsRequest request) { + public CompletableFuture mergeLeadInUser() { + return this.rawClient.mergeLeadInUser().thenApply(response -> response.body()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture mergeLeadInUser(MergeContactsRequest request) { return this.rawClient.mergeLeadInUser(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 mergeLeadInUser(MergeContactsRequest request, RequestOptions requestOptions) { + public CompletableFuture mergeLeadInUser( + MergeContactsRequest request, RequestOptions requestOptions) { return this.rawClient.mergeLeadInUser(request, requestOptions).thenApply(response -> response.body()); } @@ -430,17 +455,34 @@ public CompletableFuture> list( /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture create(CreateContactRequest request) { + public CompletableFuture create(CreateContactRequest request) { return this.rawClient.create(request).thenApply(response -> response.body()); } /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture create(CreateContactRequest request, RequestOptions requestOptions) { + public CompletableFuture create( + CreateContactRequest request, RequestOptions requestOptions) { return this.rawClient.create(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. */ @@ -469,4 +511,18 @@ public CompletableFuture unarchive( UnarchiveContactRequest request, RequestOptions requestOptions) { return this.rawClient.unarchive(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/contacts/AsyncRawContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/AsyncRawContactsClient.java index 28dc93a..9a76625 100644 --- a/src/main/java/com/intercom/api/resources/contacts/AsyncRawContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/AsyncRawContactsClient.java @@ -18,6 +18,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -27,12 +28,19 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; import com.intercom.api.types.ContactAttachedCompanies; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactList; import com.intercom.api.types.ContactSegments; @@ -45,6 +53,7 @@ import com.intercom.api.types.SubscriptionTypeList; import com.intercom.api.types.TagList; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -87,17 +96,16 @@ public CompletableFuture>> list .addPathSegments("companies"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -109,18 +117,20 @@ public CompletableFuture>> list @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - ContactAttachedCompanies parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), ContactAttachedCompanies.class); - int newPageNumber = - request.getPage().map(page -> page + 1).orElse(1); + ContactAttachedCompanies parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactAttachedCompanies.class); + int newPageNumber = request.getPage() + .map((Integer page) -> page + 1) + .orElse(1); ListAttachedCompaniesRequest nextRequest = ListAttachedCompaniesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getCompanies(); + List result = parsedResponse.getCompanies().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> { + new SyncPagingIterable(true, result, parsedResponse, () -> { try { return listAttachedCompanies(nextRequest, requestOptions) .get() @@ -132,7 +142,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -149,11 +158,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -191,7 +198,6 @@ public CompletableFuture> listAttachedSegm .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(); @@ -203,13 +209,13 @@ public CompletableFuture> listAttachedSegm @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactSegments.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactSegments.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -226,11 +232,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -276,7 +280,6 @@ public CompletableFuture> listAttache .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(); @@ -288,13 +291,13 @@ public CompletableFuture> listAttache @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionTypeList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -311,11 +314,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -378,13 +379,13 @@ public CompletableFuture> attachSubscript @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionType.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -401,11 +402,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -444,7 +443,6 @@ public CompletableFuture> detachSubscript .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(); @@ -456,13 +454,13 @@ public CompletableFuture> detachSubscript @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionType.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -479,11 +477,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -520,7 +516,6 @@ public CompletableFuture> listAttachedTags( .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(); @@ -532,12 +527,12 @@ public CompletableFuture> listAttachedTags( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TagList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -554,11 +549,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -576,14 +569,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can fetch the details of a single contact. */ - public CompletableFuture> find(FindContactRequest request) { + public CompletableFuture> find(FindContactRequest request) { return find(request, null); } /** * You can fetch the details of a single contact. */ - public CompletableFuture> find( + public CompletableFuture> find( FindContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -594,24 +587,24 @@ public CompletableFuture> find( .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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactsFindResponse.class), + response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -621,11 +614,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -642,15 +633,23 @@ public void onFailure(@NotNull Call call, @NotNull IOException 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 CompletableFuture> update(UpdateContactRequest request) { + public CompletableFuture> update(UpdateContactRequest request) { return update(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> update( + public CompletableFuture> update( UpdateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -675,17 +674,18 @@ public CompletableFuture> update( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactsUpdateResponse.class), + response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -695,11 +695,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -735,7 +733,6 @@ public CompletableFuture> delete( .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(); @@ -747,13 +744,13 @@ public CompletableFuture> delete( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactDeleted.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactDeleted.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -763,11 +760,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -785,14 +780,22 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public CompletableFuture> mergeLeadInUser(MergeContactsRequest request) { + public CompletableFuture> mergeLeadInUser() { + return mergeLeadInUser(MergeContactsRequest.builder().build()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public CompletableFuture> mergeLeadInUser( + MergeContactsRequest request) { return mergeLeadInUser(request, null); } /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public CompletableFuture> mergeLeadInUser( + public CompletableFuture> mergeLeadInUser( MergeContactsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -816,17 +819,19 @@ public CompletableFuture> mergeLeadInUser( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, ContactsMergeLeadInUserResponse.class), + response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -836,11 +841,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1064,15 +1067,16 @@ public CompletableFuture>> sear @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ContactList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) .flatMap(StartingAfterPaging::getStartingAfter); Optional pagination = request.getPagination() - .map(pagination_ -> StartingAfterPaging.builder() + .map((StartingAfterPaging pagination_) -> StartingAfterPaging.builder() .from(pagination_) .startingAfter(startingAfter) .build()); @@ -1080,21 +1084,21 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return search(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -1104,11 +1108,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1159,11 +1161,11 @@ public CompletableFuture>> list .addPathSegments("contacts"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().get(), false); } if (request.getStartingAfter().isPresent()) { QueryStringMapper.addQueryParameter( @@ -1173,7 +1175,6 @@ public CompletableFuture>> list .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(); @@ -1185,9 +1186,10 @@ public CompletableFuture>> list @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ContactList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -1196,21 +1198,21 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return list(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return list(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -1220,11 +1222,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1242,14 +1242,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture> create(CreateContactRequest request) { + public CompletableFuture> create(CreateContactRequest request) { return create(request, null); } /** * You can create a new contact (ie. user or lead). */ - public CompletableFuture> create( + public CompletableFuture> create( CreateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -1273,17 +1273,85 @@ public CompletableFuture> create( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactsCreateResponse.class), + response)); return; } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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()) { String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, ShowContactByExternalIdResponse.class), + response)); + return; + } try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -1293,11 +1361,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1334,7 +1400,6 @@ public CompletableFuture> archive( .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(); @@ -1346,18 +1411,16 @@ public CompletableFuture> archive( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactArchived.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactArchived.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1394,7 +1457,6 @@ public CompletableFuture> unarchive( .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(); @@ -1406,18 +1468,73 @@ public CompletableFuture> unarchive( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactUnarchived.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactUnarchived.class), response)); return; } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getContactId()) + .addPathSegments("block") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", 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()) { String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactBlocked.class), + response)); + return; + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java index dd7ed73..3c5cbf7 100644 --- a/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/ContactsClient.java @@ -9,6 +9,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -18,11 +19,18 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactSegments; import com.intercom.api.types.ContactUnarchived; @@ -154,28 +162,36 @@ public TagList listAttachedTags(ListTagsAttachedToContactRequest request, Reques /** * You can fetch the details of a single contact. */ - public Contact find(FindContactRequest request) { + public ContactsFindResponse find(FindContactRequest request) { return this.rawClient.find(request).body(); } /** * You can fetch the details of a single contact. */ - public Contact find(FindContactRequest request, RequestOptions requestOptions) { + public ContactsFindResponse find(FindContactRequest request, RequestOptions requestOptions) { return this.rawClient.find(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 Contact update(UpdateContactRequest request) { + public ContactsUpdateResponse update(UpdateContactRequest request) { return this.rawClient.update(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 Contact update(UpdateContactRequest request, RequestOptions requestOptions) { + public ContactsUpdateResponse update(UpdateContactRequest request, RequestOptions requestOptions) { return this.rawClient.update(request, requestOptions).body(); } @@ -196,14 +212,22 @@ public ContactDeleted delete(DeleteContactRequest request, RequestOptions reques /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public Contact mergeLeadInUser(MergeContactsRequest request) { + public ContactsMergeLeadInUserResponse mergeLeadInUser() { + return this.rawClient.mergeLeadInUser().body(); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public ContactsMergeLeadInUserResponse mergeLeadInUser(MergeContactsRequest request) { return this.rawClient.mergeLeadInUser(request).body(); } /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public Contact mergeLeadInUser(MergeContactsRequest request, RequestOptions requestOptions) { + public ContactsMergeLeadInUserResponse mergeLeadInUser( + MergeContactsRequest request, RequestOptions requestOptions) { return this.rawClient.mergeLeadInUser(request, requestOptions).body(); } @@ -427,17 +451,32 @@ public SyncPagingIterable list(ListContactsRequest request, RequestOpti /** * You can create a new contact (ie. user or lead). */ - public Contact create(CreateContactRequest request) { + public ContactsCreateResponse create(CreateContactRequest request) { return this.rawClient.create(request).body(); } /** * You can create a new contact (ie. user or lead). */ - public Contact create(CreateContactRequest request, RequestOptions requestOptions) { + public ContactsCreateResponse create(CreateContactRequest request, RequestOptions requestOptions) { return this.rawClient.create(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. */ @@ -465,4 +504,18 @@ public ContactUnarchived unarchive(UnarchiveContactRequest request) { public ContactUnarchived unarchive(UnarchiveContactRequest request, RequestOptions requestOptions) { return this.rawClient.unarchive(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/contacts/RawContactsClient.java b/src/main/java/com/intercom/api/resources/contacts/RawContactsClient.java index e9000a9..6b5cfe9 100644 --- a/src/main/java/com/intercom/api/resources/contacts/RawContactsClient.java +++ b/src/main/java/com/intercom/api/resources/contacts/RawContactsClient.java @@ -18,6 +18,7 @@ import com.intercom.api.resources.companies.types.Company; import com.intercom.api.resources.contacts.requests.ArchiveContactRequest; import com.intercom.api.resources.contacts.requests.AttachSubscriptionToContactRequest; +import com.intercom.api.resources.contacts.requests.BlockContactRequest; import com.intercom.api.resources.contacts.requests.DeleteContactRequest; import com.intercom.api.resources.contacts.requests.DetachSubscriptionFromContactRequest; import com.intercom.api.resources.contacts.requests.FindContactRequest; @@ -27,12 +28,19 @@ import com.intercom.api.resources.contacts.requests.ListSegmentsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.ListTagsAttachedToContactRequest; import com.intercom.api.resources.contacts.requests.MergeContactsRequest; +import com.intercom.api.resources.contacts.requests.ShowContactByExternalIdRequest; import com.intercom.api.resources.contacts.requests.UnarchiveContactRequest; import com.intercom.api.resources.contacts.requests.UpdateContactRequest; import com.intercom.api.resources.contacts.types.Contact; +import com.intercom.api.resources.contacts.types.ContactsCreateResponse; +import com.intercom.api.resources.contacts.types.ContactsFindResponse; +import com.intercom.api.resources.contacts.types.ContactsMergeLeadInUserResponse; +import com.intercom.api.resources.contacts.types.ContactsUpdateResponse; +import com.intercom.api.resources.contacts.types.ShowContactByExternalIdResponse; import com.intercom.api.resources.subscriptiontypes.types.SubscriptionType; import com.intercom.api.types.ContactArchived; import com.intercom.api.types.ContactAttachedCompanies; +import com.intercom.api.types.ContactBlocked; import com.intercom.api.types.ContactDeleted; import com.intercom.api.types.ContactList; import com.intercom.api.types.ContactSegments; @@ -45,6 +53,7 @@ import com.intercom.api.types.SubscriptionTypeList; import com.intercom.api.types.TagList; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import okhttp3.Headers; @@ -82,17 +91,16 @@ public IntercomHttpResponse> listAttachedCompanies( .addPathSegments("companies"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -101,22 +109,23 @@ public IntercomHttpResponse> listAttachedCompanies( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { ContactAttachedCompanies parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactAttachedCompanies.class); - int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactAttachedCompanies.class); + int newPageNumber = + request.getPage().map((Integer page) -> page + 1).orElse(1); ListAttachedCompaniesRequest nextRequest = ListAttachedCompaniesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getCompanies(); + List result = parsedResponse.getCompanies().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( - true, result, () -> listAttachedCompanies(nextRequest, requestOptions) + true, result, parsedResponse, () -> listAttachedCompanies(nextRequest, requestOptions) .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -129,11 +138,9 @@ public IntercomHttpResponse> listAttachedCompanies( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -161,7 +168,6 @@ public IntercomHttpResponse listAttachedSegments( .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(); @@ -170,11 +176,11 @@ public IntercomHttpResponse listAttachedSegments( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactSegments.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactSegments.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -187,11 +193,9 @@ public IntercomHttpResponse listAttachedSegments( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -228,7 +232,6 @@ public IntercomHttpResponse listAttachedSubscriptions( .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(); @@ -237,12 +240,11 @@ public IntercomHttpResponse listAttachedSubscriptions( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionTypeList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -255,11 +257,9 @@ public IntercomHttpResponse listAttachedSubscriptions( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -309,11 +309,11 @@ public IntercomHttpResponse attachSubscription( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionType.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -326,11 +326,9 @@ public IntercomHttpResponse attachSubscription( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -359,7 +357,6 @@ public IntercomHttpResponse detachSubscription( .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(); @@ -368,11 +365,11 @@ public IntercomHttpResponse detachSubscription( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionType.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionType.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -385,11 +382,9 @@ public IntercomHttpResponse detachSubscription( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -417,7 +412,6 @@ public IntercomHttpResponse listAttachedTags( .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(); @@ -426,11 +420,11 @@ public IntercomHttpResponse listAttachedTags( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TagList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -443,11 +437,9 @@ public IntercomHttpResponse listAttachedTags( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -456,14 +448,14 @@ public IntercomHttpResponse listAttachedTags( /** * You can fetch the details of a single contact. */ - public IntercomHttpResponse find(FindContactRequest request) { + public IntercomHttpResponse find(FindContactRequest request) { return find(request, null); } /** * You can fetch the details of a single contact. */ - public IntercomHttpResponse find(FindContactRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse find(FindContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") @@ -473,7 +465,6 @@ public IntercomHttpResponse find(FindContactRequest request, RequestOpt .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(); @@ -482,11 +473,11 @@ public IntercomHttpResponse find(FindContactRequest request, RequestOpt } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactsFindResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -495,11 +486,9 @@ public IntercomHttpResponse find(FindContactRequest request, RequestOpt } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -507,15 +496,24 @@ public IntercomHttpResponse find(FindContactRequest request, RequestOpt /** * 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 update(UpdateContactRequest request) { + public IntercomHttpResponse update(UpdateContactRequest request) { return update(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 update(UpdateContactRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse update( + UpdateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") @@ -541,11 +539,12 @@ public IntercomHttpResponse update(UpdateContactRequest request, Reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactsUpdateResponse.class), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -554,11 +553,9 @@ public IntercomHttpResponse update(UpdateContactRequest request, Reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -584,7 +581,6 @@ public IntercomHttpResponse delete(DeleteContactRequest request, .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(); @@ -593,11 +589,11 @@ public IntercomHttpResponse delete(DeleteContactRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactDeleted.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactDeleted.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -606,11 +602,9 @@ public IntercomHttpResponse delete(DeleteContactRequest request, } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -619,14 +613,22 @@ public IntercomHttpResponse delete(DeleteContactRequest request, /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest request) { + public IntercomHttpResponse mergeLeadInUser() { + return mergeLeadInUser(MergeContactsRequest.builder().build()); + } + + /** + * You can merge a contact with a role of lead into a contact with a role of user. + */ + public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest request) { return mergeLeadInUser(request, null); } /** * You can merge a contact with a role of lead into a contact with a role of user. */ - public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse mergeLeadInUser( + MergeContactsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts/merge") @@ -651,11 +653,12 @@ public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactsMergeLeadInUserResponse.class), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -664,11 +667,9 @@ public IntercomHttpResponse mergeLeadInUser(MergeContactsRequest reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -880,15 +881,15 @@ public IntercomHttpResponse> search( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - ContactList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + ContactList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) .flatMap(StartingAfterPaging::getStartingAfter); Optional pagination = request.getPagination() - .map(pagination_ -> StartingAfterPaging.builder() + .map((StartingAfterPaging pagination_) -> StartingAfterPaging.builder() .from(pagination_) .startingAfter(startingAfter) .build()); @@ -896,14 +897,13 @@ public IntercomHttpResponse> search( .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> search( + nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -912,11 +912,9 @@ public IntercomHttpResponse> search( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -958,11 +956,11 @@ public IntercomHttpResponse> list( .addPathSegments("contacts"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().get(), false); } if (request.getStartingAfter().isPresent()) { QueryStringMapper.addQueryParameter( @@ -972,7 +970,6 @@ public IntercomHttpResponse> list( .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(); @@ -981,9 +978,9 @@ public IntercomHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - ContactList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactList.class); + ContactList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -992,14 +989,13 @@ public IntercomHttpResponse> list( .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable(startingAfter.isPresent(), result, parsedResponse, () -> list( + nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -1008,11 +1004,9 @@ public IntercomHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -1021,14 +1015,15 @@ public IntercomHttpResponse> list( /** * You can create a new contact (ie. user or lead). */ - public IntercomHttpResponse create(CreateContactRequest request) { + public IntercomHttpResponse create(CreateContactRequest request) { return create(request, null); } /** * You can create a new contact (ie. user or lead). */ - public IntercomHttpResponse create(CreateContactRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse create( + CreateContactRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("contacts") @@ -1053,11 +1048,64 @@ public IntercomHttpResponse create(CreateContactRequest request, Reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactsCreateResponse.class), + response); } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ShowContactByExternalIdResponse.class), + response); + } try { if (response.code() == 401) { throw new UnauthorizedError( @@ -1066,11 +1114,9 @@ public IntercomHttpResponse create(CreateContactRequest request, Reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -1097,7 +1143,6 @@ public IntercomHttpResponse archive(ArchiveContactRequest reque .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(); @@ -1106,16 +1151,14 @@ public IntercomHttpResponse archive(ArchiveContactRequest reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactArchived.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactArchived.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -1143,7 +1186,6 @@ public IntercomHttpResponse unarchive( .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(); @@ -1152,16 +1194,57 @@ public IntercomHttpResponse unarchive( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactUnarchived.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactUnarchived.class), response); } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getContactId()) + .addPathSegments("block") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", 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(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ContactBlocked.class), response); + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 a1c5637..70861a4 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 @@ -29,7 +29,7 @@ private ArchiveContactRequest(String contactId, Map additionalPr } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + *

contact_id

*/ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,8 @@ public Builder from(ArchiveContactRequest other) { } /** - * id

id

+ *

contact_id

+ *

contact_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 2cea956..808e932 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 @@ -93,7 +93,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ SubscriptionIdStage contactId(@NotNull String contactId); @@ -102,14 +102,14 @@ public interface ContactIdStage { public interface SubscriptionIdStage { /** - * The unique identifier for the subscription which is given by Intercom + *

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. + *

The consent_type of a subscription, opt_out or opt_in.

*/ _FinalStage consentType(@NotNull String consentType); } @@ -140,7 +140,8 @@ 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

+ *

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 @@ -151,7 +152,8 @@ 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

+ *

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 @@ -162,7 +164,8 @@ 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.

+ *

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/BlockContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/BlockContactRequest.java new file mode 100644 index 0000000..3d3c0ed --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/BlockContactRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 contactId; + + private final Map additionalProperties; + + private BlockContactRequest(String contactId, Map additionalProperties) { + this.contactId = contactId; + this.additionalProperties = additionalProperties; + } + + /** + * @return contact_id + */ + @JsonProperty("contact_id") + public String getContactId() { + return contactId; + } + + @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 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 { + /** + *

contact_id

+ */ + _FinalStage contactId(@NotNull String contactId); + + Builder from(BlockContactRequest other); + } + + public interface _FinalStage { + BlockContactRequest 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(BlockContactRequest other) { + contactId(other.getContactId()); + return this; + } + + /** + *

contact_id

+ *

contact_id

+ * @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 BlockContactRequest build() { + return new BlockContactRequest(contactId, additionalProperties); + } + } +} 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 82c4d68..354b9cb 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 @@ -29,7 +29,7 @@ private DeleteContactRequest(String contactId, Map additionalPro } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + *

contact_id

*/ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,8 @@ public Builder from(DeleteContactRequest other) { } /** - * id

id

+ *

contact_id

+ *

contact_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 369fbcd..145d916 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 @@ -80,7 +80,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ SubscriptionIdStage contactId(@NotNull String contactId); @@ -89,7 +89,7 @@ public interface ContactIdStage { public interface SubscriptionIdStage { /** - * The unique identifier for the subscription type which is given by Intercom + *

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

*/ _FinalStage subscriptionId(@NotNull String subscriptionId); } @@ -117,7 +117,8 @@ 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

+ *

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 @@ -128,7 +129,8 @@ 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

+ *

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 28fdb9e..762c74f 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 @@ -29,7 +29,7 @@ private FindContactRequest(String contactId, Map additionalPrope } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + *

contact_id

*/ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,8 @@ public Builder from(FindContactRequest other) { } /** - * id

id

+ *

contact_id

+ *

contact_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 9763506..259bfd2 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 @@ -95,7 +95,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ _FinalStage contactId(@NotNull String contactId); @@ -142,7 +142,8 @@ 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

+ *

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/ListAttachedSubscriptionsRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListAttachedSubscriptionsRequest.java index ee21bea..db91f2d 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 @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,8 @@ 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

+ *

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/ListSegmentsAttachedToContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ListSegmentsAttachedToContactRequest.java index 961dbc5..9cb06af 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 @@ -68,7 +68,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ _FinalStage contactId(@NotNull String contactId); @@ -95,7 +95,8 @@ 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

+ *

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 826d2d1..e3f35bd 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 @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

The unique identifier for the contact which is given by Intercom

*/ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,8 @@ 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

+ *

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 600f2ea..987743b 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 @@ -9,23 +9,25 @@ 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 org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = MergeContactsRequest.Builder.class) public final class MergeContactsRequest { - private final String leadId; + private final Optional leadId; - private final String contactId; + private final Optional contactId; private final Map additionalProperties; - private MergeContactsRequest(String leadId, String contactId, Map additionalProperties) { + private MergeContactsRequest( + Optional leadId, Optional contactId, Map additionalProperties) { this.leadId = leadId; this.contactId = contactId; this.additionalProperties = additionalProperties; @@ -35,7 +37,7 @@ private MergeContactsRequest(String leadId, String contactId, Map getLeadId() { return leadId; } @@ -43,7 +45,7 @@ public String getLeadId() { * @return The unique identifier for the contact to merge into. Must be a user. */ @JsonProperty("into") - public String getContactId() { + public Optional getContactId() { return contactId; } @@ -72,42 +74,21 @@ public String toString() { return ObjectMappers.stringify(this); } - public static LeadIdStage builder() { + public static Builder builder() { return new 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); - } - - public interface _FinalStage { - MergeContactsRequest build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements LeadIdStage, ContactIdStage, _FinalStage { - private String leadId; + public static final class Builder { + private Optional leadId = Optional.empty(); - private String contactId; + private Optional contactId = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(MergeContactsRequest other) { leadId(other.getLeadId()); contactId(other.getContactId()); @@ -115,28 +96,33 @@ 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.

- * @return Reference to {@code this} so that method calls can be chained together. + *

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

*/ - @java.lang.Override - @JsonSetter("from") - public ContactIdStage leadId(@NotNull String leadId) { - this.leadId = Objects.requireNonNull(leadId, "leadId must not be null"); + @JsonSetter(value = "from", nulls = Nulls.SKIP) + public Builder leadId(Optional leadId) { + this.leadId = leadId; + return this; + } + + public Builder leadId(String leadId) { + this.leadId = Optional.ofNullable(leadId); return this; } /** - * 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. + *

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

*/ - @java.lang.Override - @JsonSetter("into") - public _FinalStage contactId(@NotNull String contactId) { - this.contactId = Objects.requireNonNull(contactId, "contactId must not be null"); + @JsonSetter(value = "into", nulls = Nulls.SKIP) + public Builder contactId(Optional contactId) { + this.contactId = contactId; + return this; + } + + public Builder contactId(String contactId) { + this.contactId = Optional.ofNullable(contactId); return this; } - @java.lang.Override public MergeContactsRequest build() { return new MergeContactsRequest(leadId, contactId, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/contacts/requests/ShowContactByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/ShowContactByExternalIdRequest.java new file mode 100644 index 0000000..1be7dd7 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/requests/ShowContactByExternalIdRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/contacts/requests/UnarchiveContactRequest.java b/src/main/java/com/intercom/api/resources/contacts/requests/UnarchiveContactRequest.java index b232367..2148e8e 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 @@ -29,7 +29,7 @@ private UnarchiveContactRequest(String contactId, Map additional } /** - * @return id + * @return contact_id */ @JsonProperty("contact_id") public String getContactId() { @@ -67,7 +67,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + *

contact_id

*/ _FinalStage contactId(@NotNull String contactId); @@ -94,7 +94,8 @@ public Builder from(UnarchiveContactRequest other) { } /** - * id

id

+ *

contact_id

+ *

contact_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 a0f7ea4..6466672 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 @@ -226,7 +226,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * id + *

id

*/ _FinalStage contactId(@NotNull String contactId); @@ -363,7 +363,8 @@ public Builder from(UpdateContactRequest other) { } /** - * id

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/types/Contact.java b/src/main/java/com/intercom/api/resources/contacts/types/Contact.java index 3dba6ae..28332c8 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 @@ -21,20 +21,19 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Contact.Builder.class) -public final class Contact { +public final class Contact implements IContact { private final Optional type; - private final String id; + private final Optional id; private final Optional externalId; - private final String workspaceId; + private final Optional workspaceId; - private final String role; + private final Optional role; private final Optional email; @@ -42,21 +41,19 @@ public final class Contact { private final Optional phone; - private final Optional formattedPhone; - private final Optional name; private final Optional ownerId; - private final boolean hasHardBounced; + private final Optional hasHardBounced; - private final boolean markedEmailAsSpam; + private final Optional markedEmailAsSpam; - private final boolean unsubscribedFromEmails; + private final Optional unsubscribedFromEmails; - private final int createdAt; + private final Optional createdAt; - private final int updatedAt; + private final Optional updatedAt; private final Optional signedUpAt; @@ -114,29 +111,28 @@ public final class Contact { private final Optional companies; - private final ContactLocation location; + private final Optional location; - private final ContactSocialProfiles socialProfiles; + private final Optional socialProfiles; private final Map additionalProperties; private Contact( Optional type, - String id, + Optional id, Optional externalId, - String workspaceId, - String role, + Optional workspaceId, + Optional role, Optional email, Optional emailDomain, Optional phone, - Optional formattedPhone, Optional name, Optional ownerId, - boolean hasHardBounced, - boolean markedEmailAsSpam, - boolean unsubscribedFromEmails, - int createdAt, - int updatedAt, + Optional hasHardBounced, + Optional markedEmailAsSpam, + Optional unsubscribedFromEmails, + Optional createdAt, + Optional updatedAt, Optional signedUpAt, Optional lastSeenAt, Optional lastRepliedAt, @@ -165,8 +161,8 @@ private Contact( Optional tags, Optional notes, Optional companies, - ContactLocation location, - ContactSocialProfiles socialProfiles, + Optional location, + Optional socialProfiles, Map additionalProperties) { this.type = type; this.id = id; @@ -176,7 +172,6 @@ private Contact( this.email = email; this.emailDomain = emailDomain; this.phone = phone; - this.formattedPhone = formattedPhone; this.name = name; this.ownerId = ownerId; this.hasHardBounced = hasHardBounced; @@ -229,7 +224,7 @@ public Optional getType() { * @return The unique identifier for the contact which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -245,7 +240,7 @@ public Optional getExternalId() { * @return The id of the workspace which the contact belongs to. */ @JsonProperty("workspace_id") - public String getWorkspaceId() { + public Optional getWorkspaceId() { return workspaceId; } @@ -253,7 +248,7 @@ public String getWorkspaceId() { * @return The role of the contact. */ @JsonProperty("role") - public String getRole() { + public Optional getRole() { return role; } @@ -281,14 +276,6 @@ 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. */ @@ -309,7 +296,7 @@ public Optional getOwnerId() { * @return Whether the contact has had an email sent to them hard bounce. */ @JsonProperty("has_hard_bounced") - public boolean getHasHardBounced() { + public Optional getHasHardBounced() { return hasHardBounced; } @@ -317,7 +304,7 @@ public boolean getHasHardBounced() { * @return Whether the contact has marked an email sent to them as spam. */ @JsonProperty("marked_email_as_spam") - public boolean getMarkedEmailAsSpam() { + public Optional getMarkedEmailAsSpam() { return markedEmailAsSpam; } @@ -325,7 +312,7 @@ public boolean getMarkedEmailAsSpam() { * @return Whether the contact is unsubscribed from emails. */ @JsonProperty("unsubscribed_from_emails") - public boolean getUnsubscribedFromEmails() { + public Optional getUnsubscribedFromEmails() { return unsubscribedFromEmails; } @@ -333,7 +320,7 @@ public boolean getUnsubscribedFromEmails() { * @return (UNIX timestamp) The time when the contact was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -341,7 +328,7 @@ public int getCreatedAt() { * @return (UNIX timestamp) The time when the contact was last updated. */ @JsonProperty("updated_at") - public int getUpdatedAt() { + public Optional getUpdatedAt() { return updatedAt; } @@ -561,12 +548,12 @@ public Optional getCompanies() { } @JsonProperty("location") - public ContactLocation getLocation() { + public Optional getLocation() { return location; } @JsonProperty("social_profiles") - public ContactSocialProfiles getSocialProfiles() { + public Optional getSocialProfiles() { return socialProfiles; } @@ -590,14 +577,13 @@ private boolean equalTo(Contact other) { && 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 == other.hasHardBounced - && markedEmailAsSpam == other.markedEmailAsSpam - && unsubscribedFromEmails == other.unsubscribedFromEmails - && createdAt == other.createdAt - && updatedAt == other.updatedAt + && 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) @@ -641,7 +627,6 @@ public int hashCode() { this.email, this.emailDomain, this.phone, - this.formattedPhone, this.name, this.ownerId, this.hasHardBounced, @@ -686,1286 +671,771 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new Builder(); } - public interface IdStage { - /** - * The unique identifier for the contact which is given by Intercom. - */ - WorkspaceIdStage id(@NotNull String id); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - Builder from(Contact other); - } + private Optional id = Optional.empty(); - public interface WorkspaceIdStage { - /** - * The id of the workspace which the contact belongs to. - */ - RoleStage workspaceId(@NotNull String workspaceId); - } + private Optional externalId = Optional.empty(); - public interface RoleStage { - /** - * The role of the contact. - */ - HasHardBouncedStage role(@NotNull String role); - } + private Optional workspaceId = Optional.empty(); - public interface HasHardBouncedStage { - /** - * Whether the contact has had an email sent to them hard bounce. - */ - MarkedEmailAsSpamStage hasHardBounced(boolean hasHardBounced); - } + private Optional role = Optional.empty(); - public interface MarkedEmailAsSpamStage { - /** - * Whether the contact has marked an email sent to them as spam. - */ - UnsubscribedFromEmailsStage markedEmailAsSpam(boolean markedEmailAsSpam); - } + private Optional email = Optional.empty(); - public interface UnsubscribedFromEmailsStage { - /** - * Whether the contact is unsubscribed from emails. - */ - CreatedAtStage unsubscribedFromEmails(boolean unsubscribedFromEmails); - } + private Optional emailDomain = Optional.empty(); - public interface CreatedAtStage { - /** - * (UNIX timestamp) The time when the contact was created. - */ - UpdatedAtStage createdAt(int createdAt); - } + private Optional phone = Optional.empty(); - public interface UpdatedAtStage { - /** - * (UNIX timestamp) The time when the contact was last updated. - */ - LocationStage updatedAt(int updatedAt); - } + private Optional name = Optional.empty(); - public interface LocationStage { - SocialProfilesStage location(@NotNull ContactLocation location); - } + private Optional ownerId = Optional.empty(); - public interface SocialProfilesStage { - _FinalStage socialProfiles(@NotNull ContactSocialProfiles socialProfiles); - } + private Optional hasHardBounced = Optional.empty(); - public interface _FinalStage { - Contact build(); + private Optional markedEmailAsSpam = Optional.empty(); - /** - *

The type of object.

- */ - _FinalStage type(Optional type); + private Optional unsubscribedFromEmails = Optional.empty(); - _FinalStage type(String type); + private Optional createdAt = Optional.empty(); - /** - *

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

- */ - _FinalStage externalId(Optional externalId); + private Optional updatedAt = Optional.empty(); - _FinalStage externalId(String externalId); + private Optional signedUpAt = Optional.empty(); - /** - *

The contact's email.

- */ - _FinalStage email(Optional email); + private Optional lastSeenAt = Optional.empty(); - _FinalStage email(String email); + private Optional lastRepliedAt = Optional.empty(); - /** - *

The contact's email domain.

- */ - _FinalStage emailDomain(Optional emailDomain); + private Optional lastContactedAt = Optional.empty(); - _FinalStage emailDomain(String emailDomain); + private Optional lastEmailOpenedAt = Optional.empty(); - /** - *

The contacts phone.

- */ - _FinalStage phone(Optional phone); + private Optional lastEmailClickedAt = Optional.empty(); - _FinalStage phone(String phone); + private Optional languageOverride = Optional.empty(); - /** - *

The contacts phone number normalized to the E164 format

- */ - _FinalStage formattedPhone(Optional formattedPhone); + private Optional browser = Optional.empty(); - _FinalStage formattedPhone(String formattedPhone); + private Optional browserVersion = Optional.empty(); - /** - *

The contacts name.

- */ - _FinalStage name(Optional name); + private Optional browserLanguage = Optional.empty(); - _FinalStage name(String name); + private Optional os = Optional.empty(); - /** - *

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

- */ - _FinalStage ownerId(Optional ownerId); + private Optional androidAppName = Optional.empty(); - _FinalStage ownerId(Integer ownerId); + private Optional androidAppVersion = Optional.empty(); - /** - *

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

- */ - _FinalStage signedUpAt(Optional signedUpAt); + private Optional androidDevice = Optional.empty(); - _FinalStage signedUpAt(Integer signedUpAt); + private Optional androidOsVersion = Optional.empty(); - /** - *

(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); + private Optional androidSdkVersion = Optional.empty(); - _FinalStage lastSeenAt(Integer lastSeenAt); + private Optional androidLastSeenAt = Optional.empty(); - /** - *

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

- */ - _FinalStage lastRepliedAt(Optional lastRepliedAt); + private Optional iosAppName = Optional.empty(); - _FinalStage lastRepliedAt(Integer lastRepliedAt); + private Optional iosAppVersion = Optional.empty(); - /** - *

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

- */ - _FinalStage lastContactedAt(Optional lastContactedAt); + private Optional iosDevice = Optional.empty(); - _FinalStage lastContactedAt(Integer lastContactedAt); + private Optional iosOsVersion = Optional.empty(); - /** - *

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

- */ - _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt); + private Optional iosSdkVersion = Optional.empty(); - _FinalStage lastEmailOpenedAt(Integer lastEmailOpenedAt); + private Optional iosLastSeenAt = Optional.empty(); - /** - *

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

- */ - _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt); + private Optional> customAttributes = Optional.empty(); - _FinalStage lastEmailClickedAt(Integer lastEmailClickedAt); + private Optional avatar = Optional.empty(); - /** - *

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

- */ - _FinalStage languageOverride(Optional languageOverride); + private Optional tags = Optional.empty(); - _FinalStage languageOverride(String languageOverride); + private Optional notes = Optional.empty(); - /** - *

The name of the browser which the contact is using.

- */ - _FinalStage browser(Optional browser); + private Optional companies = Optional.empty(); - _FinalStage browser(String browser); + private Optional location = Optional.empty(); - /** - *

The version of the browser which the contact is using.

- */ - _FinalStage browserVersion(Optional browserVersion); + private Optional socialProfiles = Optional.empty(); - _FinalStage browserVersion(String browserVersion); + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); - /** - *

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

- */ - _FinalStage browserLanguage(Optional browserLanguage); + private Builder() {} - _FinalStage browserLanguage(String browserLanguage); + 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()); + 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 operating system which the contact is using.

+ *

The type of object.

*/ - _FinalStage os(Optional os); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } - _FinalStage os(String os); + public Builder type(String type) { + this.type = Optional.ofNullable(type); + return this; + } /** - *

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

+ *

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

*/ - _FinalStage androidAppName(Optional androidAppName); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } - _FinalStage androidAppName(String androidAppName); + public Builder id(String id) { + this.id = Optional.ofNullable(id); + return this; + } /** - *

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

+ *

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

*/ - _FinalStage androidAppVersion(Optional androidAppVersion); + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; + return this; + } - _FinalStage androidAppVersion(String androidAppVersion); + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); + return this; + } /** - *

The Android device which the contact is using.

+ *

The id of the workspace which the contact belongs to.

*/ - _FinalStage androidDevice(Optional androidDevice); + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; + return this; + } - _FinalStage androidDevice(String androidDevice); + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); + return this; + } /** - *

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

+ *

The role of the contact.

*/ - _FinalStage androidOsVersion(Optional androidOsVersion); + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } - _FinalStage androidOsVersion(String androidOsVersion); + public Builder role(String role) { + this.role = Optional.ofNullable(role); + return this; + } /** - *

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

+ *

The contact's email.

*/ - _FinalStage androidSdkVersion(Optional androidSdkVersion); + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } - _FinalStage androidSdkVersion(String androidSdkVersion); + public Builder email(String email) { + this.email = Optional.ofNullable(email); + return this; + } /** - *

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

+ *

The contact's email domain.

*/ - _FinalStage androidLastSeenAt(Optional androidLastSeenAt); + @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) + public Builder emailDomain(Optional emailDomain) { + this.emailDomain = emailDomain; + return this; + } - _FinalStage androidLastSeenAt(Integer androidLastSeenAt); + public Builder emailDomain(String emailDomain) { + this.emailDomain = Optional.ofNullable(emailDomain); + return this; + } /** - *

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

+ *

The contacts phone.

*/ - _FinalStage iosAppName(Optional iosAppName); + @JsonSetter(value = "phone", nulls = Nulls.SKIP) + public Builder phone(Optional phone) { + this.phone = phone; + return this; + } - _FinalStage iosAppName(String iosAppName); + public Builder phone(String phone) { + this.phone = Optional.ofNullable(phone); + return this; + } /** - *

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

+ *

The contacts name.

*/ - _FinalStage iosAppVersion(Optional iosAppVersion); + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } - _FinalStage iosAppVersion(String iosAppVersion); + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } /** - *

The iOS device which the contact is using.

+ *

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

*/ - _FinalStage iosDevice(Optional iosDevice); + @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } - _FinalStage iosDevice(String iosDevice); + public Builder ownerId(Integer ownerId) { + this.ownerId = Optional.ofNullable(ownerId); + return this; + } /** - *

The version of iOS which the contact is using.

+ *

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

*/ - _FinalStage iosOsVersion(Optional iosOsVersion); + @JsonSetter(value = "has_hard_bounced", nulls = Nulls.SKIP) + public Builder hasHardBounced(Optional hasHardBounced) { + this.hasHardBounced = hasHardBounced; + return this; + } - _FinalStage iosOsVersion(String iosOsVersion); + public Builder hasHardBounced(Boolean hasHardBounced) { + this.hasHardBounced = Optional.ofNullable(hasHardBounced); + return this; + } /** - *

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

+ *

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

*/ - _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); - - _FinalStage tags(Optional tags); - - _FinalStage tags(ContactTags tags); - - _FinalStage notes(Optional notes); - - _FinalStage notes(ContactNotes notes); - - _FinalStage companies(Optional companies); - - _FinalStage companies(ContactCompanies companies); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - WorkspaceIdStage, - RoleStage, - HasHardBouncedStage, - MarkedEmailAsSpamStage, - UnsubscribedFromEmailsStage, - CreatedAtStage, - UpdatedAtStage, - LocationStage, - SocialProfilesStage, - _FinalStage { - private String id; - - private String workspaceId; - - private String role; - - private boolean hasHardBounced; - - private boolean markedEmailAsSpam; - - private boolean unsubscribedFromEmails; - - private int createdAt; - - private int updatedAt; - - private ContactLocation location; - - private ContactSocialProfiles socialProfiles; - - private Optional companies = Optional.empty(); - - private Optional notes = Optional.empty(); - - private Optional tags = Optional.empty(); - - private Optional avatar = Optional.empty(); - - private Optional> customAttributes = Optional.empty(); - - private Optional iosLastSeenAt = Optional.empty(); - - private Optional iosSdkVersion = Optional.empty(); - - private Optional iosOsVersion = Optional.empty(); - - private Optional iosDevice = Optional.empty(); - - private Optional iosAppVersion = Optional.empty(); - - private Optional iosAppName = Optional.empty(); - - private Optional androidLastSeenAt = Optional.empty(); - - private Optional androidSdkVersion = Optional.empty(); - - private Optional androidOsVersion = Optional.empty(); - - private Optional androidDevice = Optional.empty(); - - private Optional androidAppVersion = Optional.empty(); - - private Optional androidAppName = Optional.empty(); - - private Optional os = Optional.empty(); - - private Optional browserLanguage = Optional.empty(); - - private Optional browserVersion = Optional.empty(); - - private Optional browser = Optional.empty(); - - private Optional languageOverride = Optional.empty(); - - private Optional lastEmailClickedAt = Optional.empty(); - - private Optional lastEmailOpenedAt = Optional.empty(); - - private Optional lastContactedAt = Optional.empty(); - - private Optional lastRepliedAt = Optional.empty(); - - private Optional lastSeenAt = Optional.empty(); - - private Optional signedUpAt = Optional.empty(); - - private Optional ownerId = Optional.empty(); - - private Optional name = Optional.empty(); - - private Optional formattedPhone = Optional.empty(); - - private Optional phone = Optional.empty(); - - private Optional emailDomain = Optional.empty(); - - private Optional email = Optional.empty(); - - private Optional externalId = Optional.empty(); - - private Optional type = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - 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 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 WorkspaceIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); - return this; - } - - /** - * 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 - @JsonSetter("workspace_id") - public RoleStage workspaceId(@NotNull String workspaceId) { - this.workspaceId = Objects.requireNonNull(workspaceId, "workspaceId must not be null"); - return this; - } - - /** - * 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 - @JsonSetter("role") - public HasHardBouncedStage role(@NotNull String role) { - this.role = Objects.requireNonNull(role, "role must not be null"); - return this; - } - - /** - * 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 - @JsonSetter("has_hard_bounced") - public MarkedEmailAsSpamStage hasHardBounced(boolean hasHardBounced) { - this.hasHardBounced = hasHardBounced; - return this; - } - - /** - * 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 - @JsonSetter("marked_email_as_spam") - public UnsubscribedFromEmailsStage markedEmailAsSpam(boolean markedEmailAsSpam) { + @JsonSetter(value = "marked_email_as_spam", nulls = Nulls.SKIP) + public Builder markedEmailAsSpam(Optional markedEmailAsSpam) { this.markedEmailAsSpam = markedEmailAsSpam; return this; } - /** - * 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 - @JsonSetter("unsubscribed_from_emails") - public CreatedAtStage unsubscribedFromEmails(boolean unsubscribedFromEmails) { - this.unsubscribedFromEmails = unsubscribedFromEmails; - return this; - } - - /** - * (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 - @JsonSetter("created_at") - public UpdatedAtStage createdAt(int createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - * (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 - @JsonSetter("updated_at") - public LocationStage updatedAt(int updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - @java.lang.Override - @JsonSetter("location") - public SocialProfilesStage location(@NotNull ContactLocation location) { - this.location = Objects.requireNonNull(location, "location must not be null"); - return this; - } - - @java.lang.Override - @JsonSetter("social_profiles") - public _FinalStage socialProfiles(@NotNull ContactSocialProfiles socialProfiles) { - this.socialProfiles = Objects.requireNonNull(socialProfiles, "socialProfiles must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage companies(ContactCompanies companies) { - this.companies = Optional.ofNullable(companies); - return this; - } - - @java.lang.Override - @JsonSetter(value = "companies", nulls = Nulls.SKIP) - public _FinalStage companies(Optional companies) { - this.companies = companies; - return this; - } - - @java.lang.Override - public _FinalStage notes(ContactNotes notes) { - this.notes = Optional.ofNullable(notes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "notes", nulls = Nulls.SKIP) - public _FinalStage notes(Optional notes) { - this.notes = notes; - return this; - } - - @java.lang.Override - public _FinalStage tags(ContactTags tags) { - this.tags = Optional.ofNullable(tags); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public _FinalStage tags(Optional tags) { - this.tags = tags; + public Builder markedEmailAsSpam(Boolean markedEmailAsSpam) { + this.markedEmailAsSpam = Optional.ofNullable(markedEmailAsSpam); return this; } /** - *

An image URL containing the avatar of a contact.

- * @return Reference to {@code this} so that method calls can be chained together. + *

Whether the contact is unsubscribed from emails.

*/ - @java.lang.Override - public _FinalStage avatar(String avatar) { - this.avatar = Optional.ofNullable(avatar); + @JsonSetter(value = "unsubscribed_from_emails", nulls = Nulls.SKIP) + public Builder unsubscribedFromEmails(Optional unsubscribedFromEmails) { + this.unsubscribedFromEmails = unsubscribedFromEmails; 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; + public Builder unsubscribedFromEmails(Boolean unsubscribedFromEmails) { + this.unsubscribedFromEmails = Optional.ofNullable(unsubscribedFromEmails); return this; } /** - *

The custom attributes which are set for the contact.

- * @return Reference to {@code this} so that method calls can be chained together. + *

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

*/ - @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; + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public Builder createdAt(Optional createdAt) { + this.createdAt = createdAt; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosLastSeenAt(Integer iosLastSeenAt) { - this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); + public Builder createdAt(Integer createdAt) { + this.createdAt = Optional.ofNullable(createdAt); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) - public _FinalStage iosLastSeenAt(Optional iosLastSeenAt) { - this.iosLastSeenAt = iosLastSeenAt; + @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) + public Builder updatedAt(Optional updatedAt) { + this.updatedAt = updatedAt; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosSdkVersion(String iosSdkVersion) { - this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) - public _FinalStage iosSdkVersion(Optional iosSdkVersion) { - this.iosSdkVersion = iosSdkVersion; + @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) + public Builder signedUpAt(Optional signedUpAt) { + this.signedUpAt = signedUpAt; return this; } - /** - *

The version of iOS which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosOsVersion(String iosOsVersion) { - this.iosOsVersion = Optional.ofNullable(iosOsVersion); + public Builder signedUpAt(Integer signedUpAt) { + this.signedUpAt = Optional.ofNullable(signedUpAt); return this; } /** - *

The version of iOS which the contact is using.

+ *

(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 = "ios_os_version", nulls = Nulls.SKIP) - public _FinalStage iosOsVersion(Optional iosOsVersion) { - this.iosOsVersion = iosOsVersion; + @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) + public Builder lastSeenAt(Optional lastSeenAt) { + this.lastSeenAt = lastSeenAt; return this; } - /** - *

The iOS device which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosDevice(String iosDevice) { - this.iosDevice = Optional.ofNullable(iosDevice); + public Builder lastSeenAt(Integer lastSeenAt) { + this.lastSeenAt = Optional.ofNullable(lastSeenAt); return this; } /** - *

The iOS device which the contact is using.

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) - public _FinalStage iosDevice(Optional iosDevice) { - this.iosDevice = iosDevice; + @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) + public Builder lastRepliedAt(Optional lastRepliedAt) { + this.lastRepliedAt = lastRepliedAt; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosAppVersion(String iosAppVersion) { - this.iosAppVersion = Optional.ofNullable(iosAppVersion); + public Builder lastRepliedAt(Integer lastRepliedAt) { + this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) - public _FinalStage iosAppVersion(Optional iosAppVersion) { - this.iosAppVersion = iosAppVersion; + @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) + public Builder lastContactedAt(Optional lastContactedAt) { + this.lastContactedAt = lastContactedAt; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iosAppName(String iosAppName) { - this.iosAppName = Optional.ofNullable(iosAppName); + public Builder lastContactedAt(Integer lastContactedAt) { + this.lastContactedAt = Optional.ofNullable(lastContactedAt); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) - public _FinalStage iosAppName(Optional iosAppName) { - this.iosAppName = iosAppName; + @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) + public Builder lastEmailOpenedAt(Optional lastEmailOpenedAt) { + this.lastEmailOpenedAt = lastEmailOpenedAt; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidLastSeenAt(Integer androidLastSeenAt) { - this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); + public Builder lastEmailOpenedAt(Integer lastEmailOpenedAt) { + this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) - public _FinalStage androidLastSeenAt(Optional androidLastSeenAt) { - this.androidLastSeenAt = androidLastSeenAt; + @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) + public Builder lastEmailClickedAt(Optional lastEmailClickedAt) { + this.lastEmailClickedAt = lastEmailClickedAt; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidSdkVersion(String androidSdkVersion) { - this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); + public Builder lastEmailClickedAt(Integer lastEmailClickedAt) { + this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) - public _FinalStage androidSdkVersion(Optional androidSdkVersion) { - this.androidSdkVersion = androidSdkVersion; + @JsonSetter(value = "language_override", nulls = Nulls.SKIP) + public Builder languageOverride(Optional languageOverride) { + this.languageOverride = languageOverride; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidOsVersion(String androidOsVersion) { - this.androidOsVersion = Optional.ofNullable(androidOsVersion); + public Builder languageOverride(String languageOverride) { + this.languageOverride = Optional.ofNullable(languageOverride); return this; } /** - *

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

+ *

The name of the browser which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) - public _FinalStage androidOsVersion(Optional androidOsVersion) { - this.androidOsVersion = androidOsVersion; + @JsonSetter(value = "browser", nulls = Nulls.SKIP) + public Builder browser(Optional browser) { + this.browser = browser; return this; } - /** - *

The Android device which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidDevice(String androidDevice) { - this.androidDevice = Optional.ofNullable(androidDevice); + public Builder browser(String browser) { + this.browser = Optional.ofNullable(browser); return this; } /** - *

The Android device which the contact is using.

+ *

The version of the browser which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "android_device", nulls = Nulls.SKIP) - public _FinalStage androidDevice(Optional androidDevice) { - this.androidDevice = androidDevice; + @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) + public Builder browserVersion(Optional browserVersion) { + this.browserVersion = browserVersion; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidAppVersion(String androidAppVersion) { - this.androidAppVersion = Optional.ofNullable(androidAppVersion); + public Builder browserVersion(String browserVersion) { + this.browserVersion = Optional.ofNullable(browserVersion); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) - public _FinalStage androidAppVersion(Optional androidAppVersion) { - this.androidAppVersion = androidAppVersion; + @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) + public Builder browserLanguage(Optional browserLanguage) { + this.browserLanguage = browserLanguage; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage androidAppName(String androidAppName) { - this.androidAppName = Optional.ofNullable(androidAppName); + public Builder browserLanguage(String browserLanguage) { + this.browserLanguage = Optional.ofNullable(browserLanguage); return this; } /** - *

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

+ *

The operating system which the contact is using.

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

The operating system which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage os(String os) { + public Builder os(String os) { this.os = Optional.ofNullable(os); return this; } /** - *

The operating system which the contact is using.

+ *

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

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

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage browserLanguage(String browserLanguage) { - this.browserLanguage = Optional.ofNullable(browserLanguage); + public Builder androidAppName(String androidAppName) { + this.androidAppName = Optional.ofNullable(androidAppName); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "browser_language", nulls = Nulls.SKIP) - public _FinalStage browserLanguage(Optional browserLanguage) { - this.browserLanguage = browserLanguage; + @JsonSetter(value = "android_app_version", nulls = Nulls.SKIP) + public Builder androidAppVersion(Optional androidAppVersion) { + this.androidAppVersion = androidAppVersion; return this; } - /** - *

The version of the browser which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage browserVersion(String browserVersion) { - this.browserVersion = Optional.ofNullable(browserVersion); + public Builder androidAppVersion(String androidAppVersion) { + this.androidAppVersion = Optional.ofNullable(androidAppVersion); return this; } /** - *

The version of the browser which the contact is using.

+ *

The Android device which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "browser_version", nulls = Nulls.SKIP) - public _FinalStage browserVersion(Optional browserVersion) { - this.browserVersion = browserVersion; + @JsonSetter(value = "android_device", nulls = Nulls.SKIP) + public Builder androidDevice(Optional androidDevice) { + this.androidDevice = androidDevice; return this; } - /** - *

The name of the browser which the contact is using.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage browser(String browser) { - this.browser = Optional.ofNullable(browser); + public Builder androidDevice(String androidDevice) { + this.androidDevice = Optional.ofNullable(androidDevice); return this; } /** - *

The name of the browser which the contact is using.

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "browser", nulls = Nulls.SKIP) - public _FinalStage browser(Optional browser) { - this.browser = browser; + @JsonSetter(value = "android_os_version", nulls = Nulls.SKIP) + public Builder androidOsVersion(Optional androidOsVersion) { + this.androidOsVersion = androidOsVersion; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languageOverride(String languageOverride) { - this.languageOverride = Optional.ofNullable(languageOverride); + public Builder androidOsVersion(String androidOsVersion) { + this.androidOsVersion = Optional.ofNullable(androidOsVersion); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "language_override", nulls = Nulls.SKIP) - public _FinalStage languageOverride(Optional languageOverride) { - this.languageOverride = languageOverride; + @JsonSetter(value = "android_sdk_version", nulls = Nulls.SKIP) + public Builder androidSdkVersion(Optional androidSdkVersion) { + this.androidSdkVersion = androidSdkVersion; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastEmailClickedAt(Integer lastEmailClickedAt) { - this.lastEmailClickedAt = Optional.ofNullable(lastEmailClickedAt); + public Builder androidSdkVersion(String androidSdkVersion) { + this.androidSdkVersion = Optional.ofNullable(androidSdkVersion); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "last_email_clicked_at", nulls = Nulls.SKIP) - public _FinalStage lastEmailClickedAt(Optional lastEmailClickedAt) { - this.lastEmailClickedAt = lastEmailClickedAt; + @JsonSetter(value = "android_last_seen_at", nulls = Nulls.SKIP) + public Builder androidLastSeenAt(Optional androidLastSeenAt) { + this.androidLastSeenAt = androidLastSeenAt; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastEmailOpenedAt(Integer lastEmailOpenedAt) { - this.lastEmailOpenedAt = Optional.ofNullable(lastEmailOpenedAt); + public Builder androidLastSeenAt(Integer androidLastSeenAt) { + this.androidLastSeenAt = Optional.ofNullable(androidLastSeenAt); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "last_email_opened_at", nulls = Nulls.SKIP) - public _FinalStage lastEmailOpenedAt(Optional lastEmailOpenedAt) { - this.lastEmailOpenedAt = lastEmailOpenedAt; + @JsonSetter(value = "ios_app_name", nulls = Nulls.SKIP) + public Builder iosAppName(Optional iosAppName) { + this.iosAppName = iosAppName; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastContactedAt(Integer lastContactedAt) { - this.lastContactedAt = Optional.ofNullable(lastContactedAt); + public Builder iosAppName(String iosAppName) { + this.iosAppName = Optional.ofNullable(iosAppName); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "last_contacted_at", nulls = Nulls.SKIP) - public _FinalStage lastContactedAt(Optional lastContactedAt) { - this.lastContactedAt = lastContactedAt; + @JsonSetter(value = "ios_app_version", nulls = Nulls.SKIP) + public Builder iosAppVersion(Optional iosAppVersion) { + this.iosAppVersion = iosAppVersion; return this; } - /** - *

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

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lastRepliedAt(Integer lastRepliedAt) { - this.lastRepliedAt = Optional.ofNullable(lastRepliedAt); + public Builder iosAppVersion(String iosAppVersion) { + this.iosAppVersion = Optional.ofNullable(iosAppVersion); return this; } /** - *

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

+ *

The iOS device which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "last_replied_at", nulls = Nulls.SKIP) - public _FinalStage lastRepliedAt(Optional lastRepliedAt) { - this.lastRepliedAt = lastRepliedAt; + @JsonSetter(value = "ios_device", nulls = Nulls.SKIP) + public Builder iosDevice(Optional iosDevice) { + this.iosDevice = iosDevice; return this; } - /** - *

(UNIX timestamp) 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); + public Builder iosDevice(String iosDevice) { + this.iosDevice = Optional.ofNullable(iosDevice); return this; } /** - *

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

+ *

The version of iOS which the contact is using.

*/ - @java.lang.Override - @JsonSetter(value = "last_seen_at", nulls = Nulls.SKIP) - public _FinalStage lastSeenAt(Optional lastSeenAt) { - this.lastSeenAt = lastSeenAt; + @JsonSetter(value = "ios_os_version", nulls = Nulls.SKIP) + public Builder iosOsVersion(Optional iosOsVersion) { + this.iosOsVersion = iosOsVersion; return this; } - /** - *

(UNIX timestamp) 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); + public Builder iosOsVersion(String iosOsVersion) { + this.iosOsVersion = Optional.ofNullable(iosOsVersion); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "signed_up_at", nulls = Nulls.SKIP) - public _FinalStage signedUpAt(Optional signedUpAt) { - this.signedUpAt = signedUpAt; + @JsonSetter(value = "ios_sdk_version", nulls = Nulls.SKIP) + public Builder iosSdkVersion(Optional iosSdkVersion) { + this.iosSdkVersion = iosSdkVersion; 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); + public Builder iosSdkVersion(String iosSdkVersion) { + this.iosSdkVersion = Optional.ofNullable(iosSdkVersion); return this; } /** - *

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

+ *

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

*/ - @java.lang.Override - @JsonSetter(value = "owner_id", nulls = Nulls.SKIP) - public _FinalStage ownerId(Optional ownerId) { - this.ownerId = ownerId; + @JsonSetter(value = "ios_last_seen_at", nulls = Nulls.SKIP) + public Builder iosLastSeenAt(Optional iosLastSeenAt) { + this.iosLastSeenAt = iosLastSeenAt; 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); + public Builder iosLastSeenAt(Integer iosLastSeenAt) { + this.iosLastSeenAt = Optional.ofNullable(iosLastSeenAt); return this; } /** - *

The contacts name.

+ *

The custom attributes which are set for the contact.

*/ - @java.lang.Override - @JsonSetter(value = "name", nulls = Nulls.SKIP) - public _FinalStage name(Optional name) { - this.name = name; + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; return this; } - /** - *

The contacts phone number normalized to the E164 format

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage formattedPhone(String formattedPhone) { - this.formattedPhone = Optional.ofNullable(formattedPhone); + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); return this; } /** - *

The contacts phone number normalized to the E164 format

+ *

An image URL containing the avatar of a contact.

*/ - @java.lang.Override - @JsonSetter(value = "formatted_phone", nulls = Nulls.SKIP) - public _FinalStage formattedPhone(Optional formattedPhone) { - this.formattedPhone = formattedPhone; + @JsonSetter(value = "avatar", nulls = Nulls.SKIP) + public Builder avatar(Optional avatar) { + this.avatar = avatar; 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); + public Builder avatar(String avatar) { + this.avatar = Optional.ofNullable(avatar); return this; } - /** - *

The contacts phone.

- */ - @java.lang.Override - @JsonSetter(value = "phone", nulls = Nulls.SKIP) - public _FinalStage phone(Optional phone) { - this.phone = phone; + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; return this; } - /** - *

The contact's email domain.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage emailDomain(String emailDomain) { - this.emailDomain = Optional.ofNullable(emailDomain); + public Builder tags(ContactTags tags) { + this.tags = Optional.ofNullable(tags); return this; } - /** - *

The contact's email domain.

- */ - @java.lang.Override - @JsonSetter(value = "email_domain", nulls = Nulls.SKIP) - public _FinalStage emailDomain(Optional emailDomain) { - this.emailDomain = emailDomain; + @JsonSetter(value = "notes", nulls = Nulls.SKIP) + public Builder notes(Optional notes) { + this.notes = notes; return this; } - /** - *

The contact's 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); + public Builder notes(ContactNotes notes) { + this.notes = Optional.ofNullable(notes); return this; } - /** - *

The contact's email.

- */ - @java.lang.Override - @JsonSetter(value = "email", nulls = Nulls.SKIP) - public _FinalStage email(Optional email) { - this.email = email; + @JsonSetter(value = "companies", nulls = Nulls.SKIP) + public Builder companies(Optional companies) { + this.companies = companies; return this; } - /** - *

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

- * @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); + public Builder companies(ContactCompanies companies) { + this.companies = Optional.ofNullable(companies); 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) { - this.externalId = externalId; + @JsonSetter(value = "location", nulls = Nulls.SKIP) + public Builder location(Optional location) { + this.location = location; return this; } - /** - *

The type of 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); + public Builder location(ContactLocation location) { + this.location = Optional.ofNullable(location); return this; } - /** - *

The type of object.

- */ - @java.lang.Override - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public _FinalStage type(Optional type) { - this.type = type; + @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; } - @java.lang.Override public Contact build() { return new Contact( type, @@ -1976,7 +1446,6 @@ public Contact build() { email, emailDomain, phone, - formattedPhone, name, ownerId, hasHardBounced, diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsCreateResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsCreateResponse.java new file mode 100644 index 0000000..27130d1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsCreateResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.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 = ContactsCreateResponse.Builder.class) +public final class ContactsCreateResponse 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 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 ContactsCreateResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + 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.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 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; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @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 ContactsCreateResponse && equalTo((ContactsCreateResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsCreateResponse 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) + && 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.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 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(ContactsCreateResponse 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()); + 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 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; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @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 = "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 ContactsCreateResponse build() { + return new ContactsCreateResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + 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); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsFindResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsFindResponse.java new file mode 100644 index 0000000..3d95a6d --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsFindResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.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 = ContactsFindResponse.Builder.class) +public final class ContactsFindResponse 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 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 ContactsFindResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + 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.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 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; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @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 ContactsFindResponse && equalTo((ContactsFindResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsFindResponse 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) + && 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.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 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(ContactsFindResponse 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()); + 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 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; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @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 = "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 ContactsFindResponse build() { + return new ContactsFindResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + 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); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsMergeLeadInUserResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsMergeLeadInUserResponse.java new file mode 100644 index 0000000..a6c4783 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsMergeLeadInUserResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.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 = ContactsMergeLeadInUserResponse.Builder.class) +public final class ContactsMergeLeadInUserResponse 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 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 ContactsMergeLeadInUserResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + 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.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 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; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @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 ContactsMergeLeadInUserResponse && equalTo((ContactsMergeLeadInUserResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsMergeLeadInUserResponse 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) + && 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.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 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(ContactsMergeLeadInUserResponse 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()); + 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 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; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @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 = "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 ContactsMergeLeadInUserResponse build() { + return new ContactsMergeLeadInUserResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + 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); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ContactsUpdateResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ContactsUpdateResponse.java new file mode 100644 index 0000000..bb446f4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ContactsUpdateResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.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 = ContactsUpdateResponse.Builder.class) +public final class ContactsUpdateResponse 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 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 ContactsUpdateResponse( + Optional type, + Optional id, + Optional externalId, + Optional workspaceId, + Optional role, + Optional email, + Optional emailDomain, + Optional phone, + 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.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 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; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @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 ContactsUpdateResponse && equalTo((ContactsUpdateResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ContactsUpdateResponse 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) + && 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.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 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(ContactsUpdateResponse 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()); + 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 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; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @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 = "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 ContactsUpdateResponse build() { + return new ContactsUpdateResponse( + type, + id, + externalId, + workspaceId, + role, + email, + emailDomain, + phone, + 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); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/IContact.java b/src/main/java/com/intercom/api/resources/contacts/types/IContact.java new file mode 100644 index 0000000..faa1acb --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/IContact.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.contacts.types; + +import com.intercom.api.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.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 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 getAvatar(); + + Optional getTags(); + + Optional getNotes(); + + Optional getCompanies(); + + Optional getLocation(); + + Optional getSocialProfiles(); +} diff --git a/src/main/java/com/intercom/api/resources/contacts/types/ShowContactByExternalIdResponse.java b/src/main/java/com/intercom/api/resources/contacts/types/ShowContactByExternalIdResponse.java new file mode 100644 index 0000000..c48d03a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/contacts/types/ShowContactByExternalIdResponse.java @@ -0,0 +1,1521 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.ContactCompanies; +import com.intercom.api.types.ContactLocation; +import com.intercom.api.types.ContactNotes; +import com.intercom.api.types.ContactSocialProfiles; +import com.intercom.api.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 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 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.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 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; + } + + /** + * @return An image URL containing the avatar of a contact. + */ + @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) + && 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.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 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()); + 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 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; + } + + /** + *

An image URL containing the avatar of a contact.

+ */ + @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 = "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, + 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); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java index 034671b..acb67a9 100644 --- a/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/AsyncConversationsClient.java @@ -10,6 +10,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -19,8 +20,10 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncConversationsClient { @@ -132,6 +135,10 @@ public CompletableFuture find(FindConversationRequest request, Req *

{% 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 update(UpdateConversationRequest request) { return this.rawClient.update(request).thenApply(response -> response.body()); @@ -142,11 +149,30 @@ public CompletableFuture update(UpdateConversationRequest request) *

{% 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 update(UpdateConversationRequest request, RequestOptions requestOptions) { return this.rawClient.update(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.

@@ -165,7 +191,7 @@ public CompletableFuture update(UpdateConversationRequest request, *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -262,7 +288,7 @@ public CompletableFuture> search(SearchRequest *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -383,33 +409,6 @@ public CompletableFuture manage( return this.rawClient.manage(request, requestOptions).thenApply(response -> response.body()); } - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture runAssignmentRules(AutoAssignConversationRequest request) { - return this.rawClient.runAssignmentRules(request).thenApply(response -> response.body()); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture runAssignmentRules( - AutoAssignConversationRequest request, RequestOptions requestOptions) { - return this.rawClient.runAssignmentRules(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" %} @@ -476,15 +475,42 @@ public CompletableFuture redactConversationPart( /** * You can convert a conversation to a ticket. */ - public CompletableFuture convertToTicket(ConvertConversationToTicketRequest request) { + public CompletableFuture> convertToTicket(ConvertConversationToTicketRequest request) { return this.rawClient.convertToTicket(request).thenApply(response -> response.body()); } /** * You can convert a conversation to a ticket. */ - public CompletableFuture convertToTicket( + public CompletableFuture> convertToTicket( ConvertConversationToTicketRequest request, RequestOptions requestOptions) { return this.rawClient.convertToTicket(request, requestOptions).thenApply(response -> response.body()); } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public CompletableFuture runAssignmentRules(AutoAssignConversationRequest request) { + return this.rawClient.runAssignmentRules(request).thenApply(response -> response.body()); + } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public CompletableFuture runAssignmentRules( + AutoAssignConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.runAssignmentRules(request, requestOptions).thenApply(response -> response.body()); + } } diff --git a/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java index 436f2a3..9c95c4b 100644 --- a/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/AsyncRawConversationsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -22,6 +23,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -31,16 +33,16 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; +import com.intercom.api.types.ConversationList; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedConversationResponse; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.StartingAfterPaging; import java.io.IOException; -import java.util.HashMap; +import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -102,7 +104,7 @@ public CompletableFuture>> .addPathSegments("conversations"); if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().get(), false); } if (request.getStartingAfter().isPresent()) { QueryStringMapper.addQueryParameter( @@ -112,7 +114,6 @@ public CompletableFuture>> .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(); @@ -124,9 +125,10 @@ public CompletableFuture>> @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -135,21 +137,22 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getConversations(); + List result = + parsedResponse.getConversations().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return list(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return list(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -166,11 +169,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -236,12 +237,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Message.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -263,11 +264,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -312,11 +311,17 @@ public CompletableFuture> find( QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); } + if (request.getIncludeTranslations().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_translations", + request.getIncludeTranslations().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(); @@ -328,13 +333,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -356,11 +360,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -380,6 +382,10 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *

    {% 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> update(UpdateConversationRequest request) { return update(request, null); @@ -390,6 +396,10 @@ public CompletableFuture> update(UpdateConver *

    {% 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> update( UpdateConversationRequest request, RequestOptions requestOptions) { @@ -401,17 +411,10 @@ public CompletableFuture> update( QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); } - Map properties = new HashMap<>(); - if (request.getRead().isPresent()) { - properties.put("read", request.getRead()); - } - if (request.getCustomAttributes().isPresent()) { - properties.put("custom_attributes", request.getCustomAttributes()); - } RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -431,13 +434,12 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -459,11 +461,82 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, 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.getConversationId())) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConversationDeleted.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -496,7 +569,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -593,7 +666,7 @@ public CompletableFuture>> *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -697,15 +770,16 @@ public CompletableFuture>> @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) .flatMap(StartingAfterPaging::getStartingAfter); Optional pagination = request.getPagination() - .map(pagination_ -> StartingAfterPaging.builder() + .map((StartingAfterPaging pagination_) -> StartingAfterPaging.builder() .from(pagination_) .startingAfter(startingAfter) .build()); @@ -713,26 +787,25 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getConversations(); + List result = + parsedResponse.getConversations().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return search(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -788,13 +861,12 @@ public CompletableFuture> reply( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -816,11 +888,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -888,107 +958,12 @@ public CompletableFuture> manage( @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; - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture> runAssignmentRules( - AutoAssignConversationRequest request) { - return runAssignmentRules(request, null); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public CompletableFuture> runAssignmentRules( - AutoAssignConversationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) - .addPathSegments("run_assignment_rules") - .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(), Conversation.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -1010,11 +985,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1077,13 +1050,12 @@ public CompletableFuture> attachContactAsAdmi @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -1105,11 +1077,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1173,13 +1143,12 @@ public CompletableFuture> detachContactAsAdmi @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -1206,11 +1175,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1271,13 +1238,12 @@ public CompletableFuture> redactConversationP @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -1294,11 +1260,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -1316,19 +1280,20 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can convert a conversation to a ticket. */ - public CompletableFuture> convertToTicket(ConvertConversationToTicketRequest request) { + public CompletableFuture>> convertToTicket( + ConvertConversationToTicketRequest request) { return convertToTicket(request, null); } /** * You can convert a conversation to a ticket. */ - public CompletableFuture> convertToTicket( + public CompletableFuture>> convertToTicket( ConvertConversationToTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) + .addPathSegment(Integer.toString(request.getConversationId())) .addPathSegments("convert") .build(); RequestBody body; @@ -1349,17 +1314,19 @@ public CompletableFuture> convertToTicket( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 400) { future.completeExceptionally(new BadRequestError( @@ -1369,11 +1336,99 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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; + } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public CompletableFuture> runAssignmentRules( + AutoAssignConversationRequest request) { + return runAssignmentRules(request, null); + } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public CompletableFuture> runAssignmentRules( + AutoAssignConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("run_assignment_rules") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java index df1b33f..8440374 100644 --- a/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/ConversationsClient.java @@ -10,6 +10,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -19,8 +20,10 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; +import java.util.Optional; public class ConversationsClient { protected final ClientOptions clientOptions; @@ -130,6 +133,10 @@ public Conversation find(FindConversationRequest request, RequestOptions request *

    {% 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 update(UpdateConversationRequest request) { return this.rawClient.update(request).body(); @@ -140,11 +147,29 @@ public Conversation update(UpdateConversationRequest request) { *

    {% 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 update(UpdateConversationRequest request, RequestOptions requestOptions) { return this.rawClient.update(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.

    @@ -163,7 +188,7 @@ public Conversation update(UpdateConversationRequest request, RequestOptions req *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -260,7 +285,7 @@ public SyncPagingIterable search(SearchRequest request) { *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -379,32 +404,6 @@ public Conversation manage(ManageConversationPartsRequest request, RequestOption return this.rawClient.manage(request, requestOptions).body(); } - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public Conversation runAssignmentRules(AutoAssignConversationRequest request) { - return this.rawClient.runAssignmentRules(request).body(); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public Conversation runAssignmentRules(AutoAssignConversationRequest request, RequestOptions requestOptions) { - return this.rawClient.runAssignmentRules(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" %} @@ -470,14 +469,40 @@ public Conversation redactConversationPart(RedactConversationRequest request, Re /** * You can convert a conversation to a ticket. */ - public Ticket convertToTicket(ConvertConversationToTicketRequest request) { + public Optional convertToTicket(ConvertConversationToTicketRequest request) { return this.rawClient.convertToTicket(request).body(); } /** * You can convert a conversation to a ticket. */ - public Ticket convertToTicket(ConvertConversationToTicketRequest request, RequestOptions requestOptions) { + public Optional convertToTicket(ConvertConversationToTicketRequest request, RequestOptions requestOptions) { return this.rawClient.convertToTicket(request, requestOptions).body(); } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public Conversation runAssignmentRules(AutoAssignConversationRequest request) { + return this.rawClient.runAssignmentRules(request).body(); + } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public Conversation runAssignmentRules(AutoAssignConversationRequest request, RequestOptions requestOptions) { + return this.rawClient.runAssignmentRules(request, requestOptions).body(); + } } diff --git a/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java b/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java index 5016dba..cc3f0f1 100644 --- a/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java +++ b/src/main/java/com/intercom/api/resources/conversations/RawConversationsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -22,6 +23,7 @@ import com.intercom.api.resources.conversations.requests.AutoAssignConversationRequest; import com.intercom.api.resources.conversations.requests.ConvertConversationToTicketRequest; import com.intercom.api.resources.conversations.requests.CreateConversationRequest; +import com.intercom.api.resources.conversations.requests.DeleteConversationRequest; import com.intercom.api.resources.conversations.requests.DetachContactFromConversationRequest; import com.intercom.api.resources.conversations.requests.FindConversationRequest; import com.intercom.api.resources.conversations.requests.ListConversationsRequest; @@ -31,16 +33,16 @@ import com.intercom.api.resources.conversations.types.Conversation; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.resources.tickets.types.Ticket; +import com.intercom.api.types.ConversationDeleted; +import com.intercom.api.types.ConversationList; import com.intercom.api.types.CursorPages; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedConversationResponse; import com.intercom.api.types.RedactConversationRequest; import com.intercom.api.types.SearchRequest; import com.intercom.api.types.StartingAfterPaging; import java.io.IOException; -import java.util.HashMap; +import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -96,7 +98,7 @@ public IntercomHttpResponse> list( .addPathSegments("conversations"); if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().get(), false); } if (request.getStartingAfter().isPresent()) { QueryStringMapper.addQueryParameter( @@ -106,7 +108,6 @@ public IntercomHttpResponse> list( .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(); @@ -115,9 +116,10 @@ public IntercomHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) @@ -126,14 +128,14 @@ public IntercomHttpResponse> list( .from(request) .startingAfter(startingAfter) .build(); - List result = parsedResponse.getConversations(); + List result = parsedResponse.getConversations().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( - startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions) + startingAfter.isPresent(), result, parsedResponse, () -> list( + nextRequest, requestOptions) .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -146,11 +148,9 @@ public IntercomHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -203,11 +203,11 @@ public IntercomHttpResponse create(CreateConversationRequest request, R } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Message.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -223,11 +223,9 @@ public IntercomHttpResponse create(CreateConversationRequest request, R } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -262,11 +260,17 @@ public IntercomHttpResponse find(FindConversationRequest request, QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); } + if (request.getIncludeTranslations().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_translations", + request.getIncludeTranslations().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(); @@ -275,11 +279,11 @@ public IntercomHttpResponse find(FindConversationRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -295,11 +299,9 @@ public IntercomHttpResponse find(FindConversationRequest request, } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -310,6 +312,10 @@ public IntercomHttpResponse find(FindConversationRequest request, *

    {% 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 update(UpdateConversationRequest request) { return update(request, null); @@ -320,6 +326,10 @@ public IntercomHttpResponse update(UpdateConversationRequest reque *

    {% 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 update(UpdateConversationRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) @@ -330,17 +340,10 @@ public IntercomHttpResponse update(UpdateConversationRequest reque QueryStringMapper.addQueryParameter( httpUrl, "display_as", request.getDisplayAs().get(), false); } - Map properties = new HashMap<>(); - if (request.getRead().isPresent()) { - properties.put("read", request.getRead()); - } - if (request.getCustomAttributes().isPresent()) { - properties.put("custom_attributes", request.getCustomAttributes()); - } RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); } catch (Exception e) { throw new RuntimeException(e); } @@ -357,11 +360,11 @@ public IntercomHttpResponse update(UpdateConversationRequest reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -377,11 +380,63 @@ public IntercomHttpResponse update(UpdateConversationRequest reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, 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.getConversationId())) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConversationDeleted.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -405,7 +460,7 @@ public IntercomHttpResponse update(UpdateConversationRequest reque *
  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -502,7 +557,7 @@ public IntercomHttpResponse> search(SearchReque *

  • There's a limit of max 15 filters for each AND or OR group
  • * *

    Accepted Fields

    - *

    Most keys listed as part of the The conversation model is 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"). + *

    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 | * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -603,15 +658,16 @@ public IntercomHttpResponse> search( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - PaginatedConversationResponse parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedConversationResponse.class); + ConversationList parsedResponse = + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ConversationList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) .flatMap(StartingAfterPaging::getStartingAfter); Optional pagination = request.getPagination() - .map(pagination_ -> StartingAfterPaging.builder() + .map((StartingAfterPaging pagination_) -> StartingAfterPaging.builder() .from(pagination_) .startingAfter(startingAfter) .build()); @@ -619,19 +675,17 @@ public IntercomHttpResponse> search( .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getConversations(); + List result = parsedResponse.getConversations().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( new SyncPagingIterable( - startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + startingAfter.isPresent(), result, parsedResponse, () -> search( + nextRequest, requestOptions) .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -674,11 +728,11 @@ public IntercomHttpResponse reply(ReplyToConversationRequest reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -694,11 +748,9 @@ public IntercomHttpResponse reply(ReplyToConversationRequest reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -754,84 +806,11 @@ public IntercomHttpResponse manage( } 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); - } - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public IntercomHttpResponse runAssignmentRules(AutoAssignConversationRequest request) { - return runAssignmentRules(request, null); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - */ - public IntercomHttpResponse runAssignmentRules( - AutoAssignConversationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) - .addPathSegments("run_assignment_rules") - .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(), Conversation.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -847,11 +826,9 @@ public IntercomHttpResponse runAssignmentRules( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -901,11 +878,11 @@ public IntercomHttpResponse attachContactAsAdmin( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -921,11 +898,9 @@ public IntercomHttpResponse attachContactAsAdmin( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -976,11 +951,11 @@ public IntercomHttpResponse detachContactAsAdmin( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -999,11 +974,9 @@ public IntercomHttpResponse detachContactAsAdmin( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -1051,11 +1024,11 @@ public IntercomHttpResponse redactConversationPart( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Conversation.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -1068,11 +1041,9 @@ public IntercomHttpResponse redactConversationPart( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -1081,19 +1052,19 @@ public IntercomHttpResponse redactConversationPart( /** * You can convert a conversation to a ticket. */ - public IntercomHttpResponse convertToTicket(ConvertConversationToTicketRequest request) { + public IntercomHttpResponse> convertToTicket(ConvertConversationToTicketRequest request) { return convertToTicket(request, null); } /** * You can convert a conversation to a ticket. */ - public IntercomHttpResponse convertToTicket( + public IntercomHttpResponse> convertToTicket( ConvertConversationToTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("conversations") - .addPathSegment(request.getConversationId()) + .addPathSegment(Integer.toString(request.getConversationId())) .addPathSegments("convert") .build(); RequestBody body; @@ -1116,11 +1087,13 @@ public IntercomHttpResponse convertToTicket( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 400) { throw new BadRequestError( @@ -1129,11 +1102,79 @@ public IntercomHttpResponse convertToTicket( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public IntercomHttpResponse runAssignmentRules(AutoAssignConversationRequest request) { + return runAssignmentRules(request, null); + } + + /** + * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} + * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. + * {% /admonition %} + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="warning" name="When using workflows" %} + * It is not possible to use this endpoint with Workflows. + * {% /admonition %} + */ + public IntercomHttpResponse runAssignmentRules( + AutoAssignConversationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("conversations") + .addPathSegment(request.getConversationId()) + .addPathSegments("run_assignment_rules") + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conversation.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 840efc5..c22dcd5 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 @@ -102,7 +102,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * The identifier for the conversation as given by Intercom. + *

    The identifier for the conversation as given by Intercom.

    */ _FinalStage conversationId(@NotNull String conversationId); @@ -146,7 +146,8 @@ 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.

    + *

    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 @@ -273,15 +274,15 @@ public Customer deserialize(JsonParser p, DeserializationContext context) throws Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, IntercomUserId.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, UserId.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, Customer_.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } throw new JsonParseException(p, "Failed to deserialize"); } @@ -347,7 +348,7 @@ public static UserIdStage builder() { public interface UserIdStage { /** - * 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.

    */ _FinalStage userId(@NotNull String userId); @@ -381,7 +382,8 @@ 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.

    + *

    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 @@ -471,7 +473,7 @@ public static EmailStage builder() { public interface EmailStage { /** - * 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.

    */ _FinalStage email(@NotNull String email); @@ -505,7 +507,8 @@ 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.

    + *

    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 @@ -597,7 +600,7 @@ public static IntercomUserIdStage builder() { public interface IntercomUserIdStage { /** - * The identifier for the contact as given by Intercom. + *

    The identifier for the contact as given by Intercom.

    */ _FinalStage intercomUserId(@NotNull String intercomUserId); @@ -631,7 +634,8 @@ 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.

    + *

    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 8225e4c..526265c 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 @@ -67,7 +67,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * The identifier for the conversation as given by Intercom. + *

    The identifier for the conversation as given by Intercom.

    */ _FinalStage conversationId(@NotNull String conversationId); @@ -94,7 +94,8 @@ 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.

    + *

    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 2affc19..6f71957 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 @@ -21,7 +21,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ConvertConversationToTicketRequest.Builder.class) public final class ConvertConversationToTicketRequest { - private final String conversationId; + private final int conversationId; private final String ticketTypeId; @@ -30,7 +30,7 @@ public final class ConvertConversationToTicketRequest { private final Map additionalProperties; private ConvertConversationToTicketRequest( - String conversationId, + int conversationId, String ticketTypeId, Optional> attributes, Map additionalProperties) { @@ -44,7 +44,7 @@ private ConvertConversationToTicketRequest( * @return The id of the conversation to target */ @JsonProperty("conversation_id") - public String getConversationId() { + public int getConversationId() { return conversationId; } @@ -74,7 +74,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(ConvertConversationToTicketRequest other) { - return conversationId.equals(other.conversationId) + return conversationId == other.conversationId && ticketTypeId.equals(other.ticketTypeId) && attributes.equals(other.attributes); } @@ -95,16 +95,16 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * The id of the conversation to target + *

    The id of the conversation to target

    */ - TicketTypeIdStage conversationId(@NotNull String conversationId); + TicketTypeIdStage conversationId(int conversationId); Builder from(ConvertConversationToTicketRequest other); } public interface TicketTypeIdStage { /** - * 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

    */ _FinalStage ticketTypeId(@NotNull String ticketTypeId); } @@ -119,7 +119,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ConversationIdStage, TicketTypeIdStage, _FinalStage { - private String conversationId; + private int conversationId; private String ticketTypeId; @@ -139,18 +139,20 @@ 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

    + *

    The id of the conversation to target

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @JsonSetter("conversation_id") - public TicketTypeIdStage conversationId(@NotNull String conversationId) { - this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + public TicketTypeIdStage conversationId(int conversationId) { + this.conversationId = conversationId; 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

    + *

    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 c1986b0..6dc7a0b 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 @@ -97,7 +97,7 @@ public interface FromStage { public interface BodyStage { /** - * The content of the message. HTML is not supported. + *

    The content of the message. HTML is not supported.

    */ _FinalStage body(@NotNull String body); } @@ -142,7 +142,8 @@ 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.

    + *

    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 @@ -240,7 +241,7 @@ public static TypeStage builder() { public interface TypeStage { /** - * The role associated to the contact - user or lead. + *

    The role associated to the contact - user or lead.

    */ IdStage type(@NotNull Type type); @@ -249,7 +250,7 @@ public interface TypeStage { public interface IdStage { /** - * The identifier for the contact which is given by Intercom. + *

    The identifier for the contact which is given by Intercom.

    */ _FinalStage id(@NotNull String id); } @@ -277,7 +278,8 @@ 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.

    + *

    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 @@ -288,7 +290,8 @@ 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.

    + *

    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/DeleteConversationRequest.java b/src/main/java/com/intercom/api/resources/conversations/requests/DeleteConversationRequest.java new file mode 100644 index 0000000..7699a83 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/conversations/requests/DeleteConversationRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 conversationId; + + private final Map additionalProperties; + + private DeleteConversationRequest(int conversationId, Map additionalProperties) { + this.conversationId = conversationId; + this.additionalProperties = additionalProperties; + } + + /** + * @return id + */ + @JsonProperty("conversation_id") + public int getConversationId() { + return conversationId; + } + + @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 conversationId == other.conversationId; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.conversationId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ConversationIdStage builder() { + return new Builder(); + } + + public interface ConversationIdStage { + /** + *

    id

    + */ + _FinalStage conversationId(int conversationId); + + Builder from(DeleteConversationRequest other); + } + + public interface _FinalStage { + DeleteConversationRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ConversationIdStage, _FinalStage { + private int conversationId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteConversationRequest other) { + conversationId(other.getConversationId()); + return this; + } + + /** + *

    id

    + *

    id

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("conversation_id") + public _FinalStage conversationId(int conversationId) { + this.conversationId = conversationId; + return this; + } + + @java.lang.Override + public DeleteConversationRequest build() { + return new DeleteConversationRequest(conversationId, additionalProperties); + } + } +} 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 ec9b6f3..1773500 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 @@ -93,7 +93,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * The identifier for the conversation as given by Intercom. + *

    The identifier for the conversation as given by Intercom.

    */ ContactIdStage conversationId(@NotNull String conversationId); @@ -102,14 +102,14 @@ public interface ConversationIdStage { public interface ContactIdStage { /** - * The identifier for the contact as given by Intercom. + *

    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. + *

    The id of the admin who is performing the action.

    */ _FinalStage adminId(@NotNull String adminId); } @@ -140,7 +140,8 @@ 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.

    + *

    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 @@ -151,7 +152,8 @@ 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.

    + *

    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 @@ -162,7 +164,8 @@ 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.

    + *

    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 dd75ae6..a54d6e5 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 @@ -25,12 +25,18 @@ public final class FindConversationRequest { private final Optional displayAs; + private final Optional includeTranslations; + private final Map additionalProperties; private FindConversationRequest( - String conversationId, Optional displayAs, Map additionalProperties) { + String conversationId, + Optional displayAs, + Optional includeTranslations, + Map additionalProperties) { this.conversationId = conversationId; this.displayAs = displayAs; + this.includeTranslations = includeTranslations; this.additionalProperties = additionalProperties; } @@ -50,6 +56,14 @@ public Optional getDisplayAs() { return displayAs; } + /** + * @return If set to true, conversation parts will be translated to the detected language of the conversation. + */ + @JsonProperty("include_translations") + public Optional getIncludeTranslations() { + return includeTranslations; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -62,12 +76,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindConversationRequest other) { - return conversationId.equals(other.conversationId) && displayAs.equals(other.displayAs); + return conversationId.equals(other.conversationId) + && displayAs.equals(other.displayAs) + && includeTranslations.equals(other.includeTranslations); } @java.lang.Override public int hashCode() { - return Objects.hash(this.conversationId, this.displayAs); + return Objects.hash(this.conversationId, this.displayAs, this.includeTranslations); } @java.lang.Override @@ -81,7 +97,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * The id of the conversation to target + *

    The id of the conversation to target

    */ _FinalStage conversationId(@NotNull String conversationId); @@ -97,12 +113,21 @@ public interface _FinalStage { _FinalStage displayAs(Optional displayAs); _FinalStage displayAs(String displayAs); + + /** + *

    If set to true, conversation parts will be translated to the detected language of the conversation.

    + */ + _FinalStage includeTranslations(Optional includeTranslations); + + _FinalStage includeTranslations(Boolean includeTranslations); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ConversationIdStage, _FinalStage { private String conversationId; + private Optional includeTranslations = Optional.empty(); + private Optional displayAs = Optional.empty(); @JsonAnySetter @@ -114,11 +139,13 @@ private Builder() {} public Builder from(FindConversationRequest other) { conversationId(other.getConversationId()); displayAs(other.getDisplayAs()); + includeTranslations(other.getIncludeTranslations()); return this; } /** - * The id of the conversation to target

    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 @@ -128,6 +155,26 @@ public _FinalStage conversationId(@NotNull String conversationId) { return this; } + /** + *

    If set to true, conversation parts will be translated to the detected language of the conversation.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage includeTranslations(Boolean includeTranslations) { + this.includeTranslations = Optional.ofNullable(includeTranslations); + return this; + } + + /** + *

    If set to true, conversation parts will be translated to the detected language of the conversation.

    + */ + @java.lang.Override + @JsonSetter(value = "include_translations", nulls = Nulls.SKIP) + public _FinalStage includeTranslations(Optional includeTranslations) { + this.includeTranslations = includeTranslations; + 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. @@ -150,7 +197,7 @@ public _FinalStage displayAs(Optional displayAs) { @java.lang.Override public FindConversationRequest build() { - return new FindConversationRequest(conversationId, displayAs, additionalProperties); + return new FindConversationRequest(conversationId, displayAs, includeTranslations, additionalProperties); } } } 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 702e2e2..dc36d2b 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 @@ -77,7 +77,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * The identifier for the conversation as given by Intercom. + *

    The identifier for the conversation as given by Intercom.

    */ BodyStage conversationId(@NotNull String conversationId); @@ -111,7 +111,8 @@ 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.

    + *

    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 6a71fdf..0720053 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 @@ -77,7 +77,7 @@ 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 + *

    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); @@ -111,7 +111,8 @@ 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

    + *

    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 76ad55d..08db0b5 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 @@ -9,9 +9,17 @@ 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.types.CustomObjectInstanceList; +import com.intercom.api.types.Datetime; +import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -27,7 +35,11 @@ public final class UpdateConversationRequest { private final Optional read; - private final Optional> customAttributes; + private final Optional title; + + private final Optional> customAttributes; + + private final Optional companyId; private final Map additionalProperties; @@ -35,12 +47,16 @@ private UpdateConversationRequest( String conversationId, Optional displayAs, Optional read, - Optional> customAttributes, + Optional title, + Optional> customAttributes, + Optional companyId, Map additionalProperties) { this.conversationId = conversationId; this.displayAs = displayAs; this.read = read; + this.title = title; this.customAttributes = customAttributes; + this.companyId = companyId; this.additionalProperties = additionalProperties; } @@ -68,11 +84,27 @@ 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() { + public Optional> getCustomAttributes() { return customAttributes; } + /** + * @return The ID of the company that the conversation 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; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -88,12 +120,15 @@ private boolean equalTo(UpdateConversationRequest other) { return conversationId.equals(other.conversationId) && displayAs.equals(other.displayAs) && read.equals(other.read) - && customAttributes.equals(other.customAttributes); + && title.equals(other.title) + && customAttributes.equals(other.customAttributes) + && companyId.equals(other.companyId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.conversationId, this.displayAs, this.read, this.customAttributes); + return Objects.hash( + this.conversationId, this.displayAs, this.read, this.title, this.customAttributes, this.companyId); } @java.lang.Override @@ -107,7 +142,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * The id of the conversation to target + *

    The id of the conversation to target

    */ _FinalStage conversationId(@NotNull String conversationId); @@ -131,16 +166,34 @@ public interface _FinalStage { _FinalStage read(Boolean read); - _FinalStage customAttributes(Optional> customAttributes); + /** + *

    The title given to the conversation

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

    The ID of the company that the conversation 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 customAttributes(Map customAttributes); + _FinalStage companyId(String companyId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements ConversationIdStage, _FinalStage { private String conversationId; - private Optional> customAttributes = Optional.empty(); + private Optional companyId = Optional.empty(); + + private Optional> customAttributes = Optional.empty(); + + private Optional title = Optional.empty(); private Optional read = Optional.empty(); @@ -156,12 +209,15 @@ public Builder from(UpdateConversationRequest other) { conversationId(other.getConversationId()); displayAs(other.getDisplayAs()); read(other.getRead()); + title(other.getTitle()); customAttributes(other.getCustomAttributes()); + companyId(other.getCompanyId()); return this; } /** - * The id of the conversation to target

    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 @@ -171,19 +227,59 @@ public _FinalStage conversationId(@NotNull String conversationId) { return this; } + /** + *

    The ID of the company that the conversation 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 conversation 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; + } + @java.lang.Override - public _FinalStage customAttributes(Map customAttributes) { + 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) { + 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. @@ -227,7 +323,111 @@ public _FinalStage displayAs(Optional displayAs) { @java.lang.Override public UpdateConversationRequest build() { return new UpdateConversationRequest( - conversationId, displayAs, read, customAttributes, additionalProperties); + conversationId, displayAs, read, title, customAttributes, companyId, 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 (RuntimeException e) { + } + if (value instanceof Integer) { + return of((Integer) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Datetime.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomObjectInstanceList.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } } } } 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 8b01a01..2ddaf21 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 @@ -12,7 +12,11 @@ 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.aiagent.types.AiAgent; import com.intercom.api.types.ConversationContacts; @@ -22,38 +26,39 @@ import com.intercom.api.types.ConversationSource; import com.intercom.api.types.ConversationStatistics; import com.intercom.api.types.ConversationTeammates; +import com.intercom.api.types.CustomObjectInstanceList; +import com.intercom.api.types.Datetime; import com.intercom.api.types.LinkedObjectList; import com.intercom.api.types.SlaApplied; import com.intercom.api.types.Tags; +import java.io.IOException; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Conversation.Builder.class) public final class Conversation { private final Optional type; - private final String id; + private final Optional id; private final Optional title; - private final int createdAt; + private final Optional createdAt; - private final int updatedAt; + private final Optional updatedAt; private final Optional waitingSince; private final Optional snoozedUntil; - private final boolean open; + private final Optional open; - private final State state; + private final Optional state; - private final boolean read; + private final Optional read; private final Optional priority; @@ -61,17 +66,19 @@ public final class Conversation { private final Optional teamAssigneeId; + private final Optional companyId; + private final Optional tags; private final Optional conversationRating; - private final ConversationSource source; + private final Optional source; - private final ConversationContacts contacts; + private final Optional contacts; - private final ConversationTeammates teammates; + private final Optional teammates; - private final Map customAttributes; + private final Optional> customAttributes; private final Optional firstContactReply; @@ -91,24 +98,25 @@ public final class Conversation { private Conversation( Optional type, - String id, + Optional id, Optional title, - int createdAt, - int updatedAt, + Optional createdAt, + Optional updatedAt, Optional waitingSince, Optional snoozedUntil, - boolean open, - State state, - boolean read, + Optional open, + Optional state, + Optional read, Optional priority, Optional adminAssigneeId, Optional teamAssigneeId, + Optional companyId, Optional tags, Optional conversationRating, - ConversationSource source, - ConversationContacts contacts, - ConversationTeammates teammates, - Map customAttributes, + Optional source, + Optional contacts, + Optional teammates, + Optional> customAttributes, Optional firstContactReply, Optional slaApplied, Optional statistics, @@ -130,6 +138,7 @@ private Conversation( this.priority = priority; this.adminAssigneeId = adminAssigneeId; this.teamAssigneeId = teamAssigneeId; + this.companyId = companyId; this.tags = tags; this.conversationRating = conversationRating; this.source = source; @@ -158,7 +167,7 @@ public Optional getType() { * @return The id representing the conversation. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -174,7 +183,7 @@ public Optional getTitle() { * @return The time the conversation was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -182,7 +191,7 @@ public int getCreatedAt() { * @return The last time the conversation was updated. */ @JsonProperty("updated_at") - public int getUpdatedAt() { + public Optional getUpdatedAt() { return updatedAt; } @@ -206,7 +215,7 @@ public Optional getSnoozedUntil() { * @return Indicates whether a conversation is open (true) or closed (false). */ @JsonProperty("open") - public boolean getOpen() { + public Optional getOpen() { return open; } @@ -214,7 +223,7 @@ public boolean getOpen() { * @return Can be set to "open", "closed" or "snoozed". */ @JsonProperty("state") - public State getState() { + public Optional getState() { return state; } @@ -222,7 +231,7 @@ public State getState() { * @return Indicates whether a conversation has been read. */ @JsonProperty("read") - public boolean getRead() { + public Optional getRead() { return read; } @@ -250,6 +259,14 @@ public Optional getTeamAssigneeId() { return teamAssigneeId; } + /** + * @return The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. + */ + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; + } + @JsonProperty("tags") public Optional getTags() { return tags; @@ -261,22 +278,22 @@ public Optional getConversationRating() { } @JsonProperty("source") - public ConversationSource getSource() { + public Optional getSource() { return source; } @JsonProperty("contacts") - public ConversationContacts getContacts() { + public Optional getContacts() { return contacts; } @JsonProperty("teammates") - public ConversationTeammates getTeammates() { + public Optional getTeammates() { return teammates; } @JsonProperty("custom_attributes") - public Map getCustomAttributes() { + public Optional> getCustomAttributes() { return customAttributes; } @@ -333,16 +350,17 @@ private boolean equalTo(Conversation other) { return type.equals(other.type) && id.equals(other.id) && title.equals(other.title) - && createdAt == other.createdAt - && updatedAt == other.updatedAt + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) && waitingSince.equals(other.waitingSince) && snoozedUntil.equals(other.snoozedUntil) - && open == other.open + && open.equals(other.open) && state.equals(other.state) - && read == other.read + && read.equals(other.read) && priority.equals(other.priority) && adminAssigneeId.equals(other.adminAssigneeId) && teamAssigneeId.equals(other.teamAssigneeId) + && companyId.equals(other.companyId) && tags.equals(other.tags) && conversationRating.equals(other.conversationRating) && source.equals(other.source) @@ -374,6 +392,7 @@ public int hashCode() { this.priority, this.adminAssigneeId, this.teamAssigneeId, + this.companyId, this.tags, this.conversationRating, this.source, @@ -394,234 +413,71 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - } - - public interface SourceStage { - ContactsStage source(@NotNull ConversationSource source); - } - - public interface ContactsStage { - TeammatesStage contacts(@NotNull ConversationContacts contacts); - } - - public interface TeammatesStage { - _FinalStage teammates(@NotNull ConversationTeammates teammates); - } - - 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); - - _FinalStage tags(Optional tags); - - _FinalStage tags(Tags tags); - - _FinalStage conversationRating(Optional conversationRating); - - _FinalStage conversationRating(ConversationRating conversationRating); - - _FinalStage customAttributes(Map customAttributes); - - _FinalStage putAllCustomAttributes(Map customAttributes); - - _FinalStage customAttributes(String key, Object value); - - _FinalStage firstContactReply(Optional firstContactReply); - - _FinalStage firstContactReply(ConversationFirstContactReply firstContactReply); - - _FinalStage slaApplied(Optional slaApplied); - - _FinalStage slaApplied(SlaApplied slaApplied); - - _FinalStage statistics(Optional statistics); - - _FinalStage statistics(ConversationStatistics statistics); - - _FinalStage conversationParts(Optional conversationParts); - - _FinalStage conversationParts(ConversationParts conversationParts); - - _FinalStage linkedObjects(Optional linkedObjects); - - _FinalStage linkedObjects(LinkedObjectList linkedObjects); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - /** - *

    Indicates whether the AI Agent participated in the conversation.

    - */ - _FinalStage aiAgentParticipated(Optional aiAgentParticipated); + private Optional id = Optional.empty(); - _FinalStage aiAgentParticipated(Boolean aiAgentParticipated); + private Optional title = Optional.empty(); - _FinalStage aiAgent(Optional aiAgent); + private Optional createdAt = Optional.empty(); - _FinalStage aiAgent(AiAgent aiAgent); - } + private Optional updatedAt = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - CreatedAtStage, - UpdatedAtStage, - OpenStage, - StateStage, - ReadStage, - SourceStage, - ContactsStage, - TeammatesStage, - _FinalStage { - private String id; + private Optional waitingSince = Optional.empty(); - private int createdAt; + private Optional snoozedUntil = Optional.empty(); - private int updatedAt; + private Optional open = Optional.empty(); - private boolean open; + private Optional state = Optional.empty(); - private State state; + private Optional read = Optional.empty(); - private boolean read; + private Optional priority = Optional.empty(); - private ConversationSource source; + private Optional adminAssigneeId = Optional.empty(); - private ConversationContacts contacts; + private Optional teamAssigneeId = Optional.empty(); - private ConversationTeammates teammates; + private Optional companyId = Optional.empty(); - private Optional aiAgent = Optional.empty(); + private Optional tags = Optional.empty(); - private Optional aiAgentParticipated = Optional.empty(); + private Optional conversationRating = Optional.empty(); - private Optional linkedObjects = Optional.empty(); + private Optional source = Optional.empty(); - private Optional conversationParts = Optional.empty(); + private Optional contacts = Optional.empty(); - private Optional statistics = Optional.empty(); + private Optional teammates = Optional.empty(); - private Optional slaApplied = Optional.empty(); + private Optional> customAttributes = Optional.empty(); private Optional firstContactReply = Optional.empty(); - private Map customAttributes = new LinkedHashMap<>(); - - private Optional conversationRating = Optional.empty(); - - private Optional tags = Optional.empty(); - - private Optional teamAssigneeId = Optional.empty(); - - private Optional adminAssigneeId = Optional.empty(); + private Optional slaApplied = Optional.empty(); - private Optional priority = Optional.empty(); + private Optional statistics = Optional.empty(); - private Optional snoozedUntil = Optional.empty(); + private Optional conversationParts = Optional.empty(); - private Optional waitingSince = Optional.empty(); + private Optional linkedObjects = Optional.empty(); - private Optional title = Optional.empty(); + private Optional aiAgentParticipated = Optional.empty(); - private Optional type = Optional.empty(); + private Optional aiAgent = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Conversation other) { type(other.getType()); id(other.getId()); @@ -636,6 +492,7 @@ public Builder from(Conversation other) { priority(other.getPriority()); adminAssigneeId(other.getAdminAssigneeId()); teamAssigneeId(other.getTeamAssigneeId()); + companyId(other.getCompanyId()); tags(other.getTags()); conversationRating(other.getConversationRating()); source(other.getSource()); @@ -653,377 +510,347 @@ public Builder from(Conversation other) { } /** - * The id representing the conversation.

    The id representing the conversation.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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.

    */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @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 conversation was created.

    The time the conversation was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The title given to the conversation.

    */ - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(int createdAt) { + @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.

    The last time the conversation was updated.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The last time the conversation was updated.

    */ - @java.lang.Override - @JsonSetter("updated_at") - public OpenStage updatedAt(int updatedAt) { + @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; + } + /** - * 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. + *

    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("open") - public StateStage open(boolean open) { - this.open = open; + @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; } /** - * 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. + *

    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("state") - public ReadStage state(@NotNull State state) { - this.state = Objects.requireNonNull(state, "state must not be null"); + @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 has been read.

    Indicates whether a conversation has been read.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

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

    */ - @java.lang.Override - @JsonSetter("read") - public SourceStage read(boolean read) { - this.read = read; + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public Builder open(Optional open) { + this.open = open; return this; } - @java.lang.Override - @JsonSetter("source") - public ContactsStage source(@NotNull ConversationSource source) { - this.source = Objects.requireNonNull(source, "source must not be null"); + public Builder open(Boolean open) { + this.open = Optional.ofNullable(open); return this; } - @java.lang.Override - @JsonSetter("contacts") - public TeammatesStage contacts(@NotNull ConversationContacts contacts) { - this.contacts = Objects.requireNonNull(contacts, "contacts must not be null"); + /** + *

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

    + */ + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; return this; } - @java.lang.Override - @JsonSetter("teammates") - public _FinalStage teammates(@NotNull ConversationTeammates teammates) { - this.teammates = Objects.requireNonNull(teammates, "teammates must not be null"); + public Builder state(State state) { + this.state = Optional.ofNullable(state); return this; } - @java.lang.Override - public _FinalStage aiAgent(AiAgent aiAgent) { - this.aiAgent = Optional.ofNullable(aiAgent); + /** + *

    Indicates whether a conversation has been read.

    + */ + @JsonSetter(value = "read", nulls = Nulls.SKIP) + public Builder read(Optional read) { + this.read = read; return this; } - @java.lang.Override - @JsonSetter(value = "ai_agent", nulls = Nulls.SKIP) - public _FinalStage aiAgent(Optional aiAgent) { - this.aiAgent = aiAgent; + public Builder read(Boolean read) { + this.read = Optional.ofNullable(read); return this; } /** - *

    Indicates whether the AI Agent participated in the conversation.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

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

    */ - @java.lang.Override - public _FinalStage aiAgentParticipated(Boolean aiAgentParticipated) { - this.aiAgentParticipated = Optional.ofNullable(aiAgentParticipated); + @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; } /** - *

    Indicates whether the AI Agent participated in the conversation.

    + *

    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 = "ai_agent_participated", nulls = Nulls.SKIP) - public _FinalStage aiAgentParticipated(Optional aiAgentParticipated) { - this.aiAgentParticipated = aiAgentParticipated; + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; return this; } - @java.lang.Override - public _FinalStage linkedObjects(LinkedObjectList linkedObjects) { - this.linkedObjects = Optional.ofNullable(linkedObjects); + public Builder adminAssigneeId(Integer adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); return this; } - @java.lang.Override - @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) - public _FinalStage linkedObjects(Optional linkedObjects) { - this.linkedObjects = linkedObjects; + /** + *

    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; } - @java.lang.Override - public _FinalStage conversationParts(ConversationParts conversationParts) { - this.conversationParts = Optional.ofNullable(conversationParts); + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); return this; } - @java.lang.Override - @JsonSetter(value = "conversation_parts", nulls = Nulls.SKIP) - public _FinalStage conversationParts(Optional conversationParts) { - this.conversationParts = conversationParts; + /** + *

    The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom.

    + */ + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public Builder companyId(Optional companyId) { + this.companyId = companyId; return this; } - @java.lang.Override - public _FinalStage statistics(ConversationStatistics statistics) { - this.statistics = Optional.ofNullable(statistics); + public Builder companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); return this; } - @java.lang.Override - @JsonSetter(value = "statistics", nulls = Nulls.SKIP) - public _FinalStage statistics(Optional statistics) { - this.statistics = statistics; + @JsonSetter(value = "tags", nulls = Nulls.SKIP) + public Builder tags(Optional tags) { + this.tags = tags; return this; } - @java.lang.Override - public _FinalStage slaApplied(SlaApplied slaApplied) { - this.slaApplied = Optional.ofNullable(slaApplied); + public Builder tags(Tags tags) { + this.tags = Optional.ofNullable(tags); return this; } - @java.lang.Override - @JsonSetter(value = "sla_applied", nulls = Nulls.SKIP) - public _FinalStage slaApplied(Optional slaApplied) { - this.slaApplied = slaApplied; + @JsonSetter(value = "conversation_rating", nulls = Nulls.SKIP) + public Builder conversationRating(Optional conversationRating) { + this.conversationRating = conversationRating; return this; } - @java.lang.Override - public _FinalStage firstContactReply(ConversationFirstContactReply firstContactReply) { - this.firstContactReply = Optional.ofNullable(firstContactReply); + public Builder conversationRating(ConversationRating conversationRating) { + this.conversationRating = Optional.ofNullable(conversationRating); return this; } - @java.lang.Override - @JsonSetter(value = "first_contact_reply", nulls = Nulls.SKIP) - public _FinalStage firstContactReply(Optional firstContactReply) { - this.firstContactReply = firstContactReply; + @JsonSetter(value = "source", nulls = Nulls.SKIP) + public Builder source(Optional source) { + this.source = source; return this; } - @java.lang.Override - public _FinalStage customAttributes(String key, Object value) { - this.customAttributes.put(key, value); + public Builder source(ConversationSource source) { + this.source = Optional.ofNullable(source); return this; } - @java.lang.Override - public _FinalStage putAllCustomAttributes(Map customAttributes) { - this.customAttributes.putAll(customAttributes); + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional contacts) { + this.contacts = contacts; return this; } - @java.lang.Override - @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) - public _FinalStage customAttributes(Map customAttributes) { - this.customAttributes.clear(); - this.customAttributes.putAll(customAttributes); + public Builder contacts(ConversationContacts contacts) { + this.contacts = Optional.ofNullable(contacts); return this; } - @java.lang.Override - public _FinalStage conversationRating(ConversationRating conversationRating) { - this.conversationRating = Optional.ofNullable(conversationRating); + @JsonSetter(value = "teammates", nulls = Nulls.SKIP) + public Builder teammates(Optional teammates) { + this.teammates = teammates; return this; } - @java.lang.Override - @JsonSetter(value = "conversation_rating", nulls = Nulls.SKIP) - public _FinalStage conversationRating(Optional conversationRating) { - this.conversationRating = conversationRating; + public Builder teammates(ConversationTeammates teammates) { + this.teammates = Optional.ofNullable(teammates); return this; } - @java.lang.Override - public _FinalStage tags(Tags tags) { - this.tags = Optional.ofNullable(tags); + @JsonSetter(value = "custom_attributes", nulls = Nulls.SKIP) + public Builder customAttributes(Optional> customAttributes) { + this.customAttributes = customAttributes; return this; } - @java.lang.Override - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public _FinalStage tags(Optional tags) { - this.tags = tags; + public Builder customAttributes(Map customAttributes) { + this.customAttributes = Optional.ofNullable(customAttributes); return this; } - /** - *

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

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage teamAssigneeId(String teamAssigneeId) { - this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + @JsonSetter(value = "first_contact_reply", nulls = Nulls.SKIP) + public Builder firstContactReply(Optional firstContactReply) { + this.firstContactReply = firstContactReply; 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) { - this.teamAssigneeId = teamAssigneeId; + public Builder firstContactReply(ConversationFirstContactReply firstContactReply) { + this.firstContactReply = Optional.ofNullable(firstContactReply); return this; } - /** - *

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

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage adminAssigneeId(Integer adminAssigneeId) { - this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + @JsonSetter(value = "sla_applied", nulls = Nulls.SKIP) + public Builder slaApplied(Optional slaApplied) { + this.slaApplied = slaApplied; 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) { - this.adminAssigneeId = adminAssigneeId; + public Builder slaApplied(SlaApplied slaApplied) { + this.slaApplied = Optional.ofNullable(slaApplied); return this; } - /** - *

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

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage priority(Priority priority) { - this.priority = Optional.ofNullable(priority); + @JsonSetter(value = "statistics", nulls = Nulls.SKIP) + public Builder statistics(Optional statistics) { + this.statistics = statistics; 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) { - this.priority = priority; + public Builder statistics(ConversationStatistics statistics) { + this.statistics = Optional.ofNullable(statistics); 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.

    - * @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); + @JsonSetter(value = "conversation_parts", nulls = Nulls.SKIP) + public Builder conversationParts(Optional conversationParts) { + this.conversationParts = conversationParts; 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) { - this.snoozedUntil = snoozedUntil; + public Builder conversationParts(ConversationParts conversationParts) { + this.conversationParts = Optional.ofNullable(conversationParts); 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.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage waitingSince(Integer waitingSince) { - this.waitingSince = Optional.ofNullable(waitingSince); + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public Builder linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; 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) { - this.waitingSince = waitingSince; + public Builder linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); return this; } /** - *

    The title given to the conversation.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Indicates whether the AI Agent participated in the conversation.

    */ - @java.lang.Override - public _FinalStage title(String title) { - this.title = Optional.ofNullable(title); + @JsonSetter(value = "ai_agent_participated", nulls = Nulls.SKIP) + public Builder aiAgentParticipated(Optional aiAgentParticipated) { + this.aiAgentParticipated = aiAgentParticipated; 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; + public Builder aiAgentParticipated(Boolean aiAgentParticipated) { + this.aiAgentParticipated = Optional.ofNullable(aiAgentParticipated); return this; } - /** - *

    Always conversation.

    - * @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); + @JsonSetter(value = "ai_agent", nulls = Nulls.SKIP) + public Builder aiAgent(Optional aiAgent) { + this.aiAgent = aiAgent; return this; } - /** - *

    Always conversation.

    - */ - @java.lang.Override - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public _FinalStage type(Optional type) { - this.type = type; + public Builder aiAgent(AiAgent aiAgent) { + this.aiAgent = Optional.ofNullable(aiAgent); return this; } - @java.lang.Override public Conversation build() { return new Conversation( type, @@ -1039,6 +866,7 @@ public Conversation build() { priority, adminAssigneeId, teamAssigneeId, + companyId, tags, conversationRating, source, @@ -1215,4 +1043,108 @@ public interface Visitor { 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 (RuntimeException e) { + } + if (value instanceof Integer) { + return of((Integer) value); + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Datetime.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CustomObjectInstanceList.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + } } diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java new file mode 100644 index 0000000..c007d7c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncCustomChannelEventsClient.java @@ -0,0 +1,117 @@ +/** + * 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 com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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/customchannelevents/AsyncRawCustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java new file mode 100644 index 0000000..72ffe7b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/AsyncRawCustomChannelEventsClient.java @@ -0,0 +1,431 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.types.CustomChannelNotificationResponse; +import com.intercom.api.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/customchannelevents/CustomChannelEventsClient.java b/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java new file mode 100644 index 0000000..8728305 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/CustomChannelEventsClient.java @@ -0,0 +1,114 @@ +/** + * 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 com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + public CustomChannelNotificationResponse notifyAttributeCollected( + NotifyAttributeCollectedRequest request, RequestOptions requestOptions) { + return this.rawClient.notifyAttributeCollected(request, 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 new file mode 100644 index 0000000..bb45aa4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/RawCustomChannelEventsClient.java @@ -0,0 +1,342 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.errors.UnprocessableEntityError; +import com.intercom.api.resources.customchannelevents.requests.NotifyAttributeCollectedRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyNewMessageRequest; +import com.intercom.api.resources.customchannelevents.requests.NotifyQuickReplySelectedRequest; +import com.intercom.api.types.CustomChannelBaseEvent; +import com.intercom.api.types.CustomChannelNotificationResponse; +import com.intercom.api.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.

    + *
    + */ + 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomChannelNotificationResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyAttributeCollectedRequest.java b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyAttributeCollectedRequest.java new file mode 100644 index 0000000..2bb5b6e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyAttributeCollectedRequest.java @@ -0,0 +1,204 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.CustomChannelAttribute; +import com.intercom.api.types.CustomChannelContact; +import com.intercom.api.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/customchannelevents/requests/NotifyNewMessageRequest.java b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyNewMessageRequest.java new file mode 100644 index 0000000..33bfa56 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyNewMessageRequest.java @@ -0,0 +1,213 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.CustomChannelContact; +import com.intercom.api.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/customchannelevents/requests/NotifyQuickReplySelectedRequest.java b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyQuickReplySelectedRequest.java new file mode 100644 index 0000000..637e648 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customchannelevents/requests/NotifyQuickReplySelectedRequest.java @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.types.CustomChannelContact; +import com.intercom.api.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/customobjectinstances/AsyncCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncCustomObjectInstancesClient.java new file mode 100644 index 0000000..240bd25 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncCustomObjectInstancesClient.java @@ -0,0 +1,124 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.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/customobjectinstances/AsyncRawCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncRawCustomObjectInstancesClient.java new file mode 100644 index 0000000..67adb89 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/AsyncRawCustomObjectInstancesClient.java @@ -0,0 +1,426 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.types.CustomObjectInstanceDeleted; +import com.intercom.api.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("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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomObjectInstanceDeleted.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getCustomObjectInstanceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getCustomObjectInstanceId()) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, CustomObjectInstanceDeleted.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/customobjectinstances/CustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/CustomObjectInstancesClient.java new file mode 100644 index 0000000..b7f77db --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/CustomObjectInstancesClient.java @@ -0,0 +1,121 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.customobjectinstances; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.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/customobjectinstances/RawCustomObjectInstancesClient.java b/src/main/java/com/intercom/api/resources/customobjectinstances/RawCustomObjectInstancesClient.java new file mode 100644 index 0000000..c384c5c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/RawCustomObjectInstancesClient.java @@ -0,0 +1,335 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.customobjectinstances.requests.CreateOrUpdateCustomObjectInstanceRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.DeleteCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByExternalIdRequest; +import com.intercom.api.resources.customobjectinstances.requests.GetCustomObjectInstancesByIdRequest; +import com.intercom.api.resources.customobjectinstances.types.CustomObjectInstance; +import com.intercom.api.types.CustomObjectInstanceDeleted; +import com.intercom.api.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("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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CustomObjectInstanceDeleted.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getCustomObjectInstanceId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getCustomObjectInstanceId()) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CustomObjectInstanceDeleted.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java new file mode 100644 index 0000000..340018b --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/CreateOrUpdateCustomObjectInstanceRequest.java @@ -0,0 +1,302 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java new file mode 100644 index 0000000..c3a0fe1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByExternalIdRequest.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 customObjectInstanceId; + + private final Map additionalProperties; + + private DeleteCustomObjectInstancesByExternalIdRequest( + String customObjectTypeIdentifier, + String customObjectInstanceId, + Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.customObjectInstanceId = customObjectInstanceId; + 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("custom_object_instance_id") + public String getCustomObjectInstanceId() { + return customObjectInstanceId; + } + + @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) + && customObjectInstanceId.equals(other.customObjectInstanceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.customObjectInstanceId); + } + + @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.

    + */ + CustomObjectInstanceIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(DeleteCustomObjectInstancesByExternalIdRequest other); + } + + public interface CustomObjectInstanceIdStage { + /** + *

    The Intercom defined id of the custom object instance

    + */ + _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId); + } + + public interface _FinalStage { + DeleteCustomObjectInstancesByExternalIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CustomObjectTypeIdentifierStage, CustomObjectInstanceIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String customObjectInstanceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteCustomObjectInstancesByExternalIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + customObjectInstanceId(other.getCustomObjectInstanceId()); + 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 CustomObjectInstanceIdStage 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("custom_object_instance_id") + public _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId) { + this.customObjectInstanceId = + Objects.requireNonNull(customObjectInstanceId, "customObjectInstanceId must not be null"); + return this; + } + + @java.lang.Override + public DeleteCustomObjectInstancesByExternalIdRequest build() { + return new DeleteCustomObjectInstancesByExternalIdRequest( + customObjectTypeIdentifier, customObjectInstanceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java new file mode 100644 index 0000000..ff8d324 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/DeleteCustomObjectInstancesByIdRequest.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java new file mode 100644 index 0000000..d38c58f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByExternalIdRequest.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java new file mode 100644 index 0000000..331f864 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/requests/GetCustomObjectInstancesByIdRequest.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 customObjectInstanceId; + + private final Map additionalProperties; + + private GetCustomObjectInstancesByIdRequest( + String customObjectTypeIdentifier, + String customObjectInstanceId, + Map additionalProperties) { + this.customObjectTypeIdentifier = customObjectTypeIdentifier; + this.customObjectInstanceId = customObjectInstanceId; + 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("custom_object_instance_id") + public String getCustomObjectInstanceId() { + return customObjectInstanceId; + } + + @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) + && customObjectInstanceId.equals(other.customObjectInstanceId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.customObjectTypeIdentifier, this.customObjectInstanceId); + } + + @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.

    + */ + CustomObjectInstanceIdStage customObjectTypeIdentifier(@NotNull String customObjectTypeIdentifier); + + Builder from(GetCustomObjectInstancesByIdRequest other); + } + + public interface CustomObjectInstanceIdStage { + /** + *

    The id or external_id of the custom object instance

    + */ + _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId); + } + + public interface _FinalStage { + GetCustomObjectInstancesByIdRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements CustomObjectTypeIdentifierStage, CustomObjectInstanceIdStage, _FinalStage { + private String customObjectTypeIdentifier; + + private String customObjectInstanceId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetCustomObjectInstancesByIdRequest other) { + customObjectTypeIdentifier(other.getCustomObjectTypeIdentifier()); + customObjectInstanceId(other.getCustomObjectInstanceId()); + 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 CustomObjectInstanceIdStage 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("custom_object_instance_id") + public _FinalStage customObjectInstanceId(@NotNull String customObjectInstanceId) { + this.customObjectInstanceId = + Objects.requireNonNull(customObjectInstanceId, "customObjectInstanceId must not be null"); + return this; + } + + @java.lang.Override + public GetCustomObjectInstancesByIdRequest build() { + return new GetCustomObjectInstancesByIdRequest( + customObjectTypeIdentifier, customObjectInstanceId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/customobjectinstances/types/CustomObjectInstance.java b/src/main/java/com/intercom/api/resources/customobjectinstances/types/CustomObjectInstance.java new file mode 100644 index 0000000..099b9ed --- /dev/null +++ b/src/main/java/com/intercom/api/resources/customobjectinstances/types/CustomObjectInstance.java @@ -0,0 +1,330 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/dataattributes/AsyncDataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java index 175bcf9..ac0f656 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/AsyncDataAttributesClient.java @@ -5,10 +5,10 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java index aa9b3e6..2f3df74 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/AsyncRawDataAttributesClient.java @@ -16,10 +16,10 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; import com.intercom.api.types.Error; import java.io.IOException; @@ -66,20 +66,16 @@ public CompletableFuture> list( .addPathSegments("data_attributes"); if (request.getModel().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "model", request.getModel().get().toString(), false); + httpUrl, "model", request.getModel().get(), false); } if (request.getIncludeArchived().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, - "include_archived", - request.getIncludeArchived().get().toString(), - false); + httpUrl, "include_archived", request.getIncludeArchived().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(); @@ -91,13 +87,13 @@ public CompletableFuture> list( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttributeList.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataAttributeList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -107,11 +103,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -165,13 +159,13 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataAttribute.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -188,11 +182,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -230,12 +222,12 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("data_attributes") - .addPathSegment(request.getDataAttributeId()) + .addPathSegment(Integer.toString(request.getDataAttributeId())) .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -255,13 +247,13 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataAttribute.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -288,11 +280,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java index 22e4648..b672ceb 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/DataAttributesClient.java @@ -5,10 +5,10 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; public class DataAttributesClient { diff --git a/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java b/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java index 3116f21..dc20158 100644 --- a/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java +++ b/src/main/java/com/intercom/api/resources/dataattributes/RawDataAttributesClient.java @@ -16,10 +16,10 @@ import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.dataattributes.requests.CreateDataAttributeRequest; import com.intercom.api.resources.dataattributes.requests.ListDataAttributesRequest; import com.intercom.api.resources.dataattributes.requests.UpdateDataAttributeRequest; import com.intercom.api.resources.dataattributes.types.DataAttribute; +import com.intercom.api.types.CreateDataAttributeRequest; import com.intercom.api.types.DataAttributeList; import com.intercom.api.types.Error; import java.io.IOException; @@ -62,20 +62,16 @@ public IntercomHttpResponse list( .addPathSegments("data_attributes"); if (request.getModel().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "model", request.getModel().get().toString(), false); + httpUrl, "model", request.getModel().get(), false); } if (request.getIncludeArchived().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, - "include_archived", - request.getIncludeArchived().get().toString(), - false); + httpUrl, "include_archived", request.getIncludeArchived().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(); @@ -84,11 +80,11 @@ public IntercomHttpResponse list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttributeList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataAttributeList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -97,11 +93,9 @@ public IntercomHttpResponse list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -143,11 +137,11 @@ public IntercomHttpResponse create( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataAttribute.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -160,11 +154,9 @@ public IntercomHttpResponse create( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -193,12 +185,12 @@ public IntercomHttpResponse update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("data_attributes") - .addPathSegment(request.getDataAttributeId()) + .addPathSegment(Integer.toString(request.getDataAttributeId())) .build(); RequestBody body; try { body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request.getBody()), MediaTypes.APPLICATION_JSON); } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -215,11 +207,11 @@ public IntercomHttpResponse update( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataAttribute.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataAttribute.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -238,11 +230,9 @@ public IntercomHttpResponse update( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, 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 deleted file mode 100644 index fb47c39..0000000 --- a/src/main/java/com/intercom/api/resources/dataattributes/requests/CreateDataAttributeRequest.java +++ /dev/null @@ -1,508 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.intercom.api.resources.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/dataattributes/requests/UpdateDataAttributeRequest.java b/src/main/java/com/intercom/api/resources/dataattributes/requests/UpdateDataAttributeRequest.java index 23e4d8f..ef9e932 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 @@ -9,43 +9,27 @@ 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.types.UpdateDataAttributeRequestBody; 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 = UpdateDataAttributeRequest.Builder.class) public final class UpdateDataAttributeRequest { - private final String dataAttributeId; + private final int dataAttributeId; - private final Optional archived; - - private final Optional description; - - private final Optional> options; - - private final Optional messengerWritable; + private final UpdateDataAttributeRequestBody body; private final Map additionalProperties; private UpdateDataAttributeRequest( - String dataAttributeId, - Optional archived, - Optional description, - Optional> options, - Optional messengerWritable, - Map additionalProperties) { + int dataAttributeId, UpdateDataAttributeRequestBody body, Map additionalProperties) { this.dataAttributeId = dataAttributeId; - this.archived = archived; - this.description = description; - this.options = options; - this.messengerWritable = messengerWritable; + this.body = body; this.additionalProperties = additionalProperties; } @@ -53,40 +37,13 @@ private UpdateDataAttributeRequest( * @return The data attribute id */ @JsonProperty("data_attribute_id") - public String getDataAttributeId() { + public int getDataAttributeId() { return dataAttributeId; } - /** - * @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; + @JsonProperty("body") + public UpdateDataAttributeRequestBody getBody() { + return body; } @java.lang.Override @@ -101,17 +58,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateDataAttributeRequest other) { - return dataAttributeId.equals(other.dataAttributeId) - && archived.equals(other.archived) - && description.equals(other.description) - && options.equals(other.options) - && messengerWritable.equals(other.messengerWritable); + return dataAttributeId == other.dataAttributeId && body.equals(other.body); } @java.lang.Override public int hashCode() { - return Objects.hash( - this.dataAttributeId, this.archived, this.description, this.options, this.messengerWritable); + return Objects.hash(this.dataAttributeId, this.body); } @java.lang.Override @@ -125,56 +77,26 @@ public static DataAttributeIdStage builder() { public interface DataAttributeIdStage { /** - * The data attribute id + *

    The data attribute id

    */ - _FinalStage dataAttributeId(@NotNull String dataAttributeId); + BodyStage dataAttributeId(int dataAttributeId); Builder from(UpdateDataAttributeRequest other); } + public interface BodyStage { + _FinalStage body(@NotNull UpdateDataAttributeRequestBody body); + } + 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 DataAttributeIdStage, _FinalStage { - private String dataAttributeId; - - private Optional messengerWritable = Optional.empty(); - - private Optional> options = Optional.empty(); - - private Optional description = Optional.empty(); + public static final class Builder implements DataAttributeIdStage, BodyStage, _FinalStage { + private int dataAttributeId; - private Optional archived = Optional.empty(); + private UpdateDataAttributeRequestBody body; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -184,193 +106,32 @@ private Builder() {} @java.lang.Override public Builder from(UpdateDataAttributeRequest other) { dataAttributeId(other.getDataAttributeId()); - archived(other.getArchived()); - description(other.getDescription()); - options(other.getOptions()); - messengerWritable(other.getMessengerWritable()); + body(other.getBody()); return this; } /** - * The data attribute id

    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 @JsonSetter("data_attribute_id") - public _FinalStage dataAttributeId(@NotNull String dataAttributeId) { - this.dataAttributeId = Objects.requireNonNull(dataAttributeId, "dataAttributeId 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; + public BodyStage dataAttributeId(int dataAttributeId) { + this.dataAttributeId = dataAttributeId; 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; + @JsonSetter("body") + public _FinalStage body(@NotNull UpdateDataAttributeRequestBody body) { + this.body = Objects.requireNonNull(body, "body must not be null"); return this; } @java.lang.Override public UpdateDataAttributeRequest build() { - return new UpdateDataAttributeRequest( - dataAttributeId, archived, description, options, messengerWritable, additionalProperties); - } - } - - @JsonInclude(JsonInclude.Include.NON_ABSENT) - @JsonDeserialize(builder = OptionsItem.Builder.class) - public static final class OptionsItem { - private final String value; - - private final Map additionalProperties; - - private OptionsItem(String value, Map additionalProperties) { - this.value = value; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof OptionsItem && equalTo((OptionsItem) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(OptionsItem other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ValueStage builder() { - return new Builder(); - } - - public interface ValueStage { - _FinalStage value(@NotNull String value); - - Builder from(OptionsItem other); - } - - public interface _FinalStage { - OptionsItem build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ValueStage, _FinalStage { - private String value; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(OptionsItem other) { - value(other.getValue()); - return this; - } - - @java.lang.Override - @JsonSetter("value") - public _FinalStage value(@NotNull String value) { - this.value = Objects.requireNonNull(value, "value must not be null"); - return this; - } - - @java.lang.Override - public OptionsItem build() { - return new OptionsItem(value, additionalProperties); - } + return new UpdateDataAttributeRequest(dataAttributeId, body, additionalProperties); } } } 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 f8a11fe..09cc6bd 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 @@ -34,7 +34,7 @@ public final class DataAttribute { private final String label; - private final String description; + private final Optional description; private final DataType dataType; @@ -64,7 +64,7 @@ private DataAttribute( String name, String fullName, String label, - String description, + Optional description, DataType dataType, Optional> options, Optional apiWritable, @@ -147,7 +147,7 @@ public String getLabel() { * @return Readable description of the attribute. */ @JsonProperty("description") - public String getDescription() { + public Optional getDescription() { return description; } @@ -293,7 +293,7 @@ public static NameStage builder() { public interface NameStage { /** - * Name of the attribute. + *

    Name of the attribute.

    */ FullNameStage name(@NotNull String name); @@ -302,28 +302,21 @@ public interface NameStage { 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. + *

    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) + *

    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); + DataTypeStage label(@NotNull String label); } public interface DataTypeStage { /** - * The data type of the attribute. + *

    The data type of the attribute.

    */ _FinalStage dataType(@NotNull DataType dataType); } @@ -345,6 +338,13 @@ public interface _FinalStage { _FinalStage model(Model model); + /** + *

    Readable description of the attribute.

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

    List of predefined options for attribute value.

    */ @@ -410,16 +410,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements NameStage, FullNameStage, LabelStage, DescriptionStage, DataTypeStage, _FinalStage { + public static final class Builder implements NameStage, FullNameStage, LabelStage, DataTypeStage, _FinalStage { private String name; private String fullName; private String label; - private String description; - private DataType dataType; private Optional adminId = Optional.empty(); @@ -440,6 +437,8 @@ public static final class Builder private Optional> options = Optional.empty(); + private Optional description = Optional.empty(); + private Optional model = Optional.empty(); private Optional id = Optional.empty(); @@ -471,7 +470,8 @@ public Builder from(DataAttribute other) { } /** - * Name of the attribute.

    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 @@ -482,7 +482,8 @@ 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.

    + *

    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 @@ -493,29 +494,20 @@ 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)

    + *

    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 @JsonSetter("label") - public DescriptionStage label(@NotNull String label) { + public DataTypeStage label(@NotNull String label) { this.label = Objects.requireNonNull(label, "label must not be null"); return this; } /** - * 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 - @JsonSetter("description") - public DataTypeStage description(@NotNull String description) { - this.description = Objects.requireNonNull(description, "description must not be null"); - return this; - } - - /** - * The data type of the attribute.

    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 @@ -705,6 +697,26 @@ public _FinalStage options(Optional> options) { return this; } + /** + *

    Readable description of 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; + } + + /** + *

    Readable description of the attribute.

    + */ + @java.lang.Override + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public _FinalStage description(Optional description) { + this.description = description; + return this; + } + /** *

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

    * @return Reference to {@code this} so that method calls can be chained together. 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 630d1bd..67bf949 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 @@ -170,7 +170,7 @@ 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`. + *

    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); @@ -179,7 +179,7 @@ public interface EventNameStage { public interface CreatedAtStage { /** - * The time the event occurred as a UTC Unix timestamp + *

    The time the event occurred as a UTC Unix timestamp

    */ _FinalStage createdAt(int createdAt); } @@ -267,7 +267,8 @@ 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.

    + *

    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 @@ -278,7 +279,8 @@ 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

    + *

    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 diff --git a/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java index a64e7a7..e5cde46 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/AsyncDataExportClient.java @@ -8,8 +8,11 @@ import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; import java.util.concurrent.CompletableFuture; public class AsyncDataExportClient { @@ -29,6 +32,41 @@ public AsyncRawDataExportClient withRawResponse() { return this.rawClient; } + public CompletableFuture exportReportingData( + ExportReportingDataRequest request) { + return this.rawClient.exportReportingData(request).thenApply(response -> response.body()); + } + + public CompletableFuture exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + return this.rawClient.exportReportingData(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture downloadReportingDataExport(DownloadReportingDataExportRequest request) { + return this.rawClient.downloadReportingDataExport(request).thenApply(response -> response.body()); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture downloadReportingDataExport( + DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + return this.rawClient + .downloadReportingDataExport(request, requestOptions) + .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.

    diff --git a/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java index 7ce121e..732c373 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/AsyncRawDataExportClient.java @@ -10,12 +10,17 @@ 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.errors.NotFoundError; import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -36,6 +41,142 @@ public AsyncRawDataExportClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } + public CompletableFuture> exportReportingData( + ExportReportingDataRequest request) { + return exportReportingData(request, null); + } + + public CompletableFuture> exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + QueryStringMapper.addQueryParameter(httpUrl, "client_id", request.getClientId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, DataExportExportReportingDataResponse.class), + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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; + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture> downloadReportingDataExport( + DownloadReportingDataExportRequest request) { + return downloadReportingDataExport(request, null); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public CompletableFuture> downloadReportingDataExport( + DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + _requestBuilder.addHeader("accept", request.getAccept()); + 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() == 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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; + } + /** * 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.

    @@ -101,18 +242,15 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataExport.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -158,7 +296,6 @@ public CompletableFuture> find( .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(); @@ -170,18 +307,15 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataExport.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -217,7 +351,6 @@ public CompletableFuture> cancel( .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(); @@ -229,18 +362,15 @@ public CompletableFuture> cancel( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataExport.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -301,11 +431,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO return; } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java index 0237d41..2aab00a 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/DataExportClient.java @@ -8,8 +8,11 @@ import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; public class DataExportClient { protected final ClientOptions clientOptions; @@ -28,6 +31,37 @@ public RawDataExportClient withRawResponse() { return this.rawClient; } + public DataExportExportReportingDataResponse exportReportingData(ExportReportingDataRequest request) { + return this.rawClient.exportReportingData(request).body(); + } + + public DataExportExportReportingDataResponse exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + return this.rawClient.exportReportingData(request, requestOptions).body(); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public void downloadReportingDataExport(DownloadReportingDataExportRequest request) { + this.rawClient.downloadReportingDataExport(request).body(); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public void downloadReportingDataExport(DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + this.rawClient.downloadReportingDataExport(request, requestOptions).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.

    diff --git a/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java b/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java index 701b488..c04b729 100644 --- a/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java +++ b/src/main/java/com/intercom/api/resources/dataexport/RawDataExportClient.java @@ -10,12 +10,17 @@ 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.errors.NotFoundError; import com.intercom.api.resources.dataexport.requests.CancelDataExportRequest; import com.intercom.api.resources.dataexport.requests.CreateDataExportRequest; import com.intercom.api.resources.dataexport.requests.DownloadDataExportRequest; +import com.intercom.api.resources.dataexport.requests.DownloadReportingDataExportRequest; +import com.intercom.api.resources.dataexport.requests.ExportReportingDataRequest; import com.intercom.api.resources.dataexport.requests.FindDataExportRequest; import com.intercom.api.resources.dataexport.types.DataExport; +import com.intercom.api.resources.dataexport.types.DataExportExportReportingDataResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -32,6 +37,112 @@ public RawDataExportClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } + public IntercomHttpResponse exportReportingData( + ExportReportingDataRequest request) { + return exportReportingData(request, null); + } + + public IntercomHttpResponse exportReportingData( + ExportReportingDataRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("export/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + QueryStringMapper.addQueryParameter(httpUrl, "client_id", request.getClientId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, DataExportExportReportingDataResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public IntercomHttpResponse downloadReportingDataExport(DownloadReportingDataExportRequest request) { + return downloadReportingDataExport(request, null); + } + + /** + * Download the data from a completed reporting data export job. + *
    + *

    Octet header required

    + *

    You will have to specify the header Accept: application/octet-stream when hitting this endpoint.

    + *
    + */ + public IntercomHttpResponse downloadReportingDataExport( + DownloadReportingDataExportRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("download/reporting_data") + .addPathSegment(request.getJobIdentifier()); + QueryStringMapper.addQueryParameter(httpUrl, "app_id", request.getAppId(), false); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json"); + _requestBuilder.addHeader("accept", request.getAccept()); + 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() == 404) { + throw new NotFoundError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + /** * 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.

    @@ -93,16 +204,14 @@ public IntercomHttpResponse create(CreateDataExportRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataExport.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -138,7 +247,6 @@ public IntercomHttpResponse find(FindDataExportRequest request, Requ .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(); @@ -147,16 +255,14 @@ public IntercomHttpResponse find(FindDataExportRequest request, Requ } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataExport.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -182,7 +288,6 @@ public IntercomHttpResponse cancel(CancelDataExportRequest request, .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(); @@ -191,16 +296,14 @@ public IntercomHttpResponse cancel(CancelDataExportRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataExport.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataExport.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -247,11 +350,9 @@ public IntercomHttpResponse download(DownloadDataExportRequest request, Re return new IntercomHttpResponse<>(null, response); } String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 f8bc876..1b215ec 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 @@ -67,7 +67,7 @@ public static JobIdentifierStage builder() { public interface JobIdentifierStage { /** - * job_identifier + *

    job_identifier

    */ _FinalStage jobIdentifier(@NotNull String jobIdentifier); @@ -94,7 +94,8 @@ public Builder from(CancelDataExportRequest other) { } /** - * job_identifier

    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 7e8babb..23da7f6 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 @@ -77,7 +77,7 @@ public static CreatedAtAfterStage builder() { public interface CreatedAtAfterStage { /** - * 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.

    */ CreatedAtBeforeStage createdAtAfter(int createdAtAfter); @@ -86,7 +86,7 @@ public interface CreatedAtAfterStage { public interface CreatedAtBeforeStage { /** - * 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.

    */ _FinalStage createdAtBefore(int createdAtBefore); } @@ -114,7 +114,8 @@ 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.

    + *

    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 @@ -125,7 +126,8 @@ 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.

    + *

    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 f8fba0d..bfd5f32 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 @@ -67,7 +67,7 @@ public static JobIdentifierStage builder() { public interface JobIdentifierStage { /** - * job_identifier + *

    job_identifier

    */ _FinalStage jobIdentifier(@NotNull String jobIdentifier); @@ -94,7 +94,8 @@ public Builder from(DownloadDataExportRequest other) { } /** - * job_identifier

    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/DownloadReportingDataExportRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadReportingDataExportRequest.java new file mode 100644 index 0000000..3bac7a8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/DownloadReportingDataExportRequest.java @@ -0,0 +1,135 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataexport.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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 = DownloadReportingDataExportRequest.Builder.class) +public final class DownloadReportingDataExportRequest { + private final String jobIdentifier; + + private final String appId; + + private final Map additionalProperties; + + private DownloadReportingDataExportRequest( + String jobIdentifier, String appId, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.appId = appId; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + /** + * @return Required header for downloading the export file + */ + @JsonIgnore + public String getAccept() { + return "application/octet-stream"; + } + + @JsonProperty("app_id") + public String getAppId() { + return appId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DownloadReportingDataExportRequest + && equalTo((DownloadReportingDataExportRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DownloadReportingDataExportRequest other) { + return jobIdentifier.equals(other.jobIdentifier) && appId.equals(other.appId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.appId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + AppIdStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(DownloadReportingDataExportRequest other); + } + + public interface AppIdStage { + _FinalStage appId(@NotNull String appId); + } + + public interface _FinalStage { + DownloadReportingDataExportRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, AppIdStage, _FinalStage { + private String jobIdentifier; + + private String appId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DownloadReportingDataExportRequest other) { + jobIdentifier(other.getJobIdentifier()); + appId(other.getAppId()); + return this; + } + + @java.lang.Override + @JsonSetter("job_identifier") + public AppIdStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("app_id") + public _FinalStage appId(@NotNull String appId) { + this.appId = Objects.requireNonNull(appId, "appId must not be null"); + return this; + } + + @java.lang.Override + public DownloadReportingDataExportRequest build() { + return new DownloadReportingDataExportRequest(jobIdentifier, appId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/dataexport/requests/ExportReportingDataRequest.java b/src/main/java/com/intercom/api/resources/dataexport/requests/ExportReportingDataRequest.java new file mode 100644 index 0000000..bb2c6c8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/requests/ExportReportingDataRequest.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 = ExportReportingDataRequest.Builder.class) +public final class ExportReportingDataRequest { + private final String jobIdentifier; + + private final String appId; + + private final String clientId; + + private final Map additionalProperties; + + private ExportReportingDataRequest( + String jobIdentifier, String appId, String clientId, Map additionalProperties) { + this.jobIdentifier = jobIdentifier; + this.appId = appId; + this.clientId = clientId; + this.additionalProperties = additionalProperties; + } + + /** + * @return Unique identifier of the job. + */ + @JsonProperty("job_identifier") + public String getJobIdentifier() { + return jobIdentifier; + } + + /** + * @return The Intercom defined code of the workspace the company is associated to. + */ + @JsonProperty("app_id") + public String getAppId() { + return appId; + } + + @JsonProperty("client_id") + public String getClientId() { + return clientId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ExportReportingDataRequest && equalTo((ExportReportingDataRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ExportReportingDataRequest other) { + return jobIdentifier.equals(other.jobIdentifier) + && appId.equals(other.appId) + && clientId.equals(other.clientId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobIdentifier, this.appId, this.clientId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdentifierStage builder() { + return new Builder(); + } + + public interface JobIdentifierStage { + /** + *

    Unique identifier of the job.

    + */ + AppIdStage jobIdentifier(@NotNull String jobIdentifier); + + Builder from(ExportReportingDataRequest other); + } + + public interface AppIdStage { + /** + *

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

    + */ + ClientIdStage appId(@NotNull String appId); + } + + public interface ClientIdStage { + _FinalStage clientId(@NotNull String clientId); + } + + public interface _FinalStage { + ExportReportingDataRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdentifierStage, AppIdStage, ClientIdStage, _FinalStage { + private String jobIdentifier; + + private String appId; + + private String clientId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ExportReportingDataRequest other) { + jobIdentifier(other.getJobIdentifier()); + appId(other.getAppId()); + clientId(other.getClientId()); + return this; + } + + /** + *

    Unique identifier of the job.

    + *

    Unique identifier of the job.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("job_identifier") + public AppIdStage jobIdentifier(@NotNull String jobIdentifier) { + this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + return this; + } + + /** + *

    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 + @JsonSetter("app_id") + public ClientIdStage appId(@NotNull String appId) { + this.appId = Objects.requireNonNull(appId, "appId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("client_id") + public _FinalStage clientId(@NotNull String clientId) { + this.clientId = Objects.requireNonNull(clientId, "clientId must not be null"); + return this; + } + + @java.lang.Override + public ExportReportingDataRequest build() { + return new ExportReportingDataRequest(jobIdentifier, appId, clientId, additionalProperties); + } + } +} 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 b5cc684..c5eece1 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 @@ -67,7 +67,7 @@ public static JobIdentifierStage builder() { public interface JobIdentifierStage { /** - * job_identifier + *

    job_identifier

    */ _FinalStage jobIdentifier(@NotNull String jobIdentifier); @@ -94,7 +94,8 @@ public Builder from(FindDataExportRequest other) { } /** - * job_identifier

    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 3638989..237938e 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 @@ -11,31 +11,32 @@ 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 org.jetbrains.annotations.NotNull; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DataExport.Builder.class) public final class DataExport { - private final String jobIdentifier; + private final Optional jobIdentifier; - private final Status status; + private final Optional status; - private final String downloadExpiresAt; + private final Optional downloadExpiresAt; - private final String downloadUrl; + private final Optional downloadUrl; private final Map additionalProperties; private DataExport( - String jobIdentifier, - Status status, - String downloadExpiresAt, - String downloadUrl, + Optional jobIdentifier, + Optional status, + Optional downloadExpiresAt, + Optional downloadUrl, Map additionalProperties) { this.jobIdentifier = jobIdentifier; this.status = status; @@ -48,7 +49,7 @@ private DataExport( * @return The identifier for your job. */ @JsonProperty("job_identifier") - public String getJobIdentifier() { + public Optional getJobIdentifier() { return jobIdentifier; } @@ -56,7 +57,7 @@ public String getJobIdentifier() { * @return The current state of your job. */ @JsonProperty("status") - public Status getStatus() { + public Optional getStatus() { return status; } @@ -64,7 +65,7 @@ public Status getStatus() { * @return The time after which you will not be able to access the data. */ @JsonProperty("download_expires_at") - public String getDownloadExpiresAt() { + public Optional getDownloadExpiresAt() { return downloadExpiresAt; } @@ -72,7 +73,7 @@ public String getDownloadExpiresAt() { * @return The location where you can download your data. */ @JsonProperty("download_url") - public String getDownloadUrl() { + public Optional getDownloadUrl() { return downloadUrl; } @@ -104,61 +105,25 @@ public String toString() { return ObjectMappers.stringify(this); } - public static JobIdentifierStage builder() { + public static Builder builder() { return new 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); - } - - public interface _FinalStage { - DataExport build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements JobIdentifierStage, StatusStage, DownloadExpiresAtStage, DownloadUrlStage, _FinalStage { - private String jobIdentifier; + public static final class Builder { + private Optional jobIdentifier = Optional.empty(); - private Status status; + private Optional status = Optional.empty(); - private String downloadExpiresAt; + private Optional downloadExpiresAt = Optional.empty(); - private String downloadUrl; + private Optional downloadUrl = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(DataExport other) { jobIdentifier(other.getJobIdentifier()); status(other.getStatus()); @@ -168,50 +133,61 @@ public Builder from(DataExport other) { } /** - * The identifier for your job.

    The identifier for your job.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The identifier for your job.

    */ - @java.lang.Override - @JsonSetter("job_identifier") - public StatusStage jobIdentifier(@NotNull String jobIdentifier) { - this.jobIdentifier = Objects.requireNonNull(jobIdentifier, "jobIdentifier must not be null"); + @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; } /** - * 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. + *

    The current state of your job.

    */ - @java.lang.Override - @JsonSetter("status") - public DownloadExpiresAtStage status(@NotNull Status status) { - this.status = Objects.requireNonNull(status, "status must not be null"); + @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.

    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. + *

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

    */ - @java.lang.Override - @JsonSetter("download_expires_at") - public DownloadUrlStage downloadExpiresAt(@NotNull String downloadExpiresAt) { - this.downloadExpiresAt = Objects.requireNonNull(downloadExpiresAt, "downloadExpiresAt must not be null"); + @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.

    The location where you can download your data.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The location where you can download your data.

    */ - @java.lang.Override - @JsonSetter("download_url") - public _FinalStage downloadUrl(@NotNull String downloadUrl) { - this.downloadUrl = Objects.requireNonNull(downloadUrl, "downloadUrl must not be null"); + @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; } - @java.lang.Override public DataExport build() { return new DataExport(jobIdentifier, status, downloadExpiresAt, downloadUrl, additionalProperties); } diff --git a/src/main/java/com/intercom/api/resources/dataexport/types/DataExportExportReportingDataResponse.java b/src/main/java/com/intercom/api/resources/dataexport/types/DataExportExportReportingDataResponse.java new file mode 100644 index 0000000..315451c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/dataexport/types/DataExportExportReportingDataResponse.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.dataexport.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 = DataExportExportReportingDataResponse.Builder.class) +public final class DataExportExportReportingDataResponse { + private final Optional jobIdentifier; + + private final Optional status; + + private final Optional downloadUrl; + + private final Optional downloadExpiresAt; + + private final Map additionalProperties; + + private DataExportExportReportingDataResponse( + 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 DataExportExportReportingDataResponse + && equalTo((DataExportExportReportingDataResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DataExportExportReportingDataResponse 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(DataExportExportReportingDataResponse 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 DataExportExportReportingDataResponse build() { + return new DataExportExportReportingDataResponse( + jobIdentifier, status, downloadUrl, downloadExpiresAt, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/events/AsyncRawEventsClient.java b/src/main/java/com/intercom/api/resources/events/AsyncRawEventsClient.java index b30e691..d7e5502 100644 --- a/src/main/java/com/intercom/api/resources/events/AsyncRawEventsClient.java +++ b/src/main/java/com/intercom/api/resources/events/AsyncRawEventsClient.java @@ -90,17 +90,16 @@ public CompletableFuture> list( QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType(), false); if (request.getSummary().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "summary", request.getSummary().get().toString(), false); + httpUrl, "summary", request.getSummary().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -112,13 +111,13 @@ public CompletableFuture> list( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataEventSummary.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataEventSummary.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -128,11 +127,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -260,11 +257,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -339,11 +334,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/events/RawEventsClient.java b/src/main/java/com/intercom/api/resources/events/RawEventsClient.java index edf2a4e..4f53d76 100644 --- a/src/main/java/com/intercom/api/resources/events/RawEventsClient.java +++ b/src/main/java/com/intercom/api/resources/events/RawEventsClient.java @@ -85,17 +85,16 @@ public IntercomHttpResponse list(ListEventsRequest request, Re QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType(), false); if (request.getSummary().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "summary", request.getSummary().get().toString(), false); + httpUrl, "summary", request.getSummary().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -104,11 +103,11 @@ public IntercomHttpResponse list(ListEventsRequest request, Re } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DataEventSummary.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DataEventSummary.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -117,11 +116,9 @@ public IntercomHttpResponse list(ListEventsRequest request, Re } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -234,11 +231,9 @@ public IntercomHttpResponse create(CreateDataEventRequest request, Request } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -298,11 +293,9 @@ public IntercomHttpResponse summaries(ListEventSummariesRequest request, R } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 038fa0c..b075147 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 @@ -136,7 +136,7 @@ public static TypeStage builder() { public interface TypeStage { /** - * The value must be user + *

    The value must be user

    */ _FinalStage type(@NotNull String type); @@ -213,7 +213,8 @@ public Builder from(ListEventsRequest other) { } /** - * The value must be user

    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 diff --git a/src/main/java/com/intercom/api/resources/export/AsyncExportClient.java b/src/main/java/com/intercom/api/resources/export/AsyncExportClient.java new file mode 100644 index 0000000..1122e61 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/AsyncExportClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.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/export/AsyncRawExportClient.java b/src/main/java/com/intercom/api/resources/export/AsyncRawExportClient.java new file mode 100644 index 0000000..2b76ed5 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/AsyncRawExportClient.java @@ -0,0 +1,174 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.BadRequestError; +import com.intercom.api.errors.TooManyRequestsError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.export.types.PostExportReportingDataEnqueueResponse; +import com.intercom.api.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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, PostExportReportingDataEnqueueResponse.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, GetExportReportingDataGetDatasetsResponse.class), + response)); + return; + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/export/ExportClient.java b/src/main/java/com/intercom/api/resources/export/ExportClient.java new file mode 100644 index 0000000..b2d7985 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/ExportClient.java @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.export; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.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/export/RawExportClient.java b/src/main/java/com/intercom/api/resources/export/RawExportClient.java new file mode 100644 index 0000000..9f3b7bf --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/RawExportClient.java @@ -0,0 +1,134 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.BadRequestError; +import com.intercom.api.errors.TooManyRequestsError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.export.requests.PostExportReportingDataEnqueueRequest; +import com.intercom.api.resources.export.types.GetExportReportingDataGetDatasetsResponse; +import com.intercom.api.resources.export.types.PostExportReportingDataEnqueueResponse; +import com.intercom.api.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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, PostExportReportingDataEnqueueResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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("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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, GetExportReportingDataGetDatasetsResponse.class), + response); + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/export/requests/PostExportReportingDataEnqueueRequest.java b/src/main/java/com/intercom/api/resources/export/requests/PostExportReportingDataEnqueueRequest.java new file mode 100644 index 0000000..406e797 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/requests/PostExportReportingDataEnqueueRequest.java @@ -0,0 +1,200 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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) { + if (attributeIds != null) { + 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(); + if (attributeIds != null) { + 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/export/types/GetExportReportingDataGetDatasetsResponse.java b/src/main/java/com/intercom/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.java new file mode 100644 index 0000000..27ab352 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.java @@ -0,0 +1,395 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/export/types/PostExportReportingDataEnqueueResponse.java b/src/main/java/com/intercom/api/resources/export/types/PostExportReportingDataEnqueueResponse.java new file mode 100644 index 0000000..982e08f --- /dev/null +++ b/src/main/java/com/intercom/api/resources/export/types/PostExportReportingDataEnqueueResponse.java @@ -0,0 +1,171 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/helpcenter/types/Collection.java b/src/main/java/com/intercom/api/resources/helpcenter/types/Collection.java index 1231cee..74b451c 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 @@ -40,7 +40,7 @@ public final class Collection { private final int order; - private final String defaultLocale; + private final Optional defaultLocale; private final Optional translatedContent; @@ -60,7 +60,7 @@ private Collection( Optional url, Optional icon, int order, - String defaultLocale, + Optional defaultLocale, Optional translatedContent, Optional parentId, Optional helpCenterId, @@ -157,7 +157,7 @@ public int getOrder() { * @return The default locale of the help center. This field is only returned for multilingual help centers. */ @JsonProperty("default_locale") - public String getDefaultLocale() { + public Optional getDefaultLocale() { return defaultLocale; } @@ -238,7 +238,7 @@ public static IdStage builder() { public interface IdStage { /** - * The unique identifier for the collection which is given by Intercom. + *

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

    */ WorkspaceIdStage id(@NotNull String id); @@ -247,37 +247,30 @@ public interface IdStage { public interface WorkspaceIdStage { /** - * The id of the workspace which the collection belongs to. + *

    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. + *

    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. + *

    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. + *

    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); + _FinalStage order(int order); } public interface _FinalStage { @@ -311,6 +304,13 @@ public interface _FinalStage { _FinalStage icon(String icon); + /** + *

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

    + */ + _FinalStage defaultLocale(Optional defaultLocale); + + _FinalStage defaultLocale(String defaultLocale); + _FinalStage translatedContent(Optional translatedContent); _FinalStage translatedContent(GroupTranslatedContent translatedContent); @@ -332,13 +332,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder - implements IdStage, - WorkspaceIdStage, - NameStage, - CreatedAtStage, - OrderStage, - DefaultLocaleStage, - _FinalStage { + implements IdStage, WorkspaceIdStage, NameStage, CreatedAtStage, OrderStage, _FinalStage { private String id; private String workspaceId; @@ -349,14 +343,14 @@ public static final class Builder private int order; - private String defaultLocale; - private Optional helpCenterId = Optional.empty(); private Optional parentId = Optional.empty(); private Optional translatedContent = Optional.empty(); + private Optional defaultLocale = Optional.empty(); + private Optional icon = Optional.empty(); private Optional url = Optional.empty(); @@ -389,7 +383,8 @@ 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.

    + *

    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 @@ -400,7 +395,8 @@ 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.

    + *

    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 @@ -411,7 +407,8 @@ 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.

    + *

    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 @@ -422,7 +419,8 @@ 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.

    + *

    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 @@ -433,27 +431,17 @@ 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.

    + *

    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 @JsonSetter("order") - public DefaultLocaleStage order(int order) { + public _FinalStage order(int order) { this.order = order; return this; } - /** - * 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 - @JsonSetter("default_locale") - public _FinalStage defaultLocale(@NotNull String defaultLocale) { - this.defaultLocale = Objects.requireNonNull(defaultLocale, "defaultLocale must not be null"); - return this; - } - /** *

    The id of the help center the collection is in.

    * @return Reference to {@code this} so that method calls can be chained together. @@ -507,6 +495,26 @@ public _FinalStage translatedContent(Optional translated return this; } + /** + *

    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 + public _FinalStage defaultLocale(String defaultLocale) { + this.defaultLocale = Optional.ofNullable(defaultLocale); + return this; + } + + /** + *

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

    + */ + @java.lang.Override + @JsonSetter(value = "default_locale", nulls = Nulls.SKIP) + public _FinalStage defaultLocale(Optional defaultLocale) { + this.defaultLocale = defaultLocale; + return this; + } + /** *

    The icon of the collection.

    * @return Reference to {@code this} so that method calls can be chained together. 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 bb52590..81b0dd5 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 @@ -16,35 +16,40 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = HelpCenter.Builder.class) public final class HelpCenter { - private final String id; + private final Optional id; - private final String workspaceId; + private final Optional workspaceId; - private final int createdAt; + private final Optional createdAt; private final Optional updatedAt; - private final String identifier; + private final Optional identifier; - private final boolean websiteTurnedOn; + private final Optional websiteTurnedOn; - private final String displayName; + private final Optional displayName; + + private final Optional url; + + private final Optional customDomain; private final Map additionalProperties; private HelpCenter( - String id, - String workspaceId, - int createdAt, + Optional id, + Optional workspaceId, + Optional createdAt, Optional updatedAt, - String identifier, - boolean websiteTurnedOn, - String displayName, + Optional identifier, + Optional websiteTurnedOn, + Optional displayName, + Optional url, + Optional customDomain, Map additionalProperties) { this.id = id; this.workspaceId = workspaceId; @@ -53,6 +58,8 @@ private HelpCenter( this.identifier = identifier; this.websiteTurnedOn = websiteTurnedOn; this.displayName = displayName; + this.url = url; + this.customDomain = customDomain; this.additionalProperties = additionalProperties; } @@ -60,7 +67,7 @@ private HelpCenter( * @return The unique identifier for the Help Center which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -68,7 +75,7 @@ public String getId() { * @return The id of the workspace which the Help Center belongs to. */ @JsonProperty("workspace_id") - public String getWorkspaceId() { + public Optional getWorkspaceId() { return workspaceId; } @@ -76,7 +83,7 @@ public String getWorkspaceId() { * @return The time when the Help Center was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -92,7 +99,7 @@ public Optional getUpdatedAt() { * @return The identifier of the Help Center. This is used in the URL of the Help Center. */ @JsonProperty("identifier") - public String getIdentifier() { + public Optional getIdentifier() { return identifier; } @@ -100,7 +107,7 @@ public String getIdentifier() { * @return Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ @JsonProperty("website_turned_on") - public boolean getWebsiteTurnedOn() { + public Optional getWebsiteTurnedOn() { return websiteTurnedOn; } @@ -108,10 +115,26 @@ public boolean getWebsiteTurnedOn() { * @return The display name of the Help Center only seen by teammates. */ @JsonProperty("display_name") - public String getDisplayName() { + public Optional getDisplayName() { return displayName; } + /** + * @return The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. + */ + @JsonProperty("url") + public Optional getUrl() { + return url; + } + + /** + * @return Custom domain configured for the help center + */ + @JsonProperty("custom_domain") + public Optional getCustomDomain() { + return customDomain; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -126,11 +149,13 @@ public Map getAdditionalProperties() { private boolean equalTo(HelpCenter other) { return id.equals(other.id) && workspaceId.equals(other.workspaceId) - && createdAt == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && identifier.equals(other.identifier) - && websiteTurnedOn == other.websiteTurnedOn - && displayName.equals(other.displayName); + && websiteTurnedOn.equals(other.websiteTurnedOn) + && displayName.equals(other.displayName) + && url.equals(other.url) + && customDomain.equals(other.customDomain); } @java.lang.Override @@ -142,7 +167,9 @@ public int hashCode() { this.updatedAt, this.identifier, this.websiteTurnedOn, - this.displayName); + this.displayName, + this.url, + this.customDomain); } @java.lang.Override @@ -150,94 +177,35 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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(); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); - /** - *

    The time when the Help Center was last updated.

    - */ - _FinalStage updatedAt(Optional updatedAt); + private Optional workspaceId = Optional.empty(); - _FinalStage updatedAt(Integer updatedAt); - } + private Optional createdAt = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - WorkspaceIdStage, - CreatedAtStage, - IdentifierStage, - WebsiteTurnedOnStage, - DisplayNameStage, - _FinalStage { - private String id; + private Optional updatedAt = Optional.empty(); - private String workspaceId; + private Optional identifier = Optional.empty(); - private int createdAt; + private Optional websiteTurnedOn = Optional.empty(); - private String identifier; + private Optional displayName = Optional.empty(); - private boolean websiteTurnedOn; + private Optional url = Optional.empty(); - private String displayName; - - private Optional updatedAt = Optional.empty(); + private Optional customDomain = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(HelpCenter other) { id(other.getId()); workspaceId(other.getWorkspaceId()); @@ -246,96 +214,137 @@ public Builder from(HelpCenter other) { identifier(other.getIdentifier()); websiteTurnedOn(other.getWebsiteTurnedOn()); displayName(other.getDisplayName()); + url(other.getUrl()); + customDomain(other.getCustomDomain()); return this; } /** - * 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. + *

    The unique identifier for the Help Center which is given by Intercom.

    */ - @java.lang.Override - @JsonSetter("id") - public WorkspaceIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @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.

    The id of the workspace which the Help Center belongs to.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id of the workspace which the Help Center belongs to.

    */ - @java.lang.Override - @JsonSetter("workspace_id") - public CreatedAtStage workspaceId(@NotNull String workspaceId) { - this.workspaceId = Objects.requireNonNull(workspaceId, "workspaceId must not be null"); + @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.

    The time when the Help Center was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The time when the Help Center was created.

    */ - @java.lang.Override - @JsonSetter("created_at") - public IdentifierStage createdAt(int createdAt) { + @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.

    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. + *

    The identifier of the Help Center. This is used in the URL of the Help Center.

    */ - @java.lang.Override - @JsonSetter("identifier") - public WebsiteTurnedOnStage identifier(@NotNull String identifier) { - this.identifier = Objects.requireNonNull(identifier, "identifier must not be null"); + @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.

    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. + *

    Whether the Help Center is turned on or not. This is controlled in your Help Center settings.

    */ - @java.lang.Override - @JsonSetter("website_turned_on") - public DisplayNameStage websiteTurnedOn(boolean websiteTurnedOn) { + @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.

    The display name of the Help Center only seen by teammates.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The display name of the Help Center only seen by teammates.

    */ - @java.lang.Override - @JsonSetter("display_name") - public _FinalStage displayName(@NotNull String displayName) { - this.displayName = Objects.requireNonNull(displayName, "displayName must not be null"); + @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; } /** - *

    The time when the Help Center was last updated.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The URL for the help center, if you have a custom domain then this will show the URL using the custom domain.

    */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + @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 time when the Help Center was last updated.

    + *

    Custom domain configured for the help center

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @JsonSetter(value = "custom_domain", nulls = Nulls.SKIP) + public Builder customDomain(Optional customDomain) { + this.customDomain = customDomain; + return this; + } + + public Builder customDomain(String customDomain) { + this.customDomain = Optional.ofNullable(customDomain); return this; } - @java.lang.Override public HelpCenter build() { return new HelpCenter( id, @@ -345,6 +354,8 @@ public HelpCenter build() { identifier, websiteTurnedOn, displayName, + url, + customDomain, additionalProperties); } } 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 623d7e0..1a1f980 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 @@ -12,20 +12,24 @@ 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 java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = HelpCenterList.Builder.class) public final class HelpCenterList { - private final List data; + private final Optional type; + + private final Optional> data; private final Map additionalProperties; - private HelpCenterList(List data, Map additionalProperties) { + private HelpCenterList( + Optional type, Optional> data, Map additionalProperties) { + this.type = type; this.data = data; this.additionalProperties = additionalProperties; } @@ -34,15 +38,15 @@ private HelpCenterList(List data, Map additionalProp * @return The type of the object - list. */ @JsonProperty("type") - public String getType() { - return "list"; + public Optional getType() { + return type; } /** * @return An array of Help Center objects */ @JsonProperty("data") - public List getData() { + public Optional> getData() { return data; } @@ -58,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(HelpCenterList other) { - return data.equals(other.data); + return type.equals(other.type) && data.equals(other.data); } @java.lang.Override public int hashCode() { - return Objects.hash(this.data); + return Objects.hash(this.type, this.data); } @java.lang.Override @@ -77,7 +81,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List data = new ArrayList<>(); + private Optional type = Optional.empty(); + + private Optional> data = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -85,32 +91,41 @@ public static final class Builder { private Builder() {} public Builder from(HelpCenterList other) { + type(other.getType()); data(other.getData()); return this; } /** - *

    An array of Help Center objects

    + *

    The type of the object - list.

    */ - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(List data) { - this.data.clear(); - this.data.addAll(data); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - public Builder addData(HelpCenter data) { - this.data.add(data); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } - public Builder addAllData(List data) { - this.data.addAll(data); + /** + *

    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(data, additionalProperties); + return new HelpCenterList(type, data, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java b/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java index ce82a33..e959ae6 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/AsyncRawHelpCentersClient.java @@ -20,6 +20,7 @@ import com.intercom.api.resources.helpcenters.requests.ListHelpCentersRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -55,13 +56,12 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/help_centers") - .addPathSegment(request.getHelpCenterId()) + .addPathSegment(Integer.toString(request.getHelpCenterId())) .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(); @@ -73,13 +73,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenter.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HelpCenter.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -96,11 +95,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -140,17 +137,16 @@ public CompletableFuture>> l .addPathSegments("help_center/help_centers"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -162,18 +158,20 @@ public CompletableFuture>> l @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { HelpCenterList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenterList.class); - int newPageNumber = - request.getPage().map(page -> page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HelpCenterList.class); + int newPageNumber = request.getPage() + .map((Integer page) -> page + 1) + .orElse(1); ListHelpCentersRequest nextRequest = ListHelpCentersRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> { + new SyncPagingIterable(true, result, parsedResponse, () -> { try { return list(nextRequest, requestOptions) .get() @@ -185,7 +183,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -195,11 +192,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java b/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java index 3c24161..ae023ce 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/RawHelpCentersClient.java @@ -20,6 +20,7 @@ import com.intercom.api.resources.helpcenters.requests.ListHelpCentersRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -49,13 +50,12 @@ public IntercomHttpResponse find(FindHelpCenterRequest request, Requ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/help_centers") - .addPathSegment(request.getHelpCenterId()) + .addPathSegment(Integer.toString(request.getHelpCenterId())) .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(); @@ -64,11 +64,11 @@ public IntercomHttpResponse find(FindHelpCenterRequest request, Requ } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenter.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HelpCenter.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -81,11 +81,9 @@ public IntercomHttpResponse find(FindHelpCenterRequest request, Requ } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -115,17 +113,16 @@ public IntercomHttpResponse> list( .addPathSegments("help_center/help_centers"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -134,21 +131,23 @@ public IntercomHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { HelpCenterList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), HelpCenterList.class); - int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HelpCenterList.class); + int newPageNumber = + request.getPage().map((Integer page) -> page + 1).orElse(1); ListHelpCentersRequest nextRequest = ListHelpCentersRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable( + true, result, parsedResponse, () -> list(nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -157,11 +156,9 @@ public IntercomHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java index af6a0db..093ff0b 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/AsyncRawCollectionsClient.java @@ -26,6 +26,7 @@ import com.intercom.api.types.DeletedCollectionObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -75,17 +76,16 @@ public CompletableFuture>> l .addPathSegments("help_center/collections"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -97,18 +97,20 @@ public CompletableFuture>> l @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { CollectionList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CollectionList.class); - int newPageNumber = - request.getPage().map(page -> page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CollectionList.class); + int newPageNumber = request.getPage() + .map((Integer page) -> page + 1) + .orElse(1); ListCollectionsRequest nextRequest = ListCollectionsRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> { + new SyncPagingIterable(true, result, parsedResponse, () -> { try { return list(nextRequest, requestOptions) .get() @@ -120,7 +122,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -130,11 +131,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -188,13 +187,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Collection.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -211,11 +209,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -245,13 +241,12 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .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(); @@ -263,13 +258,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Collection.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -286,11 +280,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -320,7 +312,7 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); RequestBody body; try { @@ -345,13 +337,12 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Collection.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -368,11 +359,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -402,13 +391,12 @@ public CompletableFuture> delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .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(); @@ -420,14 +408,13 @@ public CompletableFuture> delete( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), DeletedCollectionObject.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedCollectionObject.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -444,11 +431,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java b/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java index 8e9cee2..6a97ae9 100644 --- a/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java +++ b/src/main/java/com/intercom/api/resources/helpcenters/collections/RawCollectionsClient.java @@ -26,6 +26,7 @@ import com.intercom.api.types.DeletedCollectionObject; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Collections; import java.util.List; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -69,17 +70,16 @@ public IntercomHttpResponse> list( .addPathSegments("help_center/collections"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -88,21 +88,23 @@ public IntercomHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { CollectionList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CollectionList.class); - int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, CollectionList.class); + int newPageNumber = + request.getPage().map((Integer page) -> page + 1).orElse(1); ListCollectionsRequest nextRequest = ListCollectionsRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable( + true, result, parsedResponse, () -> list(nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -111,11 +113,9 @@ public IntercomHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -156,11 +156,11 @@ public IntercomHttpResponse create(CreateCollectionRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Collection.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -173,11 +173,9 @@ public IntercomHttpResponse create(CreateCollectionRequest request, } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -197,13 +195,12 @@ public IntercomHttpResponse find(FindCollectionRequest request, Requ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .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(); @@ -212,11 +209,11 @@ public IntercomHttpResponse find(FindCollectionRequest request, Requ } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Collection.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -229,11 +226,9 @@ public IntercomHttpResponse find(FindCollectionRequest request, Requ } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -253,7 +248,7 @@ public IntercomHttpResponse update(UpdateCollectionRequest request, HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .build(); RequestBody body; try { @@ -275,11 +270,11 @@ public IntercomHttpResponse update(UpdateCollectionRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Collection.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -292,11 +287,9 @@ public IntercomHttpResponse update(UpdateCollectionRequest request, } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -317,13 +310,12 @@ public IntercomHttpResponse delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("help_center/collections") - .addPathSegment(request.getCollectionId()) + .addPathSegment(Integer.toString(request.getCollectionId())) .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(); @@ -332,12 +324,12 @@ public IntercomHttpResponse delete( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedCollectionObject.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedCollectionObject.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -350,11 +342,9 @@ public IntercomHttpResponse delete( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 2a8dd01..7922c75 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 @@ -121,7 +121,7 @@ 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. + *

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

    */ _FinalStage name(@NotNull String name); @@ -185,7 +185,8 @@ 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.

    + *

    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 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 acfdd76..aadd1c2 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeleteCollectionRequest.Builder.class) public final class DeleteCollectionRequest { - private final String collectionId; + private final int collectionId; private final Map additionalProperties; - private DeleteCollectionRequest(String collectionId, Map additionalProperties) { + private DeleteCollectionRequest(int collectionId, Map additionalProperties) { this.collectionId = collectionId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private DeleteCollectionRequest(String collectionId, Map additio * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("collection_id") - public String getCollectionId() { + public int getCollectionId() { return collectionId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(DeleteCollectionRequest other) { - return collectionId.equals(other.collectionId); + return collectionId == other.collectionId; } @java.lang.Override @@ -67,9 +66,9 @@ public static CollectionIdStage builder() { public interface CollectionIdStage { /** - * The unique identifier for the collection which is given by Intercom. + *

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

    */ - _FinalStage collectionId(@NotNull String collectionId); + _FinalStage collectionId(int collectionId); Builder from(DeleteCollectionRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CollectionIdStage, _FinalStage { - private String collectionId; + private int collectionId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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.

    + *

    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("collection_id") - public _FinalStage collectionId(@NotNull String collectionId) { - this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + public _FinalStage collectionId(int collectionId) { + this.collectionId = collectionId; return this; } 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 bd42768..825d552 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindCollectionRequest.Builder.class) public final class FindCollectionRequest { - private final String collectionId; + private final int collectionId; private final Map additionalProperties; - private FindCollectionRequest(String collectionId, Map additionalProperties) { + private FindCollectionRequest(int collectionId, Map additionalProperties) { this.collectionId = collectionId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindCollectionRequest(String collectionId, Map additiona * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("collection_id") - public String getCollectionId() { + public int getCollectionId() { return collectionId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindCollectionRequest other) { - return collectionId.equals(other.collectionId); + return collectionId == other.collectionId; } @java.lang.Override @@ -67,9 +66,9 @@ public static CollectionIdStage builder() { public interface CollectionIdStage { /** - * The unique identifier for the collection which is given by Intercom. + *

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

    */ - _FinalStage collectionId(@NotNull String collectionId); + _FinalStage collectionId(int collectionId); Builder from(FindCollectionRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CollectionIdStage, _FinalStage { - private String collectionId; + private int collectionId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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.

    + *

    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("collection_id") - public _FinalStage collectionId(@NotNull String collectionId) { - this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + public _FinalStage collectionId(int collectionId) { + this.collectionId = collectionId; return this; } 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 965fa00..35da929 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 @@ -17,12 +17,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateCollectionRequest.Builder.class) public final class UpdateCollectionRequest { - private final String collectionId; + private final int collectionId; private final Optional name; @@ -35,7 +34,7 @@ public final class UpdateCollectionRequest { private final Map additionalProperties; private UpdateCollectionRequest( - String collectionId, + int collectionId, Optional name, Optional description, Optional translatedContent, @@ -53,7 +52,7 @@ private UpdateCollectionRequest( * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("collection_id") - public String getCollectionId() { + public int getCollectionId() { return collectionId; } @@ -98,7 +97,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(UpdateCollectionRequest other) { - return collectionId.equals(other.collectionId) + return collectionId == other.collectionId && name.equals(other.name) && description.equals(other.description) && translatedContent.equals(other.translatedContent) @@ -121,9 +120,9 @@ public static CollectionIdStage builder() { public interface CollectionIdStage { /** - * The unique identifier for the collection which is given by Intercom. + *

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

    */ - _FinalStage collectionId(@NotNull String collectionId); + _FinalStage collectionId(int collectionId); Builder from(UpdateCollectionRequest other); } @@ -159,7 +158,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements CollectionIdStage, _FinalStage { - private String collectionId; + private int collectionId; private Optional parentId = Optional.empty(); @@ -185,13 +184,14 @@ 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.

    + *

    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("collection_id") - public _FinalStage collectionId(@NotNull String collectionId) { - this.collectionId = Objects.requireNonNull(collectionId, "collectionId must not be null"); + public _FinalStage collectionId(int collectionId) { + this.collectionId = collectionId; return this; } 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 6814db5..a2c2b64 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 @@ -14,25 +14,24 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindHelpCenterRequest.Builder.class) public final class FindHelpCenterRequest { - private final String helpCenterId; + private final int helpCenterId; private final Map additionalProperties; - private FindHelpCenterRequest(String helpCenterId, Map additionalProperties) { + private FindHelpCenterRequest(int helpCenterId, Map additionalProperties) { this.helpCenterId = helpCenterId; this.additionalProperties = additionalProperties; } /** - * @return The unique identifier for the Help Center which is given by Intercom. + * @return The unique identifier for the collection which is given by Intercom. */ @JsonProperty("help_center_id") - public String getHelpCenterId() { + public int getHelpCenterId() { return helpCenterId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindHelpCenterRequest other) { - return helpCenterId.equals(other.helpCenterId); + return helpCenterId == other.helpCenterId; } @java.lang.Override @@ -67,9 +66,9 @@ public static HelpCenterIdStage builder() { public interface HelpCenterIdStage { /** - * The unique identifier for the Help Center which is given by Intercom. + *

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

    */ - _FinalStage helpCenterId(@NotNull String helpCenterId); + _FinalStage helpCenterId(int helpCenterId); Builder from(FindHelpCenterRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements HelpCenterIdStage, _FinalStage { - private String helpCenterId; + private int helpCenterId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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 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("help_center_id") - public _FinalStage helpCenterId(@NotNull String helpCenterId) { - this.helpCenterId = Objects.requireNonNull(helpCenterId, "helpCenterId must not be null"); + public _FinalStage helpCenterId(int helpCenterId) { + this.helpCenterId = helpCenterId; return this; } diff --git a/src/main/java/com/intercom/api/resources/internalarticles/AsyncInternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/AsyncInternalArticlesClient.java new file mode 100644 index 0000000..5bf7f0e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/AsyncInternalArticlesClient.java @@ -0,0 +1,141 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.InternalArticleList; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class AsyncInternalArticlesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawInternalArticlesClient rawClient; + + public AsyncInternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawInternalArticlesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawInternalArticlesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture listInternalArticles() { + return this.rawClient.listInternalArticles().thenApply(response -> response.body()); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture listInternalArticles(RequestOptions requestOptions) { + return this.rawClient.listInternalArticles(requestOptions).thenApply(response -> response.body()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture createInternalArticle() { + return this.rawClient.createInternalArticle().thenApply(response -> response.body()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture createInternalArticle( + Optional request) { + return this.rawClient.createInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture createInternalArticle( + Optional request, RequestOptions requestOptions) { + return this.rawClient.createInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture retrieveInternalArticle(RetrieveInternalArticleRequest request) { + return this.rawClient.retrieveInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture updateInternalArticle(UpdateInternalArticleRequestBody request) { + return this.rawClient.updateInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture deleteInternalArticle(DeleteInternalArticleRequest request) { + return this.rawClient.deleteInternalArticle(request).thenApply(response -> response.body()); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteInternalArticle(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture searchInternalArticles() { + return this.rawClient.searchInternalArticles().thenApply(response -> response.body()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture searchInternalArticles( + SearchInternalArticlesRequest request) { + return this.rawClient.searchInternalArticles(request).thenApply(response -> response.body()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + return this.rawClient.searchInternalArticles(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/AsyncRawInternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/AsyncRawInternalArticlesClient.java new file mode 100644 index 0000000..838eb49 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/AsyncRawInternalArticlesClient.java @@ -0,0 +1,506 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +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.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.Error; +import com.intercom.api.types.InternalArticleList; +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 AsyncRawInternalArticlesClient { + protected final ClientOptions clientOptions; + + public AsyncRawInternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> listInternalArticles() { + return listInternalArticles(null); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> listInternalArticles( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleList.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> createInternalArticle() { + return createInternalArticle(Optional.empty()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> createInternalArticle( + Optional request) { + return createInternalArticle(request, null); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public CompletableFuture> createInternalArticle( + Optional request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.isPresent()) { + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleListItem.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> retrieveInternalArticle( + RetrieveInternalArticleRequest request) { + return retrieveInternalArticle(request, null); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleListItem.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> updateInternalArticle( + UpdateInternalArticleRequestBody request) { + return updateInternalArticle(request, null); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleListItem.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> deleteInternalArticle( + DeleteInternalArticleRequest request) { + return deleteInternalArticle(request, null); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public CompletableFuture> deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, DeletedInternalArticleObject.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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 internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture> searchInternalArticles() { + return searchInternalArticles(SearchInternalArticlesRequest.builder().build()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture> searchInternalArticles( + SearchInternalArticlesRequest request) { + return searchInternalArticles(request, null); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public CompletableFuture> searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles/search"); + if (request.getFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "folder_id", request.getFolderId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, InternalArticleSearchResponse.class), + response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/internalarticles/InternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/InternalArticlesClient.java new file mode 100644 index 0000000..5eb9b9c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/InternalArticlesClient.java @@ -0,0 +1,138 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.InternalArticleList; +import java.util.Optional; + +public class InternalArticlesClient { + protected final ClientOptions clientOptions; + + private final RawInternalArticlesClient rawClient; + + public InternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawInternalArticlesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawInternalArticlesClient withRawResponse() { + return this.rawClient; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public InternalArticleList listInternalArticles() { + return this.rawClient.listInternalArticles().body(); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public InternalArticleList listInternalArticles(RequestOptions requestOptions) { + return this.rawClient.listInternalArticles(requestOptions).body(); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public InternalArticleListItem createInternalArticle() { + return this.rawClient.createInternalArticle().body(); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public InternalArticleListItem createInternalArticle(Optional request) { + return this.rawClient.createInternalArticle(request).body(); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public InternalArticleListItem createInternalArticle( + Optional request, RequestOptions requestOptions) { + return this.rawClient.createInternalArticle(request, requestOptions).body(); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem retrieveInternalArticle(RetrieveInternalArticleRequest request) { + return this.rawClient.retrieveInternalArticle(request).body(); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieveInternalArticle(request, requestOptions).body(); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem updateInternalArticle(UpdateInternalArticleRequestBody request) { + return this.rawClient.updateInternalArticle(request).body(); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public InternalArticleListItem updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + return this.rawClient.updateInternalArticle(request, requestOptions).body(); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public DeletedInternalArticleObject deleteInternalArticle(DeleteInternalArticleRequest request) { + return this.rawClient.deleteInternalArticle(request).body(); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public DeletedInternalArticleObject deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + return this.rawClient.deleteInternalArticle(request, requestOptions).body(); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public InternalArticleSearchResponse searchInternalArticles() { + return this.rawClient.searchInternalArticles().body(); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public InternalArticleSearchResponse searchInternalArticles(SearchInternalArticlesRequest request) { + return this.rawClient.searchInternalArticles(request).body(); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public InternalArticleSearchResponse searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + return this.rawClient.searchInternalArticles(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/RawInternalArticlesClient.java b/src/main/java/com/intercom/api/resources/internalarticles/RawInternalArticlesClient.java new file mode 100644 index 0000000..14aaa7a --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/RawInternalArticlesClient.java @@ -0,0 +1,402 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles; + +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.errors.BadRequestError; +import com.intercom.api.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.internalarticles.requests.DeleteInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.RetrieveInternalArticleRequest; +import com.intercom.api.resources.internalarticles.requests.SearchInternalArticlesRequest; +import com.intercom.api.resources.internalarticles.requests.UpdateInternalArticleRequestBody; +import com.intercom.api.resources.internalarticles.types.InternalArticleListItem; +import com.intercom.api.resources.internalarticles.types.InternalArticleSearchResponse; +import com.intercom.api.types.CreateInternalArticleRequest; +import com.intercom.api.types.DeletedInternalArticleObject; +import com.intercom.api.types.Error; +import com.intercom.api.types.InternalArticleList; +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 RawInternalArticlesClient { + protected final ClientOptions clientOptions; + + public RawInternalArticlesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse listInternalArticles() { + return listInternalArticles(null); + } + + /** + * You can fetch a list of all internal articles by making a GET request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse listInternalArticles(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleList.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse createInternalArticle() { + return createInternalArticle(Optional.empty()); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse createInternalArticle( + Optional request) { + return createInternalArticle(request, null); + } + + /** + * You can create a new internal article by making a POST request to https://api.intercom.io/internal_articles. + */ + public IntercomHttpResponse createInternalArticle( + Optional request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .build(); + RequestBody body; + try { + body = RequestBody.create("", null); + if (request.isPresent()) { + 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleListItem.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse retrieveInternalArticle( + RetrieveInternalArticleRequest request) { + return retrieveInternalArticle(request, null); + } + + /** + * You can fetch the details of a single internal article by making a GET request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse retrieveInternalArticle( + RetrieveInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleListItem.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse updateInternalArticle( + UpdateInternalArticleRequestBody request) { + return updateInternalArticle(request, null); + } + + /** + * You can update the details of a single internal article by making a PUT request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse updateInternalArticle( + UpdateInternalArticleRequestBody request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleListItem.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse deleteInternalArticle( + DeleteInternalArticleRequest request) { + return deleteInternalArticle(request, null); + } + + /** + * You can delete a single internal article by making a DELETE request to https://api.intercom.io/internal_articles/<id>. + */ + public IntercomHttpResponse deleteInternalArticle( + DeleteInternalArticleRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles") + .addPathSegment(Integer.toString(request.getInternalArticleId())) + .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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedInternalArticleObject.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public IntercomHttpResponse searchInternalArticles() { + return searchInternalArticles(SearchInternalArticlesRequest.builder().build()); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public IntercomHttpResponse searchInternalArticles( + SearchInternalArticlesRequest request) { + return searchInternalArticles(request, null); + } + + /** + * You can search for internal articles by making a GET request to https://api.intercom.io/internal_articles/search. + */ + public IntercomHttpResponse searchInternalArticles( + SearchInternalArticlesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("internal_articles/search"); + if (request.getFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "folder_id", request.getFolderId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, InternalArticleSearchResponse.class), + response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/requests/DeleteInternalArticleRequest.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/DeleteInternalArticleRequest.java new file mode 100644 index 0000000..2c15d0e --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/DeleteInternalArticleRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.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 = DeleteInternalArticleRequest.Builder.class) +public final class DeleteInternalArticleRequest { + private final int internalArticleId; + + private final Map additionalProperties; + + private DeleteInternalArticleRequest(int internalArticleId, Map additionalProperties) { + this.internalArticleId = internalArticleId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the internal article which is given by Intercom. + */ + @JsonProperty("internal_article_id") + public int getInternalArticleId() { + return internalArticleId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeleteInternalArticleRequest && equalTo((DeleteInternalArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DeleteInternalArticleRequest other) { + return internalArticleId == other.internalArticleId; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticleId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InternalArticleIdStage builder() { + return new Builder(); + } + + public interface InternalArticleIdStage { + /** + *

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

    + */ + _FinalStage internalArticleId(int internalArticleId); + + Builder from(DeleteInternalArticleRequest other); + } + + public interface _FinalStage { + DeleteInternalArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements InternalArticleIdStage, _FinalStage { + private int internalArticleId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteInternalArticleRequest other) { + internalArticleId(other.getInternalArticleId()); + return this; + } + + /** + *

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

    + *

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

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("internal_article_id") + public _FinalStage internalArticleId(int internalArticleId) { + this.internalArticleId = internalArticleId; + return this; + } + + @java.lang.Override + public DeleteInternalArticleRequest build() { + return new DeleteInternalArticleRequest(internalArticleId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/requests/RetrieveInternalArticleRequest.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/RetrieveInternalArticleRequest.java new file mode 100644 index 0000000..4bc56b4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/RetrieveInternalArticleRequest.java @@ -0,0 +1,112 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.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 = RetrieveInternalArticleRequest.Builder.class) +public final class RetrieveInternalArticleRequest { + private final int internalArticleId; + + private final Map additionalProperties; + + private RetrieveInternalArticleRequest(int internalArticleId, Map additionalProperties) { + this.internalArticleId = internalArticleId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the article which is given by Intercom. + */ + @JsonProperty("internal_article_id") + public int getInternalArticleId() { + return internalArticleId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RetrieveInternalArticleRequest && equalTo((RetrieveInternalArticleRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(RetrieveInternalArticleRequest other) { + return internalArticleId == other.internalArticleId; + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticleId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InternalArticleIdStage builder() { + return new Builder(); + } + + public interface InternalArticleIdStage { + /** + *

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

    + */ + _FinalStage internalArticleId(int internalArticleId); + + Builder from(RetrieveInternalArticleRequest other); + } + + public interface _FinalStage { + RetrieveInternalArticleRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements InternalArticleIdStage, _FinalStage { + private int internalArticleId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(RetrieveInternalArticleRequest other) { + internalArticleId(other.getInternalArticleId()); + 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("internal_article_id") + public _FinalStage internalArticleId(int internalArticleId) { + this.internalArticleId = internalArticleId; + return this; + } + + @java.lang.Override + public RetrieveInternalArticleRequest build() { + return new RetrieveInternalArticleRequest(internalArticleId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/types/DataTableComponent.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/SearchInternalArticlesRequest.java similarity index 52% rename from src/main/java/com/intercom/api/types/DataTableComponent.java rename to src/main/java/com/intercom/api/resources/internalarticles/requests/SearchInternalArticlesRequest.java index 17248fc..ce6c476 100644 --- a/src/main/java/com/intercom/api/types/DataTableComponent.java +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/SearchInternalArticlesRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.internalarticles.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -12,36 +12,35 @@ 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 java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DataTableComponent.Builder.class) -public final class DataTableComponent { - private final List items; +@JsonDeserialize(builder = SearchInternalArticlesRequest.Builder.class) +public final class SearchInternalArticlesRequest { + private final Optional folderId; private final Map additionalProperties; - private DataTableComponent(List items, Map additionalProperties) { - this.items = items; + private SearchInternalArticlesRequest(Optional folderId, Map additionalProperties) { + this.folderId = folderId; this.additionalProperties = additionalProperties; } /** - * @return The items that will be rendered in the data-table. + * @return The ID of the folder to search in. */ - @JsonProperty("items") - public List getItems() { - return items; + @JsonProperty("folder_id") + public Optional getFolderId() { + return folderId; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DataTableComponent && equalTo((DataTableComponent) other); + return other instanceof SearchInternalArticlesRequest && equalTo((SearchInternalArticlesRequest) other); } @JsonAnyGetter @@ -49,13 +48,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DataTableComponent other) { - return items.equals(other.items); + private boolean equalTo(SearchInternalArticlesRequest other) { + return folderId.equals(other.folderId); } @java.lang.Override public int hashCode() { - return Objects.hash(this.items); + return Objects.hash(this.folderId); } @java.lang.Override @@ -69,40 +68,34 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List items = new ArrayList<>(); + private Optional folderId = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(DataTableComponent other) { - items(other.getItems()); + public Builder from(SearchInternalArticlesRequest other) { + folderId(other.getFolderId()); return this; } /** - *

    The items that will be rendered in the data-table.

    + *

    The ID of the folder to search in.

    */ - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public Builder items(List items) { - this.items.clear(); - this.items.addAll(items); + @JsonSetter(value = "folder_id", nulls = Nulls.SKIP) + public Builder folderId(Optional folderId) { + this.folderId = folderId; return this; } - public Builder addItems(DataTableItem items) { - this.items.add(items); + public Builder folderId(String folderId) { + this.folderId = Optional.ofNullable(folderId); return this; } - public Builder addAllItems(List items) { - this.items.addAll(items); - return this; - } - - public DataTableComponent build() { - return new DataTableComponent(items, additionalProperties); + public SearchInternalArticlesRequest build() { + return new SearchInternalArticlesRequest(folderId, additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/internalarticles/requests/UpdateInternalArticleRequestBody.java b/src/main/java/com/intercom/api/resources/internalarticles/requests/UpdateInternalArticleRequestBody.java new file mode 100644 index 0000000..1040dd8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/requests/UpdateInternalArticleRequestBody.java @@ -0,0 +1,289 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.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 = UpdateInternalArticleRequestBody.Builder.class) +public final class UpdateInternalArticleRequestBody { + private final int internalArticleId; + + private final Optional title; + + private final Optional body; + + private final Optional authorId; + + private final Optional ownerId; + + private final Map additionalProperties; + + private UpdateInternalArticleRequestBody( + int internalArticleId, + Optional title, + Optional body, + Optional authorId, + Optional ownerId, + Map additionalProperties) { + this.internalArticleId = internalArticleId; + this.title = title; + this.body = body; + this.authorId = authorId; + this.ownerId = ownerId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the internal article which is given by Intercom. + */ + @JsonProperty("internal_article_id") + public int getInternalArticleId() { + return internalArticleId; + } + + /** + * @return The title of the article. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The content of the article. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the author of the article. + */ + @JsonProperty("author_id") + public Optional getAuthorId() { + return authorId; + } + + /** + * @return The id of the author of the article. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UpdateInternalArticleRequestBody && equalTo((UpdateInternalArticleRequestBody) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(UpdateInternalArticleRequestBody other) { + return internalArticleId == other.internalArticleId + && title.equals(other.title) + && body.equals(other.body) + && authorId.equals(other.authorId) + && ownerId.equals(other.ownerId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticleId, this.title, this.body, this.authorId, this.ownerId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static InternalArticleIdStage builder() { + return new Builder(); + } + + public interface InternalArticleIdStage { + /** + *

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

    + */ + _FinalStage internalArticleId(int internalArticleId); + + Builder from(UpdateInternalArticleRequestBody other); + } + + public interface _FinalStage { + UpdateInternalArticleRequestBody build(); + + /** + *

    The title of the article.

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

    The content of the article.

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

    The id of the author of the article.

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

    The id of the author of the article.

    + */ + _FinalStage ownerId(Optional ownerId); + + _FinalStage ownerId(Integer ownerId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements InternalArticleIdStage, _FinalStage { + private int internalArticleId; + + private Optional ownerId = Optional.empty(); + + private Optional authorId = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional title = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(UpdateInternalArticleRequestBody other) { + internalArticleId(other.getInternalArticleId()); + title(other.getTitle()); + body(other.getBody()); + authorId(other.getAuthorId()); + ownerId(other.getOwnerId()); + return this; + } + + /** + *

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

    + *

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

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("internal_article_id") + public _FinalStage internalArticleId(int internalArticleId) { + this.internalArticleId = internalArticleId; + return this; + } + + /** + *

    The id of the author of the article.

    + * @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 the author of the article.

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

    The id of the author of the article.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage authorId(Integer authorId) { + this.authorId = Optional.ofNullable(authorId); + return this; + } + + /** + *

    The id of the author of the article.

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

    The content of the article.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage body(String body) { + this.body = Optional.ofNullable(body); + return this; + } + + /** + *

    The content of the article.

    + */ + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Optional body) { + this.body = body; + return this; + } + + /** + *

    The title of the article.

    + * @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 of the article.

    + */ + @java.lang.Override + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public _FinalStage title(Optional title) { + this.title = title; + return this; + } + + @java.lang.Override + public UpdateInternalArticleRequestBody build() { + return new UpdateInternalArticleRequestBody( + internalArticleId, title, body, authorId, ownerId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleListItem.java b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleListItem.java new file mode 100644 index 0000000..e08b939 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleListItem.java @@ -0,0 +1,353 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.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 = InternalArticleListItem.Builder.class) +public final class InternalArticleListItem { + private final Optional type; + + private final Optional id; + + private final Optional title; + + private final Optional body; + + private final Optional ownerId; + + private final Optional authorId; + + private final Optional createdAt; + + private final Optional updatedAt; + + private final Optional locale; + + private final Map additionalProperties; + + private InternalArticleListItem( + Optional type, + Optional id, + Optional title, + Optional body, + Optional ownerId, + Optional authorId, + Optional createdAt, + Optional updatedAt, + Optional locale, + Map additionalProperties) { + this.type = type; + this.id = id; + this.title = title; + this.body = body; + this.ownerId = ownerId; + this.authorId = authorId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.locale = locale; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of object - internal_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 title of the article. + */ + @JsonProperty("title") + public Optional getTitle() { + return title; + } + + /** + * @return The body of the article in HTML. + */ + @JsonProperty("body") + public Optional getBody() { + return body; + } + + /** + * @return The id of the owner of the article. + */ + @JsonProperty("owner_id") + public Optional getOwnerId() { + return ownerId; + } + + /** + * @return The id of the author of the article. + */ + @JsonProperty("author_id") + public Optional getAuthorId() { + return authorId; + } + + /** + * @return The time when the article was created. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The time when the article was last updated. + */ + @JsonProperty("updated_at") + public Optional getUpdatedAt() { + return updatedAt; + } + + /** + * @return The default locale of the article. + */ + @JsonProperty("locale") + public Optional getLocale() { + return locale; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InternalArticleListItem && equalTo((InternalArticleListItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InternalArticleListItem other) { + return type.equals(other.type) + && id.equals(other.id) + && title.equals(other.title) + && body.equals(other.body) + && ownerId.equals(other.ownerId) + && authorId.equals(other.authorId) + && createdAt.equals(other.createdAt) + && updatedAt.equals(other.updatedAt) + && locale.equals(other.locale); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.type, + this.id, + this.title, + this.body, + this.ownerId, + this.authorId, + this.createdAt, + this.updatedAt, + 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 type = Optional.empty(); + + private Optional id = Optional.empty(); + + private Optional title = Optional.empty(); + + private Optional body = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional authorId = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional updatedAt = Optional.empty(); + + private Optional locale = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(InternalArticleListItem other) { + type(other.getType()); + id(other.getId()); + title(other.getTitle()); + body(other.getBody()); + ownerId(other.getOwnerId()); + authorId(other.getAuthorId()); + createdAt(other.getCreatedAt()); + updatedAt(other.getUpdatedAt()); + locale(other.getLocale()); + return this; + } + + /** + *

    The type of object - internal_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 title of the article.

    + */ + @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 body of the article in 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 owner of the article.

    + */ + @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; + } + + /** + *

    The id of the author of the article.

    + */ + @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; + } + + /** + *

    The time when the article 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 article 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 default locale of the article.

    + */ + @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 InternalArticleListItem build() { + return new InternalArticleListItem( + type, id, title, body, ownerId, authorId, createdAt, updatedAt, locale, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleSearchResponse.java b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleSearchResponse.java new file mode 100644 index 0000000..7bf51bd --- /dev/null +++ b/src/main/java/com/intercom/api/resources/internalarticles/types/InternalArticleSearchResponse.java @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.internalarticles.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.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 = InternalArticleSearchResponse.Builder.class) +public final class InternalArticleSearchResponse { + private final Optional type; + + private final Optional totalCount; + + private final Optional data; + + private final Optional pages; + + private final Map additionalProperties; + + private InternalArticleSearchResponse( + 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 Internal 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 InternalArticleSearchResponse && equalTo((InternalArticleSearchResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(InternalArticleSearchResponse 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(InternalArticleSearchResponse 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 Internal 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 InternalArticleSearchResponse build() { + return new InternalArticleSearchResponse(type, totalCount, data, pages, additionalProperties); + } + } + + @JsonInclude(JsonInclude.Include.NON_ABSENT) + @JsonDeserialize(builder = Data.Builder.class) + public static final class Data { + private final Optional> internalArticles; + + private final Map additionalProperties; + + private Data( + Optional> internalArticles, Map additionalProperties) { + this.internalArticles = internalArticles; + this.additionalProperties = additionalProperties; + } + + /** + * @return An array of Internal Article objects + */ + @JsonProperty("internal_articles") + public Optional> getInternalArticles() { + return internalArticles; + } + + @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 internalArticles.equals(other.internalArticles); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.internalArticles); + } + + @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> internalArticles = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(Data other) { + internalArticles(other.getInternalArticles()); + return this; + } + + /** + *

    An array of Internal Article objects

    + */ + @JsonSetter(value = "internal_articles", nulls = Nulls.SKIP) + public Builder internalArticles(Optional> internalArticles) { + this.internalArticles = internalArticles; + return this; + } + + public Builder internalArticles(List internalArticles) { + this.internalArticles = Optional.ofNullable(internalArticles); + return this; + } + + public Data build() { + return new Data(internalArticles, additionalProperties); + } + } + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/AsyncJobsClient.java b/src/main/java/com/intercom/api/resources/jobs/AsyncJobsClient.java new file mode 100644 index 0000000..093d4fc --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/AsyncJobsClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.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/jobs/AsyncRawJobsClient.java b/src/main/java/com/intercom/api/resources/jobs/AsyncRawJobsClient.java new file mode 100644 index 0000000..acdcb2c --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/AsyncRawJobsClient.java @@ -0,0 +1,107 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.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.getJobId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Jobs.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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/jobs/JobsClient.java b/src/main/java/com/intercom/api/resources/jobs/JobsClient.java new file mode 100644 index 0000000..23576e4 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/JobsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.jobs; + +import com.intercom.api.core.ClientOptions; +import com.intercom.api.core.RequestOptions; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.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/jobs/RawJobsClient.java b/src/main/java/com/intercom/api/resources/jobs/RawJobsClient.java new file mode 100644 index 0000000..4b77ef8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/RawJobsClient.java @@ -0,0 +1,85 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.errors.NotFoundError; +import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.requests.JobsStatusRequest; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.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.getJobId()) + .build(); + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl) + .method("GET", 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Jobs.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new IntercomException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/requests/JobsStatusRequest.java b/src/main/java/com/intercom/api/resources/jobs/requests/JobsStatusRequest.java new file mode 100644 index 0000000..acacfaa --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/requests/JobsStatusRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 jobId; + + private final Map additionalProperties; + + private JobsStatusRequest(String jobId, Map additionalProperties) { + this.jobId = jobId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the job which is given by Intercom + */ + @JsonProperty("job_id") + public String getJobId() { + return jobId; + } + + @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 jobId.equals(other.jobId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.jobId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static JobIdStage builder() { + return new Builder(); + } + + public interface JobIdStage { + /** + *

    The unique identifier for the job which is given by Intercom

    + */ + _FinalStage jobId(@NotNull String jobId); + + Builder from(JobsStatusRequest other); + } + + public interface _FinalStage { + JobsStatusRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements JobIdStage, _FinalStage { + private String jobId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(JobsStatusRequest other) { + jobId(other.getJobId()); + 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("job_id") + public _FinalStage jobId(@NotNull String jobId) { + this.jobId = Objects.requireNonNull(jobId, "jobId must not be null"); + return this; + } + + @java.lang.Override + public JobsStatusRequest build() { + return new JobsStatusRequest(jobId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/jobs/types/Jobs.java b/src/main/java/com/intercom/api/resources/jobs/types/Jobs.java new file mode 100644 index 0000000..06ef5c8 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/jobs/types/Jobs.java @@ -0,0 +1,463 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/messages/AsyncMessagesClient.java b/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java index a0940a6..468fc47 100644 --- a/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/AsyncMessagesClient.java @@ -7,6 +7,7 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.types.CreateMessageRequest; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncMessagesClient { @@ -38,7 +39,23 @@ public AsyncRawMessagesClient withRawResponse() { *

    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 create(CreateMessageRequest request) { + public CompletableFuture create() { + return this.rawClient.create().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 or an email. + *
    + *

    🚧 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 create(Optional request) { return this.rawClient.create(request).thenApply(response -> response.body()); } @@ -54,7 +71,7 @@ public CompletableFuture create(CreateMessageRequest request) { *

    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 create(CreateMessageRequest request, RequestOptions requestOptions) { + public CompletableFuture create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java b/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java index 30cc313..aad8cf0 100644 --- a/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/AsyncRawMessagesClient.java @@ -19,6 +19,7 @@ import com.intercom.api.types.CreateMessageRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -50,7 +51,23 @@ public AsyncRawMessagesClient(ClientOptions clientOptions) { *

    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> create(CreateMessageRequest request) { + public CompletableFuture> create() { + return create(Optional.empty()); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + *
    + *

    🚧 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> create(Optional request) { return create(request, null); } @@ -67,15 +84,18 @@ public CompletableFuture> create(CreateMessageRequ * */ public CompletableFuture> create( - CreateMessageRequest request, RequestOptions requestOptions) { + Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -95,12 +115,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Message.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -127,11 +147,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/messages/MessagesClient.java b/src/main/java/com/intercom/api/resources/messages/MessagesClient.java index 002bd34..afbd3d1 100644 --- a/src/main/java/com/intercom/api/resources/messages/MessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/MessagesClient.java @@ -7,6 +7,7 @@ import com.intercom.api.core.RequestOptions; import com.intercom.api.resources.messages.types.Message; import com.intercom.api.types.CreateMessageRequest; +import java.util.Optional; public class MessagesClient { protected final ClientOptions clientOptions; @@ -37,7 +38,23 @@ public RawMessagesClient withRawResponse() { *

    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 create(CreateMessageRequest request) { + public Message create() { + return this.rawClient.create().body(); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + *
    + *

    🚧 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 create(Optional request) { return this.rawClient.create(request).body(); } @@ -53,7 +70,7 @@ public Message create(CreateMessageRequest request) { *

    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 create(CreateMessageRequest request, RequestOptions requestOptions) { + public Message create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java b/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java index feb1e76..067aad9 100644 --- a/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java +++ b/src/main/java/com/intercom/api/resources/messages/RawMessagesClient.java @@ -19,6 +19,7 @@ import com.intercom.api.types.CreateMessageRequest; import com.intercom.api.types.Error; import java.io.IOException; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -46,7 +47,23 @@ public RawMessagesClient(ClientOptions clientOptions) { *

    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 create(CreateMessageRequest request) { + public IntercomHttpResponse create() { + return create(Optional.empty()); + } + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. + *
    + *

    🚧 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 create(Optional request) { return create(request, null); } @@ -62,15 +79,18 @@ public IntercomHttpResponse create(CreateMessageRequest request) { *

    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 create(CreateMessageRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse create(Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -87,11 +107,11 @@ public IntercomHttpResponse create(CreateMessageRequest request, Reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Message.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Message.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -110,11 +130,9 @@ public IntercomHttpResponse create(CreateMessageRequest request, Reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 2ad8f7d..face520 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 @@ -11,11 +11,13 @@ 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) @@ -27,13 +29,13 @@ public final class Message { private final int createdAt; - private final String subject; + private final Optional subject; private final String body; private final MessageType messageType; - private final String conversationId; + private final Optional conversationId; private final Map additionalProperties; @@ -41,10 +43,10 @@ private Message( String type, String id, int createdAt, - String subject, + Optional subject, String body, MessageType messageType, - String conversationId, + Optional conversationId, Map additionalProperties) { this.type = type; this.id = id; @@ -84,7 +86,7 @@ public int getCreatedAt() { * @return The subject of the message. Only present if message_type: email. */ @JsonProperty("subject") - public String getSubject() { + public Optional getSubject() { return subject; } @@ -108,7 +110,7 @@ public MessageType getMessageType() { * @return The associated conversation_id */ @JsonProperty("conversation_id") - public String getConversationId() { + public Optional getConversationId() { return conversationId; } @@ -150,7 +152,7 @@ public static TypeStage builder() { public interface TypeStage { /** - * The type of the message + *

    The type of the message

    */ IdStage type(@NotNull String type); @@ -159,73 +161,66 @@ public interface TypeStage { public interface IdStage { /** - * The id representing the message. + *

    The id representing the message.

    */ CreatedAtStage id(@NotNull String id); } public interface CreatedAtStage { /** - * The time the conversation was created. + *

    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); + BodyStage createdAt(int createdAt); } public interface BodyStage { /** - * The message body, which may contain HTML. + *

    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. + *

    The type of message that was sent. Can be email, inapp, facebook or twitter.

    */ - ConversationIdStage messageType(@NotNull MessageType messageType); + _FinalStage messageType(@NotNull MessageType messageType); } - public interface ConversationIdStage { + public interface _FinalStage { + Message build(); + /** - * The associated conversation_id + *

    The subject of the message. Only present if message_type: email.

    */ - _FinalStage conversationId(@NotNull String conversationId); - } + _FinalStage subject(Optional subject); - public interface _FinalStage { - Message build(); + _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, - SubjectStage, - BodyStage, - MessageTypeStage, - ConversationIdStage, - _FinalStage { + implements TypeStage, IdStage, CreatedAtStage, BodyStage, MessageTypeStage, _FinalStage { private String type; private String id; private int createdAt; - private String subject; - private String body; private MessageType messageType; - private String conversationId; + private Optional conversationId = Optional.empty(); + + private Optional subject = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -245,7 +240,8 @@ public Builder from(Message other) { } /** - * The type of the message

    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 @@ -256,7 +252,8 @@ public IdStage type(@NotNull String type) { } /** - * The id representing the message.

    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 @@ -267,57 +264,78 @@ public CreatedAtStage id(@NotNull String id) { } /** - * The time the conversation was created.

    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 @JsonSetter("created_at") - public SubjectStage createdAt(int createdAt) { + public BodyStage createdAt(int createdAt) { this.createdAt = createdAt; return this; } /** - * The subject of the message. Only present if message_type: email.

    The subject of the message. Only present if message_type: email.

    + *

    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("subject") - public BodyStage subject(@NotNull String subject) { - this.subject = Objects.requireNonNull(subject, "subject must not be null"); + @JsonSetter("body") + public MessageTypeStage body(@NotNull String body) { + this.body = Objects.requireNonNull(body, "body must not be null"); return this; } /** - * The message body, which may contain HTML.

    The message body, which may contain HTML.

    + *

    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 - @JsonSetter("body") - public MessageTypeStage body(@NotNull String body) { - this.body = Objects.requireNonNull(body, "body must not be null"); + @JsonSetter("message_type") + public _FinalStage messageType(@NotNull MessageType messageType) { + this.messageType = Objects.requireNonNull(messageType, "messageType must not be null"); return this; } /** - * 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 associated conversation_id

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("message_type") - public ConversationIdStage messageType(@NotNull MessageType messageType) { - this.messageType = Objects.requireNonNull(messageType, "messageType must not be null"); + public _FinalStage conversationId(String conversationId) { + this.conversationId = Optional.ofNullable(conversationId); return this; } /** - * The associated conversation_id

    The associated conversation_id

    + *

    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 - @JsonSetter("conversation_id") - public _FinalStage conversationId(@NotNull String conversationId) { - this.conversationId = Objects.requireNonNull(conversationId, "conversationId must not be null"); + 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; } diff --git a/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java index 90b558b..c5557e4 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/AsyncFeedsClient.java @@ -8,8 +8,7 @@ import com.intercom.api.resources.news.feeds.requests.FindNewsFeedRequest; import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; import java.util.concurrent.CompletableFuture; public class AsyncFeedsClient { @@ -32,14 +31,14 @@ public AsyncRawFeedsClient withRawResponse() { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture listItems(ListNewsFeedItemsRequest request) { + public CompletableFuture listItems(ListNewsFeedItemsRequest request) { return this.rawClient.listItems(request).thenApply(response -> response.body()); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture listItems( + public CompletableFuture listItems( ListNewsFeedItemsRequest request, RequestOptions requestOptions) { return this.rawClient.listItems(request, requestOptions).thenApply(response -> response.body()); } @@ -47,14 +46,14 @@ public CompletableFuture listItems( /** * You can fetch a list of all newsfeeds */ - public CompletableFuture list() { + public CompletableFuture list() { return this.rawClient.list().thenApply(response -> response.body()); } /** * You can fetch a list of all newsfeeds */ - public CompletableFuture list(RequestOptions requestOptions) { + public CompletableFuture list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java index 9bb5511..bb5aa28 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/AsyncRawFeedsClient.java @@ -15,8 +15,7 @@ import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -39,15 +38,14 @@ public AsyncRawFeedsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture> listItems( - ListNewsFeedItemsRequest request) { + public CompletableFuture> listItems(ListNewsFeedItemsRequest request) { return listItems(request, null); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public CompletableFuture> listItems( + public CompletableFuture> listItems( ListNewsFeedItemsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -59,26 +57,24 @@ public CompletableFuture> listIt .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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedNewsItemResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PaginatedResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -88,11 +84,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -110,14 +104,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can fetch a list of all newsfeeds */ - public CompletableFuture> list() { + public CompletableFuture> list() { return list(null); } /** * You can fetch a list of all newsfeeds */ - public CompletableFuture> list(RequestOptions requestOptions) { + public CompletableFuture> list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/newsfeeds") @@ -126,26 +120,24 @@ public CompletableFuture> list(R .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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedNewsfeedResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PaginatedResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -155,11 +147,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -195,7 +185,6 @@ public CompletableFuture> find( .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(); @@ -207,12 +196,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Newsfeed.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Newsfeed.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -222,11 +211,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java index 895cf2f..9de0753 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/FeedsClient.java @@ -8,8 +8,7 @@ import com.intercom.api.resources.news.feeds.requests.FindNewsFeedRequest; import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; public class FeedsClient { protected final ClientOptions clientOptions; @@ -31,28 +30,28 @@ public RawFeedsClient withRawResponse() { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public PaginatedNewsItemResponse listItems(ListNewsFeedItemsRequest request) { + public PaginatedResponse listItems(ListNewsFeedItemsRequest request) { return this.rawClient.listItems(request).body(); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public PaginatedNewsItemResponse listItems(ListNewsFeedItemsRequest request, RequestOptions requestOptions) { + public PaginatedResponse listItems(ListNewsFeedItemsRequest request, RequestOptions requestOptions) { return this.rawClient.listItems(request, requestOptions).body(); } /** * You can fetch a list of all newsfeeds */ - public PaginatedNewsfeedResponse list() { + public PaginatedResponse list() { return this.rawClient.list().body(); } /** * You can fetch a list of all newsfeeds */ - public PaginatedNewsfeedResponse list(RequestOptions requestOptions) { + public PaginatedResponse list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).body(); } diff --git a/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java b/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java index b297ee9..c908a52 100644 --- a/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java +++ b/src/main/java/com/intercom/api/resources/news/feeds/RawFeedsClient.java @@ -15,8 +15,7 @@ import com.intercom.api.resources.news.feeds.requests.ListNewsFeedItemsRequest; import com.intercom.api.resources.news.types.Newsfeed; import com.intercom.api.types.Error; -import com.intercom.api.types.PaginatedNewsItemResponse; -import com.intercom.api.types.PaginatedNewsfeedResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -35,14 +34,14 @@ public RawFeedsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items that are live on a given newsfeed */ - public IntercomHttpResponse listItems(ListNewsFeedItemsRequest request) { + public IntercomHttpResponse listItems(ListNewsFeedItemsRequest request) { return listItems(request, null); } /** * You can fetch a list of all news items that are live on a given newsfeed */ - public IntercomHttpResponse listItems( + public IntercomHttpResponse listItems( ListNewsFeedItemsRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -54,7 +53,6 @@ public IntercomHttpResponse listItems( .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(); @@ -63,12 +61,11 @@ public IntercomHttpResponse listItems( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsItemResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PaginatedResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -77,11 +74,9 @@ public IntercomHttpResponse listItems( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -90,14 +85,14 @@ public IntercomHttpResponse listItems( /** * You can fetch a list of all newsfeeds */ - public IntercomHttpResponse list() { + public IntercomHttpResponse list() { return list(null); } /** * You can fetch a list of all newsfeeds */ - public IntercomHttpResponse list(RequestOptions requestOptions) { + public IntercomHttpResponse list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/newsfeeds") @@ -106,7 +101,6 @@ public IntercomHttpResponse list(RequestOptions reque .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(); @@ -115,12 +109,11 @@ public IntercomHttpResponse list(RequestOptions reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsfeedResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PaginatedResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -129,11 +122,9 @@ public IntercomHttpResponse list(RequestOptions reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -159,7 +150,6 @@ public IntercomHttpResponse find(FindNewsFeedRequest request, RequestO .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(); @@ -168,11 +158,11 @@ public IntercomHttpResponse find(FindNewsFeedRequest request, RequestO } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Newsfeed.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Newsfeed.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -181,11 +171,9 @@ public IntercomHttpResponse find(FindNewsFeedRequest request, RequestO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 b2c1f9a..36c7f2b 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 @@ -67,7 +67,7 @@ public static NewsfeedIdStage builder() { public interface NewsfeedIdStage { /** - * 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.

    */ _FinalStage newsfeedId(@NotNull String newsfeedId); @@ -94,7 +94,8 @@ 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.

    + *

    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 4e67013..9e5e582 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 @@ -67,7 +67,7 @@ public static NewsfeedIdStage builder() { public interface NewsfeedIdStage { /** - * 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.

    */ _FinalStage newsfeedId(@NotNull String newsfeedId); @@ -94,7 +94,8 @@ 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.

    + *

    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/AsyncItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java index c4826f4..f540d56 100644 --- a/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/AsyncItemsClient.java @@ -11,7 +11,7 @@ import com.intercom.api.resources.news.types.NewsItem; import com.intercom.api.types.DeletedObject; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; import java.util.concurrent.CompletableFuture; public class AsyncItemsClient { @@ -34,14 +34,14 @@ public AsyncRawItemsClient withRawResponse() { /** * You can fetch a list of all news items */ - public CompletableFuture list() { + public CompletableFuture list() { return this.rawClient.list().thenApply(response -> response.body()); } /** * You can fetch a list of all news items */ - public CompletableFuture list(RequestOptions requestOptions) { + public CompletableFuture list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).thenApply(response -> response.body()); } diff --git a/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java index 4386306..7a94590 100644 --- a/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/AsyncRawItemsClient.java @@ -20,7 +20,7 @@ import com.intercom.api.types.DeletedObject; import com.intercom.api.types.Error; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import java.util.concurrent.CompletableFuture; import okhttp3.Call; @@ -44,14 +44,14 @@ public AsyncRawItemsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items */ - public CompletableFuture> list() { + public CompletableFuture> list() { return list(null); } /** * You can fetch a list of all news items */ - public CompletableFuture> list(RequestOptions requestOptions) { + public CompletableFuture> list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") @@ -60,26 +60,24 @@ public CompletableFuture> list(R .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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedNewsItemResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PaginatedResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -89,11 +87,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -147,12 +143,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NewsItem.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -162,11 +158,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -196,13 +190,12 @@ public CompletableFuture> find( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .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(); @@ -214,12 +207,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NewsItem.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -236,11 +229,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -264,7 +255,7 @@ public CompletableFuture> update( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); RequestBody body; try { @@ -289,12 +280,12 @@ public CompletableFuture> update( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NewsItem.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -311,11 +302,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -345,13 +334,12 @@ public CompletableFuture> delete( HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .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(); @@ -363,13 +351,13 @@ public CompletableFuture> delete( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedObject.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedObject.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -386,11 +374,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java index 6c02302..cd7caa8 100644 --- a/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/ItemsClient.java @@ -11,7 +11,7 @@ import com.intercom.api.resources.news.types.NewsItem; import com.intercom.api.types.DeletedObject; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; public class ItemsClient { protected final ClientOptions clientOptions; @@ -33,14 +33,14 @@ public RawItemsClient withRawResponse() { /** * You can fetch a list of all news items */ - public PaginatedNewsItemResponse list() { + public PaginatedResponse list() { return this.rawClient.list().body(); } /** * You can fetch a list of all news items */ - public PaginatedNewsItemResponse list(RequestOptions requestOptions) { + public PaginatedResponse list(RequestOptions requestOptions) { return this.rawClient.list(requestOptions).body(); } diff --git a/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java b/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java index 84644ce..3c01a52 100644 --- a/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java +++ b/src/main/java/com/intercom/api/resources/news/items/RawItemsClient.java @@ -20,7 +20,7 @@ import com.intercom.api.types.DeletedObject; import com.intercom.api.types.Error; import com.intercom.api.types.NewsItemRequest; -import com.intercom.api.types.PaginatedNewsItemResponse; +import com.intercom.api.types.PaginatedResponse; import java.io.IOException; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -40,14 +40,14 @@ public RawItemsClient(ClientOptions clientOptions) { /** * You can fetch a list of all news items */ - public IntercomHttpResponse list() { + public IntercomHttpResponse list() { return list(null); } /** * You can fetch a list of all news items */ - public IntercomHttpResponse list(RequestOptions requestOptions) { + public IntercomHttpResponse list(RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") @@ -56,7 +56,6 @@ public IntercomHttpResponse list(RequestOptions reque .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(); @@ -65,12 +64,11 @@ public IntercomHttpResponse list(RequestOptions reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNewsItemResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PaginatedResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -79,11 +77,9 @@ public IntercomHttpResponse list(RequestOptions reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -124,11 +120,11 @@ public IntercomHttpResponse create(NewsItemRequest request, RequestOpt } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NewsItem.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -137,11 +133,9 @@ public IntercomHttpResponse create(NewsItemRequest request, RequestOpt } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -161,13 +155,12 @@ public IntercomHttpResponse find(FindNewsItemRequest request, RequestO HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .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(); @@ -176,11 +169,11 @@ public IntercomHttpResponse find(FindNewsItemRequest request, RequestO } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NewsItem.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -193,11 +186,9 @@ public IntercomHttpResponse find(FindNewsItemRequest request, RequestO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -211,7 +202,7 @@ public IntercomHttpResponse update(UpdateNewsItemRequest request, Requ HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .build(); RequestBody body; try { @@ -233,11 +224,11 @@ public IntercomHttpResponse update(UpdateNewsItemRequest request, Requ } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NewsItem.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NewsItem.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -250,11 +241,9 @@ public IntercomHttpResponse update(UpdateNewsItemRequest request, Requ } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -274,13 +263,12 @@ public IntercomHttpResponse delete(DeleteNewsItemRequest request, HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("news/news_items") - .addPathSegment(request.getNewsItemId()) + .addPathSegment(Integer.toString(request.getNewsItemId())) .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(); @@ -289,11 +277,11 @@ public IntercomHttpResponse delete(DeleteNewsItemRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeletedObject.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeletedObject.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -306,11 +294,9 @@ public IntercomHttpResponse delete(DeleteNewsItemRequest request, } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 a75407f..03a9d08 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeleteNewsItemRequest.Builder.class) public final class DeleteNewsItemRequest { - private final String newsItemId; + private final int newsItemId; private final Map additionalProperties; - private DeleteNewsItemRequest(String newsItemId, Map additionalProperties) { + private DeleteNewsItemRequest(int newsItemId, Map additionalProperties) { this.newsItemId = newsItemId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private DeleteNewsItemRequest(String newsItemId, Map additionalP * @return The unique identifier for the news item which is given by Intercom. */ @JsonProperty("news_item_id") - public String getNewsItemId() { + public int getNewsItemId() { return newsItemId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(DeleteNewsItemRequest other) { - return newsItemId.equals(other.newsItemId); + return newsItemId == other.newsItemId; } @java.lang.Override @@ -67,9 +66,9 @@ public static NewsItemIdStage builder() { public interface NewsItemIdStage { /** - * The unique identifier for the news item which is given by Intercom. + *

    The unique identifier for the news item which is given by Intercom.

    */ - _FinalStage newsItemId(@NotNull String newsItemId); + _FinalStage newsItemId(int newsItemId); Builder from(DeleteNewsItemRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NewsItemIdStage, _FinalStage { - private String newsItemId; + private int newsItemId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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.

    + *

    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("news_item_id") - public _FinalStage newsItemId(@NotNull String newsItemId) { - this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + public _FinalStage newsItemId(int newsItemId) { + this.newsItemId = newsItemId; return this; } 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 e67e4cb..da37fba 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindNewsItemRequest.Builder.class) public final class FindNewsItemRequest { - private final String newsItemId; + private final int newsItemId; private final Map additionalProperties; - private FindNewsItemRequest(String newsItemId, Map additionalProperties) { + private FindNewsItemRequest(int newsItemId, Map additionalProperties) { this.newsItemId = newsItemId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindNewsItemRequest(String newsItemId, Map additionalPro * @return The unique identifier for the news item which is given by Intercom. */ @JsonProperty("news_item_id") - public String getNewsItemId() { + public int getNewsItemId() { return newsItemId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindNewsItemRequest other) { - return newsItemId.equals(other.newsItemId); + return newsItemId == other.newsItemId; } @java.lang.Override @@ -67,9 +66,9 @@ public static NewsItemIdStage builder() { public interface NewsItemIdStage { /** - * The unique identifier for the news item which is given by Intercom. + *

    The unique identifier for the news item which is given by Intercom.

    */ - _FinalStage newsItemId(@NotNull String newsItemId); + _FinalStage newsItemId(int newsItemId); Builder from(FindNewsItemRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NewsItemIdStage, _FinalStage { - private String newsItemId; + private int newsItemId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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.

    + *

    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("news_item_id") - public _FinalStage newsItemId(@NotNull String newsItemId) { - this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + public _FinalStage newsItemId(int newsItemId) { + this.newsItemId = newsItemId; return this; } 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 0c5caf1..1de6528 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 @@ -20,13 +20,13 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UpdateNewsItemRequest.Builder.class) public final class UpdateNewsItemRequest { - private final String newsItemId; + private final int newsItemId; private final NewsItemRequest body; private final Map additionalProperties; - private UpdateNewsItemRequest(String newsItemId, NewsItemRequest body, Map additionalProperties) { + private UpdateNewsItemRequest(int newsItemId, NewsItemRequest body, Map additionalProperties) { this.newsItemId = newsItemId; this.body = body; this.additionalProperties = additionalProperties; @@ -36,7 +36,7 @@ private UpdateNewsItemRequest(String newsItemId, NewsItemRequest body, Map getAdditionalProperties() { } private boolean equalTo(UpdateNewsItemRequest other) { - return newsItemId.equals(other.newsItemId) && body.equals(other.body); + return newsItemId == other.newsItemId && body.equals(other.body); } @java.lang.Override @@ -76,9 +76,9 @@ public static NewsItemIdStage builder() { public interface NewsItemIdStage { /** - * The unique identifier for the news item which is given by Intercom. + *

    The unique identifier for the news item which is given by Intercom.

    */ - BodyStage newsItemId(@NotNull String newsItemId); + BodyStage newsItemId(int newsItemId); Builder from(UpdateNewsItemRequest other); } @@ -93,7 +93,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NewsItemIdStage, BodyStage, _FinalStage { - private String newsItemId; + private int newsItemId; private NewsItemRequest body; @@ -110,13 +110,14 @@ 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.

    + *

    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("news_item_id") - public BodyStage newsItemId(@NotNull String newsItemId) { - this.newsItemId = Objects.requireNonNull(newsItemId, "newsItemId must not be null"); + public BodyStage newsItemId(int newsItemId) { + this.newsItemId = newsItemId; return this; } 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 a971ca3..cecb793 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 @@ -19,22 +19,23 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = NewsItem.Builder.class) public final class NewsItem { - private final String id; + private final Optional type; - private final String workspaceId; + private final Optional id; - private final String title; + private final Optional workspaceId; - private final String body; + private final Optional title; - private final int senderId; + private final Optional body; - private final State state; + private final Optional senderId; + + private final Optional state; private final Optional> newsfeedAssignments; @@ -46,27 +47,29 @@ public final class NewsItem { private final Optional deliverSilently; - private final int createdAt; + private final Optional createdAt; private final Optional updatedAt; private final Map additionalProperties; private NewsItem( - String id, - String workspaceId, - String title, - String body, - int senderId, - State state, + Optional type, + Optional id, + Optional workspaceId, + Optional title, + Optional body, + Optional senderId, + Optional state, Optional> newsfeedAssignments, Optional>> labels, Optional coverImageUrl, Optional>> reactions, Optional deliverSilently, - int createdAt, + Optional createdAt, Optional updatedAt, Map additionalProperties) { + this.type = type; this.id = id; this.workspaceId = workspaceId; this.title = title; @@ -87,15 +90,15 @@ private NewsItem( * @return The type of object. */ @JsonProperty("type") - public String getType() { - return "news-item"; + public Optional getType() { + return type; } /** * @return The unique identifier for the news item which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -103,7 +106,7 @@ public String getId() { * @return The id of the workspace which the news item belongs to. */ @JsonProperty("workspace_id") - public String getWorkspaceId() { + public Optional getWorkspaceId() { return workspaceId; } @@ -111,7 +114,7 @@ public String getWorkspaceId() { * @return The title of the news item. */ @JsonProperty("title") - public String getTitle() { + public Optional getTitle() { return title; } @@ -119,7 +122,7 @@ public String getTitle() { * @return The news item body, which may contain HTML. */ @JsonProperty("body") - public String getBody() { + public Optional getBody() { return body; } @@ -127,7 +130,7 @@ public String getBody() { * @return The id of the sender of the news item. Must be a teammate on the workspace. */ @JsonProperty("sender_id") - public int getSenderId() { + public Optional getSenderId() { return senderId; } @@ -135,7 +138,7 @@ public int getSenderId() { * @return News items will not be visible to your users in the assigned newsfeeds until they are set live. */ @JsonProperty("state") - public State getState() { + public Optional getState() { return state; } @@ -183,7 +186,7 @@ public Optional getDeliverSilently() { * @return Timestamp for when the news item was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -207,24 +210,26 @@ public Map getAdditionalProperties() { } private boolean equalTo(NewsItem other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && workspaceId.equals(other.workspaceId) && title.equals(other.title) && body.equals(other.body) - && senderId == other.senderId + && 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 == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt); } @java.lang.Override public int hashCode() { return Objects.hash( + this.type, this.id, this.workspaceId, this.title, @@ -245,150 +250,47 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - WorkspaceIdStage, - TitleStage, - BodyStage, - SenderIdStage, - StateStage, - CreatedAtStage, - _FinalStage { - private String id; + public static final class Builder { + private Optional type = Optional.empty(); - private String workspaceId; + private Optional id = Optional.empty(); - private String title; + private Optional workspaceId = Optional.empty(); - private String body; + private Optional title = Optional.empty(); - private int senderId; + private Optional body = Optional.empty(); - private State state; + private Optional senderId = Optional.empty(); - private int createdAt; + private Optional state = Optional.empty(); - private Optional updatedAt = Optional.empty(); + private Optional> newsfeedAssignments = Optional.empty(); - private Optional deliverSilently = Optional.empty(); + private Optional>> labels = Optional.empty(); + + private Optional coverImageUrl = Optional.empty(); private Optional>> reactions = Optional.empty(); - private Optional coverImageUrl = Optional.empty(); + private Optional deliverSilently = Optional.empty(); - private Optional>> labels = Optional.empty(); + private Optional createdAt = Optional.empty(); - private Optional> newsfeedAssignments = Optional.empty(); + private Optional updatedAt = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(NewsItem other) { + type(other.getType()); id(other.getId()); workspaceId(other.getWorkspaceId()); title(other.getTitle()); @@ -406,205 +308,204 @@ 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.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The type of object.

    */ - @java.lang.Override - @JsonSetter("id") - public WorkspaceIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * 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 - @JsonSetter("workspace_id") - public TitleStage workspaceId(@NotNull String workspaceId) { - this.workspaceId = Objects.requireNonNull(workspaceId, "workspaceId must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * 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. + *

    The unique identifier for the news item which is given by Intercom.

    */ - @java.lang.Override - @JsonSetter("title") - public BodyStage title(@NotNull String title) { - this.title = Objects.requireNonNull(title, "title must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - /** - * 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 - @JsonSetter("body") - public SenderIdStage body(@NotNull String body) { - this.body = Objects.requireNonNull(body, "body must not be null"); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * 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. + *

    The id of the workspace which the news item belongs to.

    */ - @java.lang.Override - @JsonSetter("sender_id") - public StateStage senderId(int senderId) { - this.senderId = senderId; + @JsonSetter(value = "workspace_id", nulls = Nulls.SKIP) + public Builder workspaceId(Optional workspaceId) { + this.workspaceId = workspaceId; return this; } - /** - * 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 - @JsonSetter("state") - public CreatedAtStage state(@NotNull State state) { - this.state = Objects.requireNonNull(state, "state must not be null"); + public Builder workspaceId(String workspaceId) { + this.workspaceId = Optional.ofNullable(workspaceId); return this; } /** - * 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. + *

    The title of the news item.

    */ - @java.lang.Override - @JsonSetter("created_at") - public _FinalStage createdAt(int createdAt) { - this.createdAt = createdAt; + @JsonSetter(value = "title", nulls = Nulls.SKIP) + public Builder title(Optional title) { + this.title = title; return this; } - /** - *

    Timestamp for when the news item was last updated.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + public Builder title(String title) { + this.title = Optional.ofNullable(title); return this; } /** - *

    Timestamp for when the news item was last updated.

    + *

    The news item body, which may contain HTML.

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public Builder body(Optional body) { + this.body = body; return this; } - /** - *

    When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage deliverSilently(Boolean deliverSilently) { - this.deliverSilently = Optional.ofNullable(deliverSilently); + public Builder body(String body) { + this.body = Optional.ofNullable(body); return this; } /** - *

    When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

    + *

    The id of the sender of the news item. Must be a teammate on the workspace.

    */ - @java.lang.Override - @JsonSetter(value = "deliver_silently", nulls = Nulls.SKIP) - public _FinalStage deliverSilently(Optional deliverSilently) { - this.deliverSilently = deliverSilently; + @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; } /** - *

    Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    News items will not be visible to your users in the assigned newsfeeds until they are set live.

    */ - @java.lang.Override - public _FinalStage reactions(List> reactions) { - this.reactions = Optional.ofNullable(reactions); + @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; } /** - *

    Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

    + *

    A list of newsfeed_assignments to assign to the specified newsfeed.

    */ - @java.lang.Override - @JsonSetter(value = "reactions", nulls = Nulls.SKIP) - public _FinalStage reactions(Optional>> reactions) { - this.reactions = reactions; + @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; } /** - *

    URL of the image used as cover. Must have .jpg or .png extension.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Label names displayed to users to categorize the news item.

    */ - @java.lang.Override - public _FinalStage coverImageUrl(String coverImageUrl) { - this.coverImageUrl = Optional.ofNullable(coverImageUrl); + @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.

    */ - @java.lang.Override @JsonSetter(value = "cover_image_url", nulls = Nulls.SKIP) - public _FinalStage coverImageUrl(Optional coverImageUrl) { + public Builder coverImageUrl(Optional coverImageUrl) { this.coverImageUrl = coverImageUrl; return this; } + public Builder coverImageUrl(String coverImageUrl) { + this.coverImageUrl = Optional.ofNullable(coverImageUrl); + return this; + } + /** - *

    Label names displayed to users to categorize the news item.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Ordered list of emoji reactions to the news item. When empty, reactions are disabled.

    */ - @java.lang.Override - public _FinalStage labels(List> labels) { - this.labels = Optional.ofNullable(labels); + @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; } /** - *

    Label names displayed to users to categorize the news item.

    + *

    When set to true, the news item will appear in the messenger newsfeed without showing a notification badge.

    */ - @java.lang.Override - @JsonSetter(value = "labels", nulls = Nulls.SKIP) - public _FinalStage labels(Optional>> labels) { - this.labels = labels; + @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; } /** - *

    A list of newsfeed_assignments to assign to the specified newsfeed.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Timestamp for when the news item was created.

    */ - @java.lang.Override - public _FinalStage newsfeedAssignments(List newsfeedAssignments) { - this.newsfeedAssignments = Optional.ofNullable(newsfeedAssignments); + @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; } /** - *

    A list of newsfeed_assignments to assign to the specified newsfeed.

    + *

    Timestamp for when the news item was last updated.

    */ - @java.lang.Override - @JsonSetter(value = "newsfeed_assignments", nulls = Nulls.SKIP) - public _FinalStage newsfeedAssignments(Optional> newsfeedAssignments) { - this.newsfeedAssignments = newsfeedAssignments; + @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; } - @java.lang.Override public NewsItem build() { return new NewsItem( + type, id, workspaceId, title, 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 a0056b3..8d7e112 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 @@ -16,28 +16,31 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Newsfeed.Builder.class) public final class Newsfeed { - private final String id; + private final Optional id; - private final String name; + private final Optional type; - private final int createdAt; + private final Optional name; + + private final Optional createdAt; private final Optional updatedAt; private final Map additionalProperties; private Newsfeed( - String id, - String name, - int createdAt, + Optional id, + Optional type, + Optional name, + Optional createdAt, Optional updatedAt, Map additionalProperties) { this.id = id; + this.type = type; this.name = name; this.createdAt = createdAt; this.updatedAt = updatedAt; @@ -48,7 +51,7 @@ private Newsfeed( * @return The unique identifier for the newsfeed which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -56,15 +59,15 @@ public String getId() { * @return The type of object. */ @JsonProperty("type") - public String getType() { - return "newsfeed"; + public Optional getType() { + return type; } /** * @return The name of the newsfeed. This name will never be visible to your users. */ @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } @@ -72,7 +75,7 @@ public String getName() { * @return Timestamp for when the newsfeed was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -97,14 +100,15 @@ public Map getAdditionalProperties() { private boolean equalTo(Newsfeed other) { return id.equals(other.id) + && type.equals(other.type) && name.equals(other.name) - && createdAt == other.createdAt + && 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); + return Objects.hash(this.id, this.type, this.name, this.createdAt, this.updatedAt); } @java.lang.Override @@ -112,51 +116,19 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, CreatedAtStage, _FinalStage { - private String id; + public static final class Builder { + private Optional id = Optional.empty(); - private String name; + private Optional type = Optional.empty(); - private int createdAt; + private Optional name = Optional.empty(); + + private Optional createdAt = Optional.empty(); private Optional updatedAt = Optional.empty(); @@ -165,9 +137,9 @@ public static final class Builder implements IdStage, NameStage, CreatedAtStage, private Builder() {} - @java.lang.Override public Builder from(Newsfeed other) { id(other.getId()); + type(other.getType()); name(other.getName()); createdAt(other.getCreatedAt()); updatedAt(other.getUpdatedAt()); @@ -175,61 +147,77 @@ 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.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

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

    */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @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.

    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. + *

    The type of object.

    */ - @java.lang.Override - @JsonSetter("name") - public CreatedAtStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); + @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; } /** - * 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. + *

    The name of the newsfeed. This name will never be visible to your users.

    */ - @java.lang.Override - @JsonSetter("created_at") - public _FinalStage createdAt(int createdAt) { - this.createdAt = createdAt; + @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 last updated.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Timestamp for when the newsfeed was created.

    */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + @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.

    */ - @java.lang.Override @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { + public Builder updatedAt(Optional updatedAt) { this.updatedAt = updatedAt; return this; } - @java.lang.Override + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); + return this; + } + public Newsfeed build() { - return new Newsfeed(id, name, createdAt, updatedAt, additionalProperties); + return new Newsfeed(id, type, name, createdAt, updatedAt, additionalProperties); } } } 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 f7ba8e7..6781737 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 @@ -9,22 +9,25 @@ 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 int newsfeedId; + private final Optional newsfeedId; - private final int publishedAt; + private final Optional publishedAt; private final Map additionalProperties; - private NewsfeedAssignment(int newsfeedId, int publishedAt, Map additionalProperties) { + private NewsfeedAssignment( + Optional newsfeedId, Optional publishedAt, Map additionalProperties) { this.newsfeedId = newsfeedId; this.publishedAt = publishedAt; this.additionalProperties = additionalProperties; @@ -34,7 +37,7 @@ private NewsfeedAssignment(int newsfeedId, int publishedAt, Map * @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 int getNewsfeedId() { + public Optional getNewsfeedId() { return newsfeedId; } @@ -42,7 +45,7 @@ public int getNewsfeedId() { * @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 int getPublishedAt() { + public Optional getPublishedAt() { return publishedAt; } @@ -58,7 +61,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(NewsfeedAssignment other) { - return newsfeedId == other.newsfeedId && publishedAt == other.publishedAt; + return newsfeedId.equals(other.newsfeedId) && publishedAt.equals(other.publishedAt); } @java.lang.Override @@ -71,42 +74,21 @@ public String toString() { return ObjectMappers.stringify(this); } - public static NewsfeedIdStage builder() { + public static Builder builder() { return new 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); - } - - public interface _FinalStage { - NewsfeedAssignment build(); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NewsfeedIdStage, PublishedAtStage, _FinalStage { - private int newsfeedId; + public static final class Builder { + private Optional newsfeedId = Optional.empty(); - private int publishedAt; + private Optional publishedAt = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(NewsfeedAssignment other) { newsfeedId(other.getNewsfeedId()); publishedAt(other.getPublishedAt()); @@ -114,28 +96,33 @@ 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).

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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).

    */ - @java.lang.Override - @JsonSetter("newsfeed_id") - public PublishedAtStage newsfeedId(int newsfeedId) { + @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".

    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. + *

    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".

    */ - @java.lang.Override - @JsonSetter("published_at") - public _FinalStage publishedAt(int publishedAt) { + @JsonSetter(value = "published_at", nulls = Nulls.SKIP) + public Builder publishedAt(Optional publishedAt) { this.publishedAt = publishedAt; return this; } - @java.lang.Override + 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/notes/AsyncRawNotesClient.java b/src/main/java/com/intercom/api/resources/notes/AsyncRawNotesClient.java index 9fb3e8a..ad98e89 100644 --- a/src/main/java/com/intercom/api/resources/notes/AsyncRawNotesClient.java +++ b/src/main/java/com/intercom/api/resources/notes/AsyncRawNotesClient.java @@ -22,6 +22,7 @@ import com.intercom.api.types.Error; import com.intercom.api.types.NoteList; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -62,17 +63,16 @@ public CompletableFuture>> list( .addPathSegments("notes"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -84,18 +84,20 @@ public CompletableFuture>> list( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { NoteList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteList.class); - int newPageNumber = - request.getPage().map(page -> page + 1).orElse(1); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NoteList.class); + int newPageNumber = request.getPage() + .map((Integer page) -> page + 1) + .orElse(1); ListContactNotesRequest nextRequest = ListContactNotesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> { + new SyncPagingIterable(true, result, parsedResponse, () -> { try { return list(nextRequest, requestOptions) .get() @@ -107,7 +109,6 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 404) { future.completeExceptionally(new NotFoundError( @@ -117,11 +118,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -177,12 +176,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Note.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 404) { future.completeExceptionally(new NotFoundError( @@ -192,11 +191,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -225,13 +222,12 @@ public CompletableFuture> find(FindNoteRequest reques HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("notes") - .addPathSegment(request.getNoteId()) + .addPathSegment(Integer.toString(request.getNoteId())) .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(); @@ -243,12 +239,12 @@ public CompletableFuture> find(FindNoteRequest reques @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Note.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -265,11 +261,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java b/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java index e2cc71e..21b7f08 100644 --- a/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java +++ b/src/main/java/com/intercom/api/resources/notes/RawNotesClient.java @@ -22,6 +22,7 @@ import com.intercom.api.types.Error; import com.intercom.api.types.NoteList; import java.io.IOException; +import java.util.Collections; import java.util.List; import okhttp3.Headers; import okhttp3.HttpUrl; @@ -57,17 +58,16 @@ public IntercomHttpResponse> list( .addPathSegments("notes"); if (request.getPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get().toString(), false); + httpUrl, "page", request.getPage().get(), false); } if (request.getPerPage().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "per_page", request.getPerPage().get().toString(), false); + httpUrl, "per_page", request.getPerPage().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(); @@ -76,20 +76,22 @@ public IntercomHttpResponse> list( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - NoteList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteList.class); - int newPageNumber = request.getPage().map(page -> page + 1).orElse(1); + NoteList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NoteList.class); + int newPageNumber = + request.getPage().map((Integer page) -> page + 1).orElse(1); ListContactNotesRequest nextRequest = ListContactNotesRequest.builder() .from(request) .page(newPageNumber) .build(); - List result = parsedResponse.getData(); + List result = parsedResponse.getData().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable(true, result, () -> list(nextRequest, requestOptions) - .body()), + new SyncPagingIterable( + true, result, parsedResponse, () -> list(nextRequest, requestOptions) + .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 404) { throw new NotFoundError( @@ -98,11 +100,9 @@ public IntercomHttpResponse> list( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -145,11 +145,11 @@ public IntercomHttpResponse create(CreateContactNoteRequest request, Reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Note.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 404) { throw new NotFoundError( @@ -158,11 +158,9 @@ public IntercomHttpResponse create(CreateContactNoteRequest request, Reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -182,13 +180,12 @@ public IntercomHttpResponse find(FindNoteRequest request, RequestOptions r HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("notes") - .addPathSegment(request.getNoteId()) + .addPathSegment(Integer.toString(request.getNoteId())) .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(); @@ -197,11 +194,11 @@ public IntercomHttpResponse find(FindNoteRequest request, RequestOptions r } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Note.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -214,11 +211,9 @@ public IntercomHttpResponse find(FindNoteRequest request, RequestOptions r } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 5baaee8..c09369d 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 @@ -92,7 +92,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier of a given contact. + *

    The unique identifier of a given contact.

    */ BodyStage contactId(@NotNull String contactId); @@ -101,7 +101,7 @@ public interface ContactIdStage { public interface BodyStage { /** - * The text of the note. + *

    The text of the note.

    */ _FinalStage body(@NotNull String body); } @@ -139,7 +139,8 @@ 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.

    + *

    The unique identifier of a given contact.

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -150,7 +151,8 @@ public BodyStage contactId(@NotNull String contactId) { } /** - * The text of the note.

    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 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 e51a52b..11a46e9 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 @@ -14,16 +14,15 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FindNoteRequest.Builder.class) public final class FindNoteRequest { - private final String noteId; + private final int noteId; private final Map additionalProperties; - private FindNoteRequest(String noteId, Map additionalProperties) { + private FindNoteRequest(int noteId, Map additionalProperties) { this.noteId = noteId; this.additionalProperties = additionalProperties; } @@ -32,7 +31,7 @@ private FindNoteRequest(String noteId, Map additionalProperties) * @return The unique identifier of a given note */ @JsonProperty("note_id") - public String getNoteId() { + public int getNoteId() { return noteId; } @@ -48,7 +47,7 @@ public Map getAdditionalProperties() { } private boolean equalTo(FindNoteRequest other) { - return noteId.equals(other.noteId); + return noteId == other.noteId; } @java.lang.Override @@ -67,9 +66,9 @@ public static NoteIdStage builder() { public interface NoteIdStage { /** - * The unique identifier of a given note + *

    The unique identifier of a given note

    */ - _FinalStage noteId(@NotNull String noteId); + _FinalStage noteId(int noteId); Builder from(FindNoteRequest other); } @@ -80,7 +79,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements NoteIdStage, _FinalStage { - private String noteId; + private int noteId; @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -94,13 +93,14 @@ 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

    + *

    The unique identifier of a given note

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @JsonSetter("note_id") - public _FinalStage noteId(@NotNull String noteId) { - this.noteId = Objects.requireNonNull(noteId, "noteId must not be null"); + public _FinalStage noteId(int noteId) { + this.noteId = noteId; return this; } 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 54e8897..d21927d 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 @@ -95,7 +95,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier of a contact. + *

    The unique identifier of a contact.

    */ _FinalStage contactId(@NotNull String contactId); @@ -142,7 +142,8 @@ public Builder from(ListContactNotesRequest other) { } /** - * The unique identifier of a contact.

    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 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 3e303c4..847c335 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 @@ -17,30 +17,33 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Note.Builder.class) public final class Note { - private final String id; + private final Optional type; - private final int createdAt; + private final Optional id; + + private final Optional createdAt; private final Optional contact; - private final Admin author; + private final Optional author; - private final String body; + private final Optional body; private final Map additionalProperties; private Note( - String id, - int createdAt, + Optional type, + Optional id, + Optional createdAt, Optional contact, - Admin author, - String body, + Optional author, + Optional body, Map additionalProperties) { + this.type = type; this.id = id; this.createdAt = createdAt; this.contact = contact; @@ -53,15 +56,15 @@ private Note( * @return String representing the object's type. Always has the value note. */ @JsonProperty("type") - public String getType() { - return "note"; + public Optional getType() { + return type; } /** * @return The id of the note. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -69,7 +72,7 @@ public String getId() { * @return The time the note was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -85,7 +88,7 @@ public Optional getContact() { * @return Optional. Represents the Admin that created the note. */ @JsonProperty("author") - public Admin getAuthor() { + public Optional getAuthor() { return author; } @@ -93,7 +96,7 @@ public Admin getAuthor() { * @return The body text of the note. */ @JsonProperty("body") - public String getBody() { + public Optional getBody() { return body; } @@ -109,8 +112,9 @@ public Map getAdditionalProperties() { } private boolean equalTo(Note other) { - return id.equals(other.id) - && createdAt == other.createdAt + 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); @@ -118,7 +122,7 @@ private boolean equalTo(Note other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.createdAt, this.contact, this.author, this.body); + return Objects.hash(this.type, this.id, this.createdAt, this.contact, this.author, this.body); } @java.lang.Override @@ -126,70 +130,31 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, CreatedAtStage, AuthorStage, BodyStage, _FinalStage { - private String id; - - private int createdAt; + public static final class Builder { + private Optional type = Optional.empty(); - private Admin author; + private Optional id = Optional.empty(); - private String body; + 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() {} - @java.lang.Override public Builder from(Note other) { + type(other.getType()); id(other.getId()); createdAt(other.getCreatedAt()); contact(other.getContact()); @@ -199,72 +164,91 @@ public Builder from(Note other) { } /** - * The id of the note.

    The id of the note.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

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

    */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * 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 - @JsonSetter("created_at") - public AuthorStage createdAt(int createdAt) { - this.createdAt = createdAt; + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * 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. + *

    The id of the note.

    */ - @java.lang.Override - @JsonSetter("author") - public BodyStage author(@NotNull Admin author) { - this.author = Objects.requireNonNull(author, "author must not be null"); + @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 body text of the note.

    The body text of the note.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The time the note was created.

    */ - @java.lang.Override - @JsonSetter("body") - public _FinalStage body(@NotNull String body) { - this.body = Objects.requireNonNull(body, "body must not be null"); + @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.

    - * @return Reference to {@code this} so that method calls can be chained together. */ - @java.lang.Override - public _FinalStage contact(Contact contact) { + @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; } /** - *

    Represents the contact that the note was created about.

    + *

    Optional. Represents the Admin that created the note.

    */ - @java.lang.Override - @JsonSetter(value = "contact", nulls = Nulls.SKIP) - public _FinalStage contact(Optional contact) { - this.contact = contact; + @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; } - @java.lang.Override public Note build() { - return new Note(id, createdAt, contact, author, body, additionalProperties); + return new Note(type, id, createdAt, contact, author, body, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java index 2c5e358..e7b9676 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncPhoneCallRedirectsClient.java @@ -5,8 +5,9 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.PhoneSwitch; +import java.util.Optional; import java.util.concurrent.CompletableFuture; public class AsyncPhoneCallRedirectsClient { @@ -31,7 +32,16 @@ public AsyncRawPhoneCallRedirectsClient withRawResponse() { * 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 create(CreatePhoneCallRedirectRequest request) { + public CompletableFuture> create() { + return this.rawClient.create().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> create(Optional request) { return this.rawClient.create(request).thenApply(response -> response.body()); } @@ -40,8 +50,8 @@ public CompletableFuture create(CreatePhoneCallRedirectRequest requ * 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 create( - CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public CompletableFuture> create( + Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java index bcbb060..611751d 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/AsyncRawPhoneCallRedirectsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.phonecallredirects; 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; @@ -14,10 +15,11 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.Error; import com.intercom.api.types.PhoneSwitch; import java.io.IOException; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import okhttp3.Call; import okhttp3.Callback; @@ -42,7 +44,17 @@ public AsyncRawPhoneCallRedirectsClient(ClientOptions clientOptions) { * 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> create(CreatePhoneCallRedirectRequest request) { + public CompletableFuture>> create() { + return create(Optional.empty()); + } + + /** + * 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>> create( + Optional request) { return create(request, null); } @@ -51,16 +63,19 @@ public CompletableFuture> create(CreatePhoneCa * 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> create( - CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public CompletableFuture>> create( + Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -75,18 +90,19 @@ public CompletableFuture> create( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PhoneSwitch.class), + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -108,11 +124,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java index 836dc4f..dcbceab 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/PhoneCallRedirectsClient.java @@ -5,8 +5,9 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.PhoneSwitch; +import java.util.Optional; public class PhoneCallRedirectsClient { protected final ClientOptions clientOptions; @@ -30,7 +31,16 @@ public RawPhoneCallRedirectsClient withRawResponse() { * 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 PhoneSwitch create(CreatePhoneCallRedirectRequest request) { + public Optional create() { + return this.rawClient.create().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 create(Optional request) { return this.rawClient.create(request).body(); } @@ -39,7 +49,7 @@ public PhoneSwitch create(CreatePhoneCallRedirectRequest request) { * 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 PhoneSwitch create(CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public Optional create(Optional request, RequestOptions requestOptions) { return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java b/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java index 14ee509..f34b670 100644 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java +++ b/src/main/java/com/intercom/api/resources/phonecallredirects/RawPhoneCallRedirectsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.phonecallredirects; 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; @@ -14,10 +15,11 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.UnauthorizedError; import com.intercom.api.errors.UnprocessableEntityError; -import com.intercom.api.resources.phonecallredirects.requests.CreatePhoneCallRedirectRequest; +import com.intercom.api.types.CreatePhoneSwitchRequest; import com.intercom.api.types.Error; import com.intercom.api.types.PhoneSwitch; import java.io.IOException; +import java.util.Optional; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -38,7 +40,16 @@ public RawPhoneCallRedirectsClient(ClientOptions clientOptions) { * 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 create(CreatePhoneCallRedirectRequest request) { + public IntercomHttpResponse> create() { + return create(Optional.empty()); + } + + /** + * 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> create(Optional request) { return create(request, null); } @@ -47,16 +58,19 @@ public IntercomHttpResponse create(CreatePhoneCallRedirectRequest r * 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 create( - CreatePhoneCallRedirectRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> create( + Optional 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); + body = RequestBody.create("", null); + if (request.isPresent()) { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } } catch (JsonProcessingException e) { throw new IntercomException("Failed to serialize request", e); } @@ -73,11 +87,13 @@ public IntercomHttpResponse create( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PhoneSwitch.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -93,11 +109,9 @@ public IntercomHttpResponse create( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 deleted file mode 100644 index 29c1a05..0000000 --- a/src/main/java/com/intercom/api/resources/phonecallredirects/requests/CreatePhoneCallRedirectRequest.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.intercom.api.resources.phonecallredirects.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 = CreatePhoneCallRedirectRequest.Builder.class) -public final class CreatePhoneCallRedirectRequest { - private final String phone; - - private final Optional> customAttributes; - - private final Map additionalProperties; - - private CreatePhoneCallRedirectRequest( - String phone, Optional> customAttributes, Map additionalProperties) { - this.phone = phone; - this.customAttributes = customAttributes; - this.additionalProperties = additionalProperties; - } - - /** - * @return Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. - */ - @JsonProperty("phone") - public String getPhone() { - return phone; - } - - @JsonProperty("custom_attributes") - public Optional> getCustomAttributes() { - return customAttributes; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreatePhoneCallRedirectRequest && equalTo((CreatePhoneCallRedirectRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(CreatePhoneCallRedirectRequest other) { - return phone.equals(other.phone) && customAttributes.equals(other.customAttributes); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.phone, this.customAttributes); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PhoneStage builder() { - return new 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); - } - - public interface _FinalStage { - CreatePhoneCallRedirectRequest build(); - - _FinalStage customAttributes(Optional> customAttributes); - - _FinalStage customAttributes(Map customAttributes); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PhoneStage, _FinalStage { - private String phone; - - private Optional> customAttributes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(CreatePhoneCallRedirectRequest other) { - phone(other.getPhone()); - customAttributes(other.getCustomAttributes()); - return this; - } - - /** - * 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 - @JsonSetter("phone") - public _FinalStage phone(@NotNull String phone) { - this.phone = Objects.requireNonNull(phone, "phone must not be null"); - 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; - } - - @java.lang.Override - public CreatePhoneCallRedirectRequest build() { - return new CreatePhoneCallRedirectRequest(phone, customAttributes, additionalProperties); - } - } -} diff --git a/src/main/java/com/intercom/api/resources/segments/AsyncRawSegmentsClient.java b/src/main/java/com/intercom/api/resources/segments/AsyncRawSegmentsClient.java index 78d8f8b..1da2043 100644 --- a/src/main/java/com/intercom/api/resources/segments/AsyncRawSegmentsClient.java +++ b/src/main/java/com/intercom/api/resources/segments/AsyncRawSegmentsClient.java @@ -61,13 +61,12 @@ public CompletableFuture> list( .addPathSegments("segments"); if (request.getIncludeCount().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "include_count", request.getIncludeCount().get().toString(), false); + httpUrl, "include_count", request.getIncludeCount().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(); @@ -79,13 +78,12 @@ public CompletableFuture> list( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SegmentList.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SegmentList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -95,11 +93,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -135,7 +131,6 @@ public CompletableFuture> find( .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(); @@ -147,12 +142,12 @@ public CompletableFuture> find( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Segment.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Segment.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -169,11 +164,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/segments/RawSegmentsClient.java b/src/main/java/com/intercom/api/resources/segments/RawSegmentsClient.java index 723140f..df168c0 100644 --- a/src/main/java/com/intercom/api/resources/segments/RawSegmentsClient.java +++ b/src/main/java/com/intercom/api/resources/segments/RawSegmentsClient.java @@ -56,13 +56,12 @@ public IntercomHttpResponse list(ListSegmentsRequest request, Reque .addPathSegments("segments"); if (request.getIncludeCount().isPresent()) { QueryStringMapper.addQueryParameter( - httpUrl, "include_count", request.getIncludeCount().get().toString(), false); + httpUrl, "include_count", request.getIncludeCount().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(); @@ -71,11 +70,11 @@ public IntercomHttpResponse list(ListSegmentsRequest request, Reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SegmentList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SegmentList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -84,11 +83,9 @@ public IntercomHttpResponse list(ListSegmentsRequest request, Reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -114,7 +111,6 @@ public IntercomHttpResponse find(FindSegmentRequest request, RequestOpt .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(); @@ -123,11 +119,11 @@ public IntercomHttpResponse find(FindSegmentRequest request, RequestOpt } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Segment.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Segment.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -140,11 +136,9 @@ public IntercomHttpResponse find(FindSegmentRequest request, RequestOpt } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 2aafb27..b514aa0 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 @@ -67,7 +67,7 @@ public static SegmentIdStage builder() { public interface SegmentIdStage { /** - * The unique identified of a given segment. + *

    The unique identified of a given segment.

    */ _FinalStage segmentId(@NotNull String segmentId); @@ -94,7 +94,8 @@ 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.

    + *

    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/types/Segment.java b/src/main/java/com/intercom/api/resources/segments/types/Segment.java index fb148fa..a3db029 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 @@ -18,33 +18,36 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Segment.Builder.class) public final class Segment { - private final String id; + private final Optional type; - private final String name; + private final Optional id; - private final int createdAt; + private final Optional name; + + private final Optional createdAt; private final Optional updatedAt; - private final PersonType personType; + private final Optional personType; private final Optional count; private final Map additionalProperties; private Segment( - String id, - String name, - int createdAt, + Optional type, + Optional id, + Optional name, + Optional createdAt, Optional updatedAt, - PersonType personType, + Optional personType, Optional count, Map additionalProperties) { + this.type = type; this.id = id; this.name = name; this.createdAt = createdAt; @@ -58,15 +61,15 @@ private Segment( * @return The type of object. */ @JsonProperty("type") - public String getType() { - return "segment"; + public Optional getType() { + return type; } /** * @return The unique identifier representing the segment. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -74,7 +77,7 @@ public String getId() { * @return The name of the segment. */ @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } @@ -82,7 +85,7 @@ public String getName() { * @return The time the segment was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -98,7 +101,7 @@ public Optional getUpdatedAt() { * @return Type of the contact: contact (lead) or user. */ @JsonProperty("person_type") - public PersonType getPersonType() { + public Optional getPersonType() { return personType; } @@ -122,9 +125,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(Segment other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && name.equals(other.name) - && createdAt == other.createdAt + && createdAt.equals(other.createdAt) && updatedAt.equals(other.updatedAt) && personType.equals(other.personType) && count.equals(other.count); @@ -132,7 +136,7 @@ private boolean equalTo(Segment other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.name, this.createdAt, this.updatedAt, this.personType, this.count); + return Objects.hash(this.type, this.id, this.name, this.createdAt, this.updatedAt, this.personType, this.count); } @java.lang.Override @@ -140,79 +144,33 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - _FinalStage count(Integer count); - } + private Optional id = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, CreatedAtStage, PersonTypeStage, _FinalStage { - private String id; + private Optional name = Optional.empty(); - private String name; + private Optional createdAt = Optional.empty(); - private int createdAt; + private Optional updatedAt = Optional.empty(); - private PersonType personType; + private Optional personType = Optional.empty(); private Optional count = Optional.empty(); - private Optional updatedAt = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Segment other) { + type(other.getType()); id(other.getId()); name(other.getName()); createdAt(other.getCreatedAt()); @@ -223,92 +181,105 @@ public Builder from(Segment other) { } /** - * 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. + *

    The type of object.

    */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * 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 - @JsonSetter("name") - public CreatedAtStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * 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. + *

    The unique identifier representing the segment.

    */ - @java.lang.Override - @JsonSetter("created_at") - public PersonTypeStage createdAt(int createdAt) { - this.createdAt = createdAt; + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - /** - * 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 - @JsonSetter("person_type") - public _FinalStage personType(@NotNull PersonType personType) { - this.personType = Objects.requireNonNull(personType, "personType must not be null"); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - *

    The number of items in the user segment. It's returned when include_count=true is included in the request.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The name of the segment.

    */ - @java.lang.Override - public _FinalStage count(Integer count) { - this.count = Optional.ofNullable(count); + @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 number of items in the user segment. It's returned when include_count=true is included in the request.

    + *

    The time the segment was created.

    */ - @java.lang.Override - @JsonSetter(value = "count", nulls = Nulls.SKIP) - public _FinalStage count(Optional count) { - this.count = count; + @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.

    - * @return Reference to {@code this} so that method calls can be chained together. */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { + @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 segment was updated.

    + *

    Type of the contact: contact (lead) or user.

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @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; } - @java.lang.Override public Segment build() { - return new Segment(id, name, createdAt, updatedAt, personType, count, additionalProperties); + return new Segment(type, id, name, createdAt, updatedAt, personType, count, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncRawSubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncRawSubscriptionTypesClient.java index 4735b46..39ad4da 100644 --- a/src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncRawSubscriptionTypesClient.java +++ b/src/main/java/com/intercom/api/resources/subscriptiontypes/AsyncRawSubscriptionTypesClient.java @@ -51,7 +51,6 @@ public CompletableFuture> list(Reques .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(); @@ -63,13 +62,13 @@ public CompletableFuture> list(Reques @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionTypeList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -79,11 +78,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/subscriptiontypes/RawSubscriptionTypesClient.java b/src/main/java/com/intercom/api/resources/subscriptiontypes/RawSubscriptionTypesClient.java index 5f46955..4c42d55 100644 --- a/src/main/java/com/intercom/api/resources/subscriptiontypes/RawSubscriptionTypesClient.java +++ b/src/main/java/com/intercom/api/resources/subscriptiontypes/RawSubscriptionTypesClient.java @@ -47,7 +47,6 @@ public IntercomHttpResponse list(RequestOptions requestOpt .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(); @@ -56,12 +55,11 @@ public IntercomHttpResponse list(RequestOptions requestOpt } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionTypeList.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionTypeList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -70,11 +68,9 @@ public IntercomHttpResponse list(RequestOptions requestOpt } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 a02f3b4..b1a13ff 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 @@ -15,38 +15,41 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.Translation; -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; +import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SubscriptionType.Builder.class) public final class SubscriptionType { - private final String id; + private final Optional type; - private final State state; + private final Optional id; - private final Translation defaultTranslation; + private final Optional state; - private final List translations; + private final Optional defaultTranslation; - private final ConsentType consentType; + private final Optional> translations; - private final List contentTypes; + private final Optional consentType; + + private final Optional> contentTypes; private final Map additionalProperties; private SubscriptionType( - String id, - State state, - Translation defaultTranslation, - List translations, - ConsentType consentType, - List contentTypes, + 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; @@ -60,15 +63,15 @@ private SubscriptionType( * @return The type of the object - subscription */ @JsonProperty("type") - public String getType() { - return "subscription"; + public Optional getType() { + return type; } /** * @return The unique identifier representing the subscription type. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -76,12 +79,12 @@ public String getId() { * @return The state of the subscription type. */ @JsonProperty("state") - public State getState() { + public Optional getState() { return state; } @JsonProperty("default_translation") - public Translation getDefaultTranslation() { + public Optional getDefaultTranslation() { return defaultTranslation; } @@ -89,7 +92,7 @@ public Translation getDefaultTranslation() { * @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 List getTranslations() { + public Optional> getTranslations() { return translations; } @@ -97,7 +100,7 @@ public List getTranslations() { * @return Describes the type of consent. */ @JsonProperty("consent_type") - public ConsentType getConsentType() { + public Optional getConsentType() { return consentType; } @@ -105,7 +108,7 @@ public ConsentType getConsentType() { * @return The message types that this subscription supports - can contain email or sms_message. */ @JsonProperty("content_types") - public List getContentTypes() { + public Optional> getContentTypes() { return contentTypes; } @@ -121,7 +124,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(SubscriptionType other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && state.equals(other.state) && defaultTranslation.equals(other.defaultTranslation) && translations.equals(other.translations) @@ -132,7 +136,13 @@ private boolean equalTo(SubscriptionType other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.id, this.state, this.defaultTranslation, this.translations, this.consentType, this.contentTypes); + this.type, + this.id, + this.state, + this.defaultTranslation, + this.translations, + this.consentType, + this.contentTypes); } @java.lang.Override @@ -140,81 +150,33 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - } - - public interface DefaultTranslationStage { - ConsentTypeStage defaultTranslation(@NotNull Translation defaultTranslation); - } - - 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); - - _FinalStage addAllContentTypes(List contentTypes); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, StateStage, DefaultTranslationStage, ConsentTypeStage, _FinalStage { - private String id; + public static final class Builder { + private Optional type = Optional.empty(); - private State state; + private Optional id = Optional.empty(); - private Translation defaultTranslation; + private Optional state = Optional.empty(); - private ConsentType consentType; + private Optional defaultTranslation = Optional.empty(); - private List contentTypes = new ArrayList<>(); + private Optional> translations = Optional.empty(); - private List translations = new ArrayList<>(); + private Optional consentType = Optional.empty(); + + private Optional> contentTypes = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(SubscriptionType other) { + type(other.getType()); id(other.getId()); state(other.getState()); defaultTranslation(other.getDefaultTranslation()); @@ -225,111 +187,103 @@ public Builder from(SubscriptionType other) { } /** - * 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. + *

    The type of the object - subscription

    */ - @java.lang.Override - @JsonSetter("id") - public StateStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @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 state of the subscription type.

    The state of the subscription type.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The unique identifier representing the subscription type.

    */ - @java.lang.Override - @JsonSetter("state") - public DefaultTranslationStage state(@NotNull State state) { - this.state = Objects.requireNonNull(state, "state must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - @java.lang.Override - @JsonSetter("default_translation") - public ConsentTypeStage defaultTranslation(@NotNull Translation defaultTranslation) { - this.defaultTranslation = Objects.requireNonNull(defaultTranslation, "defaultTranslation must not be null"); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } /** - * Describes the type of consent.

    Describes the type of consent.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The state of the subscription type.

    */ - @java.lang.Override - @JsonSetter("consent_type") - public _FinalStage consentType(@NotNull ConsentType consentType) { - this.consentType = Objects.requireNonNull(consentType, "consentType must not be null"); + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; return this; } - /** - *

    The message types that this subscription supports - can contain email or sms_message.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllContentTypes(List contentTypes) { - this.contentTypes.addAll(contentTypes); + public Builder state(State state) { + this.state = Optional.ofNullable(state); return this; } - /** - *

    The message types that this subscription supports - can contain email or sms_message.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addContentTypes(ContentTypesItem contentTypes) { - this.contentTypes.add(contentTypes); + @JsonSetter(value = "default_translation", nulls = Nulls.SKIP) + public Builder defaultTranslation(Optional defaultTranslation) { + this.defaultTranslation = defaultTranslation; 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) { - this.contentTypes.clear(); - this.contentTypes.addAll(contentTypes); + 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.

    - * @return Reference to {@code this} so that method calls can be chained together. */ - @java.lang.Override - public _FinalStage addAllTranslations(List translations) { - this.translations.addAll(translations); + @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; } /** - *

    An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Describes the type of consent.

    */ - @java.lang.Override - public _FinalStage addTranslations(Translation translations) { - this.translations.add(translations); + @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; } /** - *

    An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

    + *

    The message types that this subscription supports - can contain email or sms_message.

    */ - @java.lang.Override - @JsonSetter(value = "translations", nulls = Nulls.SKIP) - public _FinalStage translations(List translations) { - this.translations.clear(); - this.translations.addAll(translations); + @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; } - @java.lang.Override public SubscriptionType build() { return new SubscriptionType( - id, state, defaultTranslation, translations, consentType, contentTypes, additionalProperties); + type, id, state, defaultTranslation, translations, consentType, contentTypes, additionalProperties); } } diff --git a/src/main/java/com/intercom/api/resources/tags/AsyncRawTagsClient.java b/src/main/java/com/intercom/api/resources/tags/AsyncRawTagsClient.java index 8dd4803..ae3102c 100644 --- a/src/main/java/com/intercom/api/resources/tags/AsyncRawTagsClient.java +++ b/src/main/java/com/intercom/api/resources/tags/AsyncRawTagsClient.java @@ -87,12 +87,12 @@ public CompletableFuture> tagContact( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -109,11 +109,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -151,7 +149,6 @@ public CompletableFuture> untagContact( .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(); @@ -163,12 +160,12 @@ public CompletableFuture> untagContact( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -185,11 +182,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -245,12 +240,12 @@ public CompletableFuture> tagConversation( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -267,11 +262,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -328,12 +321,12 @@ public CompletableFuture> untagConversation( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -350,11 +343,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -388,7 +379,6 @@ public CompletableFuture> list(RequestOptions requ .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(); @@ -400,12 +390,12 @@ public CompletableFuture> list(RequestOptions requ @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TagList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -415,11 +405,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -485,12 +473,12 @@ public CompletableFuture> create( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -512,11 +500,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -553,7 +539,6 @@ public CompletableFuture> find(FindTagRequest request, .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(); @@ -565,12 +550,12 @@ public CompletableFuture> find(FindTagRequest request, @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -587,11 +572,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -664,11 +647,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -724,12 +705,12 @@ public CompletableFuture> tagTicket( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -746,11 +727,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -807,12 +786,12 @@ public CompletableFuture> untagTicket( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -829,11 +808,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/tags/RawTagsClient.java b/src/main/java/com/intercom/api/resources/tags/RawTagsClient.java index 8581eba..32b8734 100644 --- a/src/main/java/com/intercom/api/resources/tags/RawTagsClient.java +++ b/src/main/java/com/intercom/api/resources/tags/RawTagsClient.java @@ -79,11 +79,11 @@ public IntercomHttpResponse tagContact(TagContactRequest request, RequestOp } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -96,11 +96,9 @@ public IntercomHttpResponse tagContact(TagContactRequest request, RequestOp } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -128,7 +126,6 @@ public IntercomHttpResponse untagContact(UntagContactRequest request, Reque .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(); @@ -137,11 +134,11 @@ public IntercomHttpResponse untagContact(UntagContactRequest request, Reque } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -154,11 +151,9 @@ public IntercomHttpResponse untagContact(UntagContactRequest request, Reque } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -201,11 +196,11 @@ public IntercomHttpResponse tagConversation(TagConversationRequest request, } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -218,11 +213,9 @@ public IntercomHttpResponse tagConversation(TagConversationRequest request, } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -267,11 +260,11 @@ public IntercomHttpResponse untagConversation( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -284,11 +277,9 @@ public IntercomHttpResponse untagConversation( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -313,7 +304,6 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { .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(); @@ -322,11 +312,11 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TagList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TagList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -335,11 +325,9 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -392,11 +380,11 @@ public IntercomHttpResponse create(TagsCreateRequestBody request, RequestOp } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -412,11 +400,9 @@ public IntercomHttpResponse create(TagsCreateRequestBody request, RequestOp } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -444,7 +430,6 @@ public IntercomHttpResponse find(FindTagRequest request, RequestOptions req .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(); @@ -453,11 +438,11 @@ public IntercomHttpResponse find(FindTagRequest request, RequestOptions req } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -470,11 +455,9 @@ public IntercomHttpResponse find(FindTagRequest request, RequestOptions req } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -527,11 +510,9 @@ public IntercomHttpResponse delete(DeleteTagRequest request, RequestOption } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -574,11 +555,11 @@ public IntercomHttpResponse tagTicket(TagTicketRequest request, RequestOpti } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -591,11 +572,9 @@ public IntercomHttpResponse tagTicket(TagTicketRequest request, RequestOpti } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -639,11 +618,11 @@ public IntercomHttpResponse untagTicket(UntagTicketRequest request, Request } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Tag.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -656,11 +635,9 @@ public IntercomHttpResponse untagTicket(UntagTicketRequest request, Request } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 56c2df6..0fea2a0 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 @@ -67,7 +67,7 @@ public static TagIdStage builder() { public interface TagIdStage { /** - * The unique identifier of a given tag + *

    The unique identifier of a given tag

    */ _FinalStage tagId(@NotNull String tagId); @@ -94,7 +94,8 @@ 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

    + *

    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 f8aaee1..51f6efc 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 @@ -67,7 +67,7 @@ public static TagIdStage builder() { public interface TagIdStage { /** - * The unique identifier of a given tag + *

    The unique identifier of a given tag

    */ _FinalStage tagId(@NotNull String tagId); @@ -94,7 +94,8 @@ 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

    + *

    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 ecabd57..a3c32c1 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 @@ -78,7 +78,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

    The unique identifier for the contact which is given by Intercom

    */ TagIdStage contactId(@NotNull String contactId); @@ -87,7 +87,7 @@ public interface ContactIdStage { public interface TagIdStage { /** - * The unique identifier for the tag which is given by Intercom + *

    The unique identifier for the tag which is given by Intercom

    */ _FinalStage tagId(@NotNull String tagId); } @@ -115,7 +115,8 @@ 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

    + *

    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 @@ -126,7 +127,8 @@ 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

    + *

    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 b8b25bb..a35679f 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 @@ -92,7 +92,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * conversation_id + *

    conversation_id

    */ TagIdStage conversationId(@NotNull String conversationId); @@ -101,14 +101,14 @@ public interface ConversationIdStage { public interface TagIdStage { /** - * The unique identifier for the tag which is given by Intercom + *

    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. + *

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

    */ _FinalStage adminId(@NotNull String adminId); } @@ -139,7 +139,8 @@ public Builder from(TagConversationRequest other) { } /** - * conversation_id

    conversation_id

    + *

    conversation_id

    + *

    conversation_id

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -150,7 +151,8 @@ 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

    + *

    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 @@ -161,7 +163,8 @@ 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.

    + *

    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 46607ac..73aa957 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 @@ -89,7 +89,7 @@ public static TicketIdStage builder() { public interface TicketIdStage { /** - * ticket_id + *

    ticket_id

    */ TagIdStage ticketId(@NotNull String ticketId); @@ -98,14 +98,14 @@ public interface TicketIdStage { public interface TagIdStage { /** - * The unique identifier for the tag which is given by Intercom + *

    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. + *

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

    */ _FinalStage adminId(@NotNull String adminId); } @@ -136,7 +136,8 @@ public Builder from(TagTicketRequest other) { } /** - * ticket_id

    ticket_id

    + *

    ticket_id

    + *

    ticket_id

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -147,7 +148,8 @@ 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

    + *

    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 @@ -158,7 +160,8 @@ 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.

    + *

    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 3cdc95b..6d28a6c 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 @@ -78,7 +78,7 @@ public static ContactIdStage builder() { public interface ContactIdStage { /** - * The unique identifier for the contact which is given by Intercom + *

    The unique identifier for the contact which is given by Intercom

    */ TagIdStage contactId(@NotNull String contactId); @@ -87,7 +87,7 @@ public interface ContactIdStage { public interface TagIdStage { /** - * The unique identifier for the tag which is given by Intercom + *

    The unique identifier for the tag which is given by Intercom

    */ _FinalStage tagId(@NotNull String tagId); } @@ -115,7 +115,8 @@ 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

    + *

    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 @@ -126,7 +127,8 @@ 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

    + *

    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 6a4faa6..8c3ca12 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 @@ -44,7 +44,7 @@ public String getConversationId() { } /** - * @return id + * @return tag_id */ @JsonProperty("tag_id") public String getTagId() { @@ -92,7 +92,7 @@ public static ConversationIdStage builder() { public interface ConversationIdStage { /** - * conversation_id + *

    conversation_id

    */ TagIdStage conversationId(@NotNull String conversationId); @@ -101,14 +101,14 @@ public interface ConversationIdStage { public interface TagIdStage { /** - * id + *

    tag_id

    */ AdminIdStage tagId(@NotNull String tagId); } public interface AdminIdStage { /** - * The unique identifier for the admin which is given by Intercom. + *

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

    */ _FinalStage adminId(@NotNull String adminId); } @@ -139,7 +139,8 @@ public Builder from(UntagConversationRequest other) { } /** - * conversation_id

    conversation_id

    + *

    conversation_id

    + *

    conversation_id

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

    id

    + *

    tag_id

    + *

    tag_id

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -161,7 +163,8 @@ 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.

    + *

    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 f26fb15..655c033 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 @@ -90,7 +90,7 @@ public static TicketIdStage builder() { public interface TicketIdStage { /** - * ticket_id + *

    ticket_id

    */ TagIdStage ticketId(@NotNull String ticketId); @@ -99,14 +99,14 @@ public interface TicketIdStage { public interface TagIdStage { /** - * The unique identifier for the tag which is given by Intercom + *

    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. + *

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

    */ _FinalStage adminId(@NotNull String adminId); } @@ -137,7 +137,8 @@ public Builder from(UntagTicketRequest other) { } /** - * ticket_id

    ticket_id

    + *

    ticket_id

    + *

    ticket_id

    * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -148,7 +149,8 @@ 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

    + *

    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 @@ -159,7 +161,8 @@ 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.

    + *

    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 86ff399..daf7bc7 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 @@ -9,12 +9,14 @@ 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.types.Reference; 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) @@ -24,13 +26,18 @@ public final class Tag { private final String name; - private final int appliedAt; + private final Optional appliedAt; - private final Reference appliedBy; + private final Optional appliedBy; private final Map additionalProperties; - private Tag(String id, String name, int appliedAt, Reference appliedBy, Map additionalProperties) { + private Tag( + String id, + String name, + Optional appliedAt, + Optional appliedBy, + Map additionalProperties) { this.id = id; this.name = name; this.appliedAt = appliedAt; @@ -66,12 +73,12 @@ public String getName() { * @return The time when the tag was applied to the object */ @JsonProperty("applied_at") - public int getAppliedAt() { + public Optional getAppliedAt() { return appliedAt; } @JsonProperty("applied_by") - public Reference getAppliedBy() { + public Optional getAppliedBy() { return appliedBy; } @@ -89,7 +96,7 @@ public Map getAdditionalProperties() { private boolean equalTo(Tag other) { return id.equals(other.id) && name.equals(other.name) - && appliedAt == other.appliedAt + && appliedAt.equals(other.appliedAt) && appliedBy.equals(other.appliedBy); } @@ -109,7 +116,7 @@ public static IdStage builder() { public interface IdStage { /** - * The id of the tag + *

    The id of the tag

    */ NameStage id(@NotNull String id); @@ -118,35 +125,35 @@ public interface IdStage { public interface NameStage { /** - * The name of the tag + *

    The name of the tag

    */ - AppliedAtStage name(@NotNull String name); + _FinalStage name(@NotNull String name); } - public interface AppliedAtStage { + public interface _FinalStage { + Tag build(); + /** - * The time when the tag was applied to the object + *

    The time when the tag was applied to the object

    */ - AppliedByStage appliedAt(int appliedAt); - } + _FinalStage appliedAt(Optional appliedAt); - public interface AppliedByStage { - _FinalStage appliedBy(@NotNull Reference appliedBy); - } + _FinalStage appliedAt(Integer appliedAt); - public interface _FinalStage { - Tag build(); + _FinalStage appliedBy(Optional appliedBy); + + _FinalStage appliedBy(Reference appliedBy); } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, AppliedAtStage, AppliedByStage, _FinalStage { + public static final class Builder implements IdStage, NameStage, _FinalStage { private String id; private String name; - private int appliedAt; + private Optional appliedBy = Optional.empty(); - private Reference appliedBy; + private Optional appliedAt = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -163,7 +170,8 @@ public Builder from(Tag other) { } /** - * The id of the tag

    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 @@ -174,31 +182,47 @@ public NameStage id(@NotNull String id) { } /** - * The name of the tag

    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 @JsonSetter("name") - public AppliedAtStage name(@NotNull String name) { + public _FinalStage name(@NotNull String name) { this.name = Objects.requireNonNull(name, "name must not be null"); return this; } + @java.lang.Override + public _FinalStage appliedBy(Reference appliedBy) { + this.appliedBy = Optional.ofNullable(appliedBy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "applied_by", nulls = Nulls.SKIP) + public _FinalStage appliedBy(Optional appliedBy) { + this.appliedBy = appliedBy; + return this; + } + /** - * 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 - @JsonSetter("applied_at") - public AppliedByStage appliedAt(int appliedAt) { - this.appliedAt = appliedAt; + public _FinalStage appliedAt(Integer appliedAt) { + this.appliedAt = Optional.ofNullable(appliedAt); return this; } + /** + *

    The time when the tag was applied to the object

    + */ @java.lang.Override - @JsonSetter("applied_by") - public _FinalStage appliedBy(@NotNull Reference appliedBy) { - this.appliedBy = Objects.requireNonNull(appliedBy, "appliedBy must not be null"); + @JsonSetter(value = "applied_at", nulls = Nulls.SKIP) + public _FinalStage appliedAt(Optional appliedAt) { + this.appliedAt = appliedAt; return this; } diff --git a/src/main/java/com/intercom/api/types/DividerComponent.java b/src/main/java/com/intercom/api/resources/tags/types/TagBasic.java similarity index 52% rename from src/main/java/com/intercom/api/types/DividerComponent.java rename to src/main/java/com/intercom/api/resources/tags/types/TagBasic.java index 3cada54..cadc71b 100644 --- a/src/main/java/com/intercom/api/types/DividerComponent.java +++ b/src/main/java/com/intercom/api/resources/tags/types/TagBasic.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.intercom.api.types; +package com.intercom.api.resources.tags.types; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -18,23 +18,37 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = DividerComponent.Builder.class) -public final class DividerComponent { +@JsonDeserialize(builder = TagBasic.Builder.class) +public final class TagBasic { + private final Optional type; + private final Optional id; - private final Optional bottomMargin; + private final Optional name; private final Map additionalProperties; - private DividerComponent( - Optional id, Optional bottomMargin, Map additionalProperties) { + private TagBasic( + Optional type, + Optional id, + Optional name, + Map additionalProperties) { + this.type = type; this.id = id; - this.bottomMargin = bottomMargin; + this.name = name; this.additionalProperties = additionalProperties; } /** - * @return A unique identifier for the component. + * @return value is "tag" + */ + @JsonProperty("type") + public Optional getType() { + return type; + } + + /** + * @return The id of the tag */ @JsonProperty("id") public Optional getId() { @@ -42,17 +56,17 @@ public Optional getId() { } /** - * @return Disables a component's margin-bottom of 10px. + * @return The name of the tag */ - @JsonProperty("bottom_margin") - public Optional getBottomMargin() { - return bottomMargin; + @JsonProperty("name") + public Optional getName() { + return name; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof DividerComponent && equalTo((DividerComponent) other); + return other instanceof TagBasic && equalTo((TagBasic) other); } @JsonAnyGetter @@ -60,13 +74,13 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(DividerComponent other) { - return id.equals(other.id) && bottomMargin.equals(other.bottomMargin); + 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.id, this.bottomMargin); + return Objects.hash(this.type, this.id, this.name); } @java.lang.Override @@ -80,23 +94,40 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional type = Optional.empty(); + private Optional id = Optional.empty(); - private Optional bottomMargin = Optional.empty(); + private Optional name = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(DividerComponent other) { + public Builder from(TagBasic other) { + type(other.getType()); id(other.getId()); - bottomMargin(other.getBottomMargin()); + 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; } /** - *

    A unique identifier for the component.

    + *

    The id of the tag

    */ @JsonSetter(value = "id", nulls = Nulls.SKIP) public Builder id(Optional id) { @@ -110,21 +141,21 @@ public Builder id(String id) { } /** - *

    Disables a component's margin-bottom of 10px.

    + *

    The name of the tag

    */ - @JsonSetter(value = "bottom_margin", nulls = Nulls.SKIP) - public Builder bottomMargin(Optional bottomMargin) { - this.bottomMargin = bottomMargin; + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; return this; } - public Builder bottomMargin(String bottomMargin) { - this.bottomMargin = Optional.ofNullable(bottomMargin); + public Builder name(String name) { + this.name = Optional.ofNullable(name); return this; } - public DividerComponent build() { - return new DividerComponent(id, bottomMargin, additionalProperties); + public TagBasic build() { + return new TagBasic(type, id, name, additionalProperties); } } } 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 ee53855..fcf8bda 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 @@ -103,19 +103,19 @@ public TagsCreateRequestBody deserialize(JsonParser p, DeserializationContext co Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, CreateOrUpdateTagRequest.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, TagCompanyRequest.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, UntagCompanyRequest.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, TagMultipleUsersRequest.class)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { } throw new JsonParseException(p, "Failed to deserialize"); } diff --git a/src/main/java/com/intercom/api/resources/teams/AsyncRawTeamsClient.java b/src/main/java/com/intercom/api/resources/teams/AsyncRawTeamsClient.java index 6091ba7..7891fc2 100644 --- a/src/main/java/com/intercom/api/resources/teams/AsyncRawTeamsClient.java +++ b/src/main/java/com/intercom/api/resources/teams/AsyncRawTeamsClient.java @@ -54,7 +54,6 @@ public CompletableFuture> list(RequestOptions req .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(); @@ -66,12 +65,12 @@ public CompletableFuture> list(RequestOptions req @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TeamList.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TeamList.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -81,11 +80,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -120,7 +117,6 @@ public CompletableFuture> find(FindTeamRequest reques .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(); @@ -132,12 +128,12 @@ public CompletableFuture> find(FindTeamRequest reques @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class), response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Team.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -154,11 +150,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); diff --git a/src/main/java/com/intercom/api/resources/teams/RawTeamsClient.java b/src/main/java/com/intercom/api/resources/teams/RawTeamsClient.java index 0f7511e..3028dd7 100644 --- a/src/main/java/com/intercom/api/resources/teams/RawTeamsClient.java +++ b/src/main/java/com/intercom/api/resources/teams/RawTeamsClient.java @@ -50,7 +50,6 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { .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(); @@ -59,11 +58,11 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TeamList.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TeamList.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -72,11 +71,9 @@ public IntercomHttpResponse list(RequestOptions requestOptions) { } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -102,7 +99,6 @@ public IntercomHttpResponse find(FindTeamRequest request, RequestOptions r .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(); @@ -111,11 +107,11 @@ public IntercomHttpResponse find(FindTeamRequest request, RequestOptions r } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Team.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 401: @@ -128,11 +124,9 @@ public IntercomHttpResponse find(FindTeamRequest request, RequestOptions r } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 a402fa0..8ddf0bb 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 @@ -67,7 +67,7 @@ public static TeamIdStage builder() { public interface TeamIdStage { /** - * The unique identifier of a given team. + *

    The unique identifier of a given team.

    */ _FinalStage teamId(@NotNull String teamId); @@ -94,7 +94,8 @@ 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.

    + *

    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 3a166c1..1de053c 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 @@ -13,37 +13,47 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.AdminPriorityLevel; -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 = Team.Builder.class) public final class Team { - private final String id; + private final Optional type; - private final String name; + private final Optional id; - private final List adminIds; + private final Optional name; + + private final Optional> adminIds; private final Optional adminPriorityLevel; + private final Optional assignmentLimit; + + private final Optional distributionMethod; + private final Map additionalProperties; private Team( - String id, - String name, - List adminIds, + Optional type, + Optional id, + Optional name, + Optional> adminIds, Optional adminPriorityLevel, + Optional assignmentLimit, + Optional distributionMethod, Map additionalProperties) { + this.type = type; this.id = id; this.name = name; this.adminIds = adminIds; this.adminPriorityLevel = adminPriorityLevel; + this.assignmentLimit = assignmentLimit; + this.distributionMethod = distributionMethod; this.additionalProperties = additionalProperties; } @@ -51,15 +61,15 @@ private Team( * @return Value is always "team" */ @JsonProperty("type") - public String getType() { - return "team"; + public Optional getType() { + return type; } /** * @return The id of the team */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -67,7 +77,7 @@ public String getId() { * @return The name of the team */ @JsonProperty("name") - public String getName() { + public Optional getName() { return name; } @@ -75,7 +85,7 @@ public String getName() { * @return The list of admin IDs that are a part of the team. */ @JsonProperty("admin_ids") - public List getAdminIds() { + public Optional> getAdminIds() { return adminIds; } @@ -84,6 +94,22 @@ public Optional getAdminPriorityLevel() { return adminPriorityLevel; } + /** + * @return The assignment limit for the team. This field is only present when the team's distribution type is load balanced. + */ + @JsonProperty("assignment_limit") + public Optional getAssignmentLimit() { + return assignmentLimit; + } + + /** + * @return Describes how assignments are distributed among the team members + */ + @JsonProperty("distribution_method") + public Optional getDistributionMethod() { + return distributionMethod; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -96,15 +122,25 @@ public Map getAdditionalProperties() { } private boolean equalTo(Team other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && name.equals(other.name) && adminIds.equals(other.adminIds) - && adminPriorityLevel.equals(other.adminPriorityLevel); + && adminPriorityLevel.equals(other.adminPriorityLevel) + && assignmentLimit.equals(other.assignmentLimit) + && distributionMethod.equals(other.distributionMethod); } @java.lang.Override public int hashCode() { - return Objects.hash(this.id, this.name, this.adminIds, this.adminPriorityLevel); + return Objects.hash( + this.type, + this.id, + this.name, + this.adminIds, + this.adminPriorityLevel, + this.assignmentLimit, + this.distributionMethod); } @java.lang.Override @@ -112,136 +148,147 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - - _FinalStage addAllAdminIds(List adminIds); - - _FinalStage adminPriorityLevel(Optional adminPriorityLevel); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - _FinalStage adminPriorityLevel(AdminPriorityLevel adminPriorityLevel); - } + private Optional id = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, _FinalStage { - private String id; + private Optional name = Optional.empty(); - private String name; + private Optional> adminIds = Optional.empty(); private Optional adminPriorityLevel = Optional.empty(); - private List adminIds = new ArrayList<>(); + private Optional assignmentLimit = Optional.empty(); + + private Optional distributionMethod = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Team other) { + type(other.getType()); id(other.getId()); name(other.getName()); adminIds(other.getAdminIds()); adminPriorityLevel(other.getAdminPriorityLevel()); + assignmentLimit(other.getAssignmentLimit()); + distributionMethod(other.getDistributionMethod()); return this; } /** - * The id of the team

    The id of the team

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Value is always "team"

    */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @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 name of the team

    The name of the team

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id of the team

    */ - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(@NotNull String name) { - this.name = Objects.requireNonNull(name, "name must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - @java.lang.Override - public _FinalStage adminPriorityLevel(AdminPriorityLevel adminPriorityLevel) { - this.adminPriorityLevel = Optional.ofNullable(adminPriorityLevel); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } - @java.lang.Override - @JsonSetter(value = "admin_priority_level", nulls = Nulls.SKIP) - public _FinalStage adminPriorityLevel(Optional adminPriorityLevel) { - this.adminPriorityLevel = adminPriorityLevel; + /** + *

    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.

    - * @return Reference to {@code this} so that method calls can be chained together. */ - @java.lang.Override - public _FinalStage addAllAdminIds(List adminIds) { - this.adminIds.addAll(adminIds); + @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; } /** - *

    The list of admin IDs that are a part of the team.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The assignment limit for the team. This field is only present when the team's distribution type is load balanced.

    */ - @java.lang.Override - public _FinalStage addAdminIds(Integer adminIds) { - this.adminIds.add(adminIds); + @JsonSetter(value = "assignment_limit", nulls = Nulls.SKIP) + public Builder assignmentLimit(Optional assignmentLimit) { + this.assignmentLimit = assignmentLimit; + return this; + } + + public Builder assignmentLimit(Integer assignmentLimit) { + this.assignmentLimit = Optional.ofNullable(assignmentLimit); return this; } /** - *

    The list of admin IDs that are a part of the team.

    + *

    Describes how assignments are distributed among the team members

    */ - @java.lang.Override - @JsonSetter(value = "admin_ids", nulls = Nulls.SKIP) - public _FinalStage adminIds(List adminIds) { - this.adminIds.clear(); - this.adminIds.addAll(adminIds); + @JsonSetter(value = "distribution_method", nulls = Nulls.SKIP) + public Builder distributionMethod(Optional distributionMethod) { + this.distributionMethod = distributionMethod; + return this; + } + + public Builder distributionMethod(String distributionMethod) { + this.distributionMethod = Optional.ofNullable(distributionMethod); return this; } - @java.lang.Override public Team build() { - return new Team(id, name, adminIds, adminPriorityLevel, additionalProperties); + return new Team( + type, + id, + name, + adminIds, + adminPriorityLevel, + assignmentLimit, + distributionMethod, + additionalProperties); } } } 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 56fcbfa..5552fb3 100644 --- a/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/AsyncRawTicketsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -15,11 +16,15 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; 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.DeleteTicketResponse; 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; @@ -27,6 +32,7 @@ import com.intercom.api.types.TicketList; import com.intercom.api.types.TicketReply; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -90,13 +96,12 @@ public CompletableFuture> reply( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketReply.class), - response)); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TicketReply.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -118,11 +123,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -140,14 +143,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can create a new ticket. */ - public CompletableFuture> create(CreateTicketRequest request) { + public CompletableFuture>> create(CreateTicketRequest request) { return create(request, null); } /** * You can create a new ticket. */ - public CompletableFuture> create( + public CompletableFuture>> create( CreateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -171,17 +174,19 @@ public CompletableFuture> create( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -191,11 +196,87 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Jobs.class), response)); + return; + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -213,14 +294,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can fetch the details of a single ticket. */ - public CompletableFuture> get(FindTicketRequest request) { + public CompletableFuture>> get(FindTicketRequest request) { return get(request, null); } /** * You can fetch the details of a single ticket. */ - public CompletableFuture> get( + public CompletableFuture>> get( FindTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -231,24 +312,25 @@ public CompletableFuture> get( .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<>(); + 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { future.completeExceptionally(new UnauthorizedError( @@ -258,11 +340,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -280,14 +360,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * You can update a ticket. */ - public CompletableFuture> update(UpdateTicketRequest request) { + public CompletableFuture>> update(UpdateTicketRequest request) { return update(request, null); } /** * You can update a ticket. */ - public CompletableFuture> update( + public CompletableFuture>> update( UpdateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -312,17 +392,96 @@ public CompletableFuture> update( 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response)); return; } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getTicketId()) + .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()) { String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeleteTicketResponse.class), + response)); + return; + } try { switch (response.code()) { case 401: @@ -339,11 +498,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); @@ -376,14 +533,15 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -394,6 +552,14 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -412,7 +578,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture>> search(SearchRequest request) { + public CompletableFuture>>> search(SearchRequest request) { return search(request, null); } @@ -434,14 +600,15 @@ public CompletableFuture>> searc *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -452,6 +619,14 @@ public CompletableFuture>> searc * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -470,7 +645,7 @@ public CompletableFuture>> searc * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture>> search( + public CompletableFuture>>> search( SearchRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -494,20 +669,22 @@ public CompletableFuture>> searc 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()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { TicketList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketList.class); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TicketList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) .flatMap(StartingAfterPaging::getStartingAfter); Optional pagination = request.getPagination() - .map(pagination_ -> StartingAfterPaging.builder() + .map((StartingAfterPaging pagination_) -> StartingAfterPaging.builder() .from(pagination_) .startingAfter(startingAfter) .build()); @@ -515,26 +692,25 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getTickets(); + List> result = + parsedResponse.getTickets().orElse(Collections.emptyList()); future.complete(new IntercomHttpResponse<>( - new SyncPagingIterable(startingAfter.isPresent(), result, () -> { - try { - return search(nextRequest, requestOptions) - .get() - .body(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - }), + new SyncPagingIterable>( + startingAfter.isPresent(), result, parsedResponse, () -> { + try { + return search(nextRequest, requestOptions) + .get() + .body(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + }), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally(new IntercomException("Network error executing HTTP request", e)); 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 5bb05fd..0d014e0 100644 --- a/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/AsyncTicketsClient.java @@ -6,13 +6,18 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; 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.DeleteTicketResponse; 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.Optional; import java.util.concurrent.CompletableFuture; public class AsyncTicketsClient { @@ -49,45 +54,75 @@ public CompletableFuture reply(ReplyToTicketRequest request, Reques /** * You can create a new ticket. */ - public CompletableFuture create(CreateTicketRequest request) { + public CompletableFuture> create(CreateTicketRequest request) { return this.rawClient.create(request).thenApply(response -> response.body()); } /** * You can create a new ticket. */ - public CompletableFuture create(CreateTicketRequest request, RequestOptions requestOptions) { + public CompletableFuture> create(CreateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.create(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 get(FindTicketRequest request) { + public CompletableFuture> get(FindTicketRequest request) { return this.rawClient.get(request).thenApply(response -> response.body()); } /** * You can fetch the details of a single ticket. */ - public CompletableFuture get(FindTicketRequest request, RequestOptions requestOptions) { + public CompletableFuture> get(FindTicketRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } /** * You can update a ticket. */ - public CompletableFuture update(UpdateTicketRequest request) { + public CompletableFuture> update(UpdateTicketRequest request) { return this.rawClient.update(request).thenApply(response -> response.body()); } /** * You can update a ticket. */ - public CompletableFuture update(UpdateTicketRequest request, RequestOptions requestOptions) { + public CompletableFuture> update(UpdateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.update(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.

    @@ -106,14 +141,15 @@ public CompletableFuture update(UpdateTicketRequest request, RequestOpti *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -124,6 +160,14 @@ public CompletableFuture update(UpdateTicketRequest request, RequestOpti * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -142,7 +186,7 @@ public CompletableFuture update(UpdateTicketRequest request, RequestOpti * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture> search(SearchRequest request) { + public CompletableFuture>> search(SearchRequest request) { return this.rawClient.search(request).thenApply(response -> response.body()); } @@ -164,14 +208,15 @@ public CompletableFuture> search(SearchRequest reques *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -182,6 +227,14 @@ public CompletableFuture> search(SearchRequest reques * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -200,7 +253,8 @@ public CompletableFuture> search(SearchRequest reques * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public CompletableFuture> search(SearchRequest request, RequestOptions requestOptions) { + public CompletableFuture>> search( + SearchRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).thenApply(response -> response.body()); } } 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 843c70a..e14e2b1 100644 --- a/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/RawTicketsClient.java @@ -4,6 +4,7 @@ package com.intercom.api.resources.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; @@ -15,11 +16,15 @@ import com.intercom.api.errors.BadRequestError; import com.intercom.api.errors.NotFoundError; import com.intercom.api.errors.UnauthorizedError; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; 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.DeleteTicketResponse; 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; @@ -27,6 +32,7 @@ import com.intercom.api.types.TicketList; import com.intercom.api.types.TicketReply; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Optional; import okhttp3.Headers; @@ -81,11 +87,11 @@ public IntercomHttpResponse reply(ReplyToTicketRequest request, Req } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketReply.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TicketReply.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -101,11 +107,9 @@ public IntercomHttpResponse reply(ReplyToTicketRequest request, Req } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -114,14 +118,14 @@ public IntercomHttpResponse reply(ReplyToTicketRequest request, Req /** * You can create a new ticket. */ - public IntercomHttpResponse create(CreateTicketRequest request) { + public IntercomHttpResponse> create(CreateTicketRequest request) { return create(request, null); } /** * You can create a new ticket. */ - public IntercomHttpResponse create(CreateTicketRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> create(CreateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("tickets") @@ -146,11 +150,13 @@ public IntercomHttpResponse create(CreateTicketRequest request, RequestO } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -159,11 +165,70 @@ public IntercomHttpResponse create(CreateTicketRequest request, RequestO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, 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(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Jobs.class), response); + } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -172,14 +237,14 @@ public IntercomHttpResponse create(CreateTicketRequest request, RequestO /** * You can fetch the details of a single ticket. */ - public IntercomHttpResponse get(FindTicketRequest request) { + public IntercomHttpResponse> get(FindTicketRequest request) { return get(request, null); } /** * You can fetch the details of a single ticket. */ - public IntercomHttpResponse get(FindTicketRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> get(FindTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("tickets") @@ -189,7 +254,6 @@ public IntercomHttpResponse get(FindTicketRequest request, RequestOption .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(); @@ -198,11 +262,13 @@ public IntercomHttpResponse get(FindTicketRequest request, RequestOption } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { if (response.code() == 401) { throw new UnauthorizedError( @@ -211,11 +277,9 @@ public IntercomHttpResponse get(FindTicketRequest request, RequestOption } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -224,14 +288,14 @@ public IntercomHttpResponse get(FindTicketRequest request, RequestOption /** * You can update a ticket. */ - public IntercomHttpResponse update(UpdateTicketRequest request) { + public IntercomHttpResponse> update(UpdateTicketRequest request) { return update(request, null); } /** * You can update a ticket. */ - public IntercomHttpResponse update(UpdateTicketRequest request, RequestOptions requestOptions) { + public IntercomHttpResponse> update(UpdateTicketRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("tickets") @@ -257,11 +321,70 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new IntercomHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, new TypeReference>() {}), + response); } + 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 + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new IntercomApiException( + "Error with status code " + response.code(), response.code(), errorBody, 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.getTicketId()) + .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(); String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new IntercomHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, DeleteTicketResponse.class), response); + } try { switch (response.code()) { case 401: @@ -274,11 +397,9 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } @@ -302,14 +423,15 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -320,6 +442,14 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -338,7 +468,7 @@ public IntercomHttpResponse update(UpdateTicketRequest request, RequestO * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public IntercomHttpResponse> search(SearchRequest request) { + public IntercomHttpResponse>> search(SearchRequest request) { return search(request, null); } @@ -360,14 +490,15 @@ public IntercomHttpResponse> search(SearchRequest req *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -378,6 +509,14 @@ public IntercomHttpResponse> search(SearchRequest req * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -396,7 +535,7 @@ public IntercomHttpResponse> search(SearchRequest req * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public IntercomHttpResponse> search( + public IntercomHttpResponse>> search( SearchRequest request, RequestOptions requestOptions) { HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() @@ -422,15 +561,15 @@ public IntercomHttpResponse> search( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { - TicketList parsedResponse = - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketList.class); + TicketList parsedResponse = ObjectMappers.JSON_MAPPER.readValue(responseBodyString, TicketList.class); Optional startingAfter = parsedResponse .getPages() .flatMap(CursorPages::getNext) .flatMap(StartingAfterPaging::getStartingAfter); Optional pagination = request.getPagination() - .map(pagination_ -> StartingAfterPaging.builder() + .map((StartingAfterPaging pagination_) -> StartingAfterPaging.builder() .from(pagination_) .startingAfter(startingAfter) .build()); @@ -438,19 +577,17 @@ public IntercomHttpResponse> search( .from(request) .pagination(pagination) .build(); - List result = parsedResponse.getTickets(); + List> result = parsedResponse.getTickets().orElse(Collections.emptyList()); return new IntercomHttpResponse<>( - new SyncPagingIterable( - startingAfter.isPresent(), result, () -> search(nextRequest, requestOptions) + new SyncPagingIterable>( + startingAfter.isPresent(), result, parsedResponse, () -> search( + nextRequest, requestOptions) .body()), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new IntercomApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new IntercomException("Network error executing HTTP request", e); } 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 cee318a..841952f 100644 --- a/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java +++ b/src/main/java/com/intercom/api/resources/tickets/TicketsClient.java @@ -6,13 +6,18 @@ import com.intercom.api.core.ClientOptions; import com.intercom.api.core.RequestOptions; import com.intercom.api.core.pagination.SyncPagingIterable; +import com.intercom.api.resources.jobs.types.Jobs; +import com.intercom.api.resources.tickets.requests.CreateTicketRequest; +import com.intercom.api.resources.tickets.requests.DeleteTicketRequest; +import com.intercom.api.resources.tickets.requests.EnqueueCreateTicketRequest; 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.DeleteTicketResponse; 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.Optional; public class TicketsClient { protected final ClientOptions clientOptions; @@ -48,45 +53,73 @@ public TicketReply reply(ReplyToTicketRequest request, RequestOptions requestOpt /** * You can create a new ticket. */ - public Ticket create(CreateTicketRequest request) { + public Optional create(CreateTicketRequest request) { return this.rawClient.create(request).body(); } /** * You can create a new ticket. */ - public Ticket create(CreateTicketRequest request, RequestOptions requestOptions) { + public Optional create(CreateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.create(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 Ticket get(FindTicketRequest request) { + public Optional get(FindTicketRequest request) { return this.rawClient.get(request).body(); } /** * You can fetch the details of a single ticket. */ - public Ticket get(FindTicketRequest request, RequestOptions requestOptions) { + public Optional get(FindTicketRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).body(); } /** * You can update a ticket. */ - public Ticket update(UpdateTicketRequest request) { + public Optional update(UpdateTicketRequest request) { return this.rawClient.update(request).body(); } /** * You can update a ticket. */ - public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) { + public Optional update(UpdateTicketRequest request, RequestOptions requestOptions) { return this.rawClient.update(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.

    @@ -105,14 +138,15 @@ public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -123,6 +157,14 @@ public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -141,7 +183,7 @@ public Ticket update(UpdateTicketRequest request, RequestOptions requestOptions) * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public SyncPagingIterable search(SearchRequest request) { + public SyncPagingIterable> search(SearchRequest request) { return this.rawClient.search(request).body(); } @@ -163,14 +205,15 @@ public SyncPagingIterable search(SearchRequest request) { *
  • 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").

    + *

    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 | + * | title | String | + * | description | String | * | category | String | * | ticket_type_id | String | * | contact_ids | String | @@ -181,6 +224,14 @@ public SyncPagingIterable search(SearchRequest request) { * | state | String | * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer |

    + *

    {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the category field, specific terms must be used instead of the category names:

    + *
      + *
    • For Customer category tickets, use the term request.
    • + *
    • For Back-office category tickets, use the term task.
    • + *
    • For Tracker category tickets, use the term tracker. + * {% /admonition %}
    • + *
    *

    Accepted Operators

    *

    {% admonition type="info" name="Searching based on created_at" %} * You may use the <= or >= operators to search by created_at. @@ -199,7 +250,7 @@ public SyncPagingIterable search(SearchRequest request) { * | ^ | String | Starts With | * | $ | String | Ends With |

    */ - public SyncPagingIterable search(SearchRequest request, RequestOptions requestOptions) { + public SyncPagingIterable> search(SearchRequest request, RequestOptions requestOptions) { return this.rawClient.search(request, requestOptions).body(); } } diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java new file mode 100644 index 0000000..29ecd99 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/CreateTicketRequest.java @@ -0,0 +1,922 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.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 = CreateTicketRequest.Builder.class) +public final class CreateTicketRequest 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 CreateTicketRequest( + 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 CreateTicketRequest && equalTo((CreateTicketRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CreateTicketRequest 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(CreateTicketRequest other); + } + + public interface _FinalStage { + CreateTicketRequest 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(CreateTicketRequest 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) { + if (contacts != null) { + 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(); + if (contacts != null) { + this.contacts.addAll(contacts); + } + return this; + } + + @java.lang.Override + public CreateTicketRequest build() { + return new CreateTicketRequest( + 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 (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ExternalId.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Email.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @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 = 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 = 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/tickets/requests/DeleteTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/DeleteTicketRequest.java new file mode 100644 index 0000000..b07ea70 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/DeleteTicketRequest.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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 ticketId; + + private final Map additionalProperties; + + private DeleteTicketRequest(String ticketId, Map additionalProperties) { + this.ticketId = ticketId; + this.additionalProperties = additionalProperties; + } + + /** + * @return The unique identifier for the ticket which is given by Intercom. + */ + @JsonProperty("ticket_id") + public String getTicketId() { + return ticketId; + } + + @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 ticketId.equals(other.ticketId); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.ticketId); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static TicketIdStage builder() { + return new Builder(); + } + + public interface TicketIdStage { + /** + *

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

    + */ + _FinalStage ticketId(@NotNull String ticketId); + + Builder from(DeleteTicketRequest other); + } + + public interface _FinalStage { + DeleteTicketRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements TicketIdStage, _FinalStage { + private String ticketId; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DeleteTicketRequest other) { + ticketId(other.getTicketId()); + 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("ticket_id") + public _FinalStage ticketId(@NotNull String ticketId) { + this.ticketId = Objects.requireNonNull(ticketId, "ticketId must not be null"); + return this; + } + + @java.lang.Override + public DeleteTicketRequest build() { + return new DeleteTicketRequest(ticketId, additionalProperties); + } + } +} diff --git a/src/main/java/com/intercom/api/resources/tickets/requests/EnqueueCreateTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/EnqueueCreateTicketRequest.java new file mode 100644 index 0000000..d0492c1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/requests/EnqueueCreateTicketRequest.java @@ -0,0 +1,922 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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.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) { + if (contacts != null) { + 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(); + if (contacts != null) { + 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 (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, ExternalId.class)); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Email.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } + + @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 = 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 = 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/tickets/requests/FindTicketRequest.java b/src/main/java/com/intercom/api/resources/tickets/requests/FindTicketRequest.java index 6850516..70d97e5 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 @@ -67,7 +67,7 @@ public static TicketIdStage builder() { public interface TicketIdStage { /** - * The unique identifier for the ticket which is given by Intercom. + *

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

    */ _FinalStage ticketId(@NotNull String ticketId); @@ -94,7 +94,8 @@ 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.

    + *

    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 9392614..4c92a06 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 @@ -5,12 +5,10 @@ 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; @@ -27,7 +25,9 @@ public final class UpdateTicketRequest { private final Optional> ticketAttributes; - private final Optional state; + private final Optional ticketStateId; + + private final Optional companyId; private final Optional open; @@ -35,26 +35,32 @@ public final class UpdateTicketRequest { private final Optional snoozedUntil; - private final Optional assignment; + private final Optional adminId; + + private final Optional assigneeId; private final Map additionalProperties; private UpdateTicketRequest( String ticketId, Optional> ticketAttributes, - Optional state, + Optional ticketStateId, + Optional companyId, Optional open, Optional isShared, Optional snoozedUntil, - Optional assignment, + Optional adminId, + Optional assigneeId, Map additionalProperties) { this.ticketId = ticketId; this.ticketAttributes = ticketAttributes; - this.state = state; + this.ticketStateId = ticketStateId; + this.companyId = companyId; this.open = open; this.isShared = isShared; this.snoozedUntil = snoozedUntil; - this.assignment = assignment; + this.adminId = adminId; + this.assigneeId = assigneeId; this.additionalProperties = additionalProperties; } @@ -75,11 +81,19 @@ public Optional> getTicketAttributes() { } /** - * @return The state of the ticket. + * @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("state") - public Optional getState() { - return state; + @JsonProperty("company_id") + public Optional getCompanyId() { + return companyId; } /** @@ -106,9 +120,20 @@ public Optional getSnoozedUntil() { return snoozedUntil; } - @JsonProperty("assignment") - public Optional getAssignment() { - return assignment; + /** + * @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 @@ -125,11 +150,13 @@ public Map getAdditionalProperties() { private boolean equalTo(UpdateTicketRequest other) { return ticketId.equals(other.ticketId) && ticketAttributes.equals(other.ticketAttributes) - && state.equals(other.state) + && ticketStateId.equals(other.ticketStateId) + && companyId.equals(other.companyId) && open.equals(other.open) && isShared.equals(other.isShared) && snoozedUntil.equals(other.snoozedUntil) - && assignment.equals(other.assignment); + && adminId.equals(other.adminId) + && assigneeId.equals(other.assigneeId); } @java.lang.Override @@ -137,11 +164,13 @@ public int hashCode() { return Objects.hash( this.ticketId, this.ticketAttributes, - this.state, + this.ticketStateId, + this.companyId, this.open, this.isShared, this.snoozedUntil, - this.assignment); + this.adminId, + this.assigneeId); } @java.lang.Override @@ -155,7 +184,7 @@ public static TicketIdStage builder() { public interface TicketIdStage { /** - * The unique identifier for the ticket which is given by Intercom + *

    The unique identifier for the ticket which is given by Intercom

    */ _FinalStage ticketId(@NotNull String ticketId); @@ -173,11 +202,18 @@ public interface _FinalStage { _FinalStage ticketAttributes(Map ticketAttributes); /** - *

    The state of the ticket.

    + *

    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 state(Optional state); + _FinalStage companyId(Optional companyId); - _FinalStage state(State state); + _FinalStage companyId(String companyId); /** *

    Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it.

    @@ -200,16 +236,28 @@ public interface _FinalStage { _FinalStage snoozedUntil(Integer snoozedUntil); - _FinalStage assignment(Optional assignment); + /** + *

    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 assignment(Assignment assignment); + _FinalStage assigneeId(String assigneeId); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements TicketIdStage, _FinalStage { private String ticketId; - private Optional assignment = Optional.empty(); + private Optional assigneeId = Optional.empty(); + + private Optional adminId = Optional.empty(); private Optional snoozedUntil = Optional.empty(); @@ -217,7 +265,9 @@ public static final class Builder implements TicketIdStage, _FinalStage { private Optional open = Optional.empty(); - private Optional state = Optional.empty(); + private Optional companyId = Optional.empty(); + + private Optional ticketStateId = Optional.empty(); private Optional> ticketAttributes = Optional.empty(); @@ -230,16 +280,19 @@ private Builder() {} public Builder from(UpdateTicketRequest other) { ticketId(other.getTicketId()); ticketAttributes(other.getTicketAttributes()); - state(other.getState()); + ticketStateId(other.getTicketStateId()); + companyId(other.getCompanyId()); open(other.getOpen()); isShared(other.getIsShared()); snoozedUntil(other.getSnoozedUntil()); - assignment(other.getAssignment()); + 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

    + *

    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 @@ -249,16 +302,43 @@ public _FinalStage ticketId(@NotNull String ticketId) { 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 assignment(Assignment assignment) { - this.assignment = Optional.ofNullable(assignment); + 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 = "assignment", nulls = Nulls.SKIP) - public _FinalStage assignment(Optional assignment) { - this.assignment = assignment; + @JsonSetter(value = "admin_id", nulls = Nulls.SKIP) + public _FinalStage adminId(Optional adminId) { + this.adminId = adminId; return this; } @@ -323,246 +403,78 @@ public _FinalStage open(Optional open) { } /** - *

    The state of the ticket.

    + *

    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 state(State state) { - this.state = Optional.ofNullable(state); + public _FinalStage companyId(String companyId) { + this.companyId = Optional.ofNullable(companyId); return this; } /** - *

    The state of the ticket.

    + *

    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 = "state", nulls = Nulls.SKIP) - public _FinalStage state(Optional state) { - this.state = state; + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) + public _FinalStage companyId(Optional companyId) { + this.companyId = companyId; return this; } /** - *

    The attributes set on the ticket.

    + *

    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 ticketAttributes(Map ticketAttributes) { - this.ticketAttributes = Optional.ofNullable(ticketAttributes); + public _FinalStage ticketStateId(String ticketStateId) { + this.ticketStateId = Optional.ofNullable(ticketStateId); return this; } /** - *

    The attributes set on the ticket.

    + *

    The ID of the ticket state associated with the ticket type.

    */ @java.lang.Override - @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) - public _FinalStage ticketAttributes(Optional> ticketAttributes) { - this.ticketAttributes = ticketAttributes; + @JsonSetter(value = "ticket_state_id", nulls = Nulls.SKIP) + public _FinalStage ticketStateId(Optional ticketStateId) { + this.ticketStateId = ticketStateId; return this; } - @java.lang.Override - public UpdateTicketRequest build() { - return new UpdateTicketRequest( - ticketId, ticketAttributes, state, open, isShared, snoozedUntil, assignment, additionalProperties); - } - } - - public static final class State { - public static final State IN_PROGRESS = new State(Value.IN_PROGRESS, "in_progress"); - - public static final State RESOLVED = new State(Value.RESOLVED, "resolved"); - - public static final State WAITING_ON_CUSTOMER = new State(Value.WAITING_ON_CUSTOMER, "waiting_on_customer"); - - 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 IN_PROGRESS: - return visitor.visitInProgress(); - 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 State valueOf(String value) { - switch (value) { - case "in_progress": - return IN_PROGRESS; - case "resolved": - return RESOLVED; - case "waiting_on_customer": - return WAITING_ON_CUSTOMER; - default: - return new State(Value.UNKNOWN, value); - } - } - - public enum Value { - IN_PROGRESS, - - WAITING_ON_CUSTOMER, - - RESOLVED, - - UNKNOWN - } - - public interface Visitor { - T visitInProgress(); - - T visitWaitingOnCustomer(); - - T visitResolved(); - - T visitUnknown(String unknownType); - } - } - - @JsonInclude(JsonInclude.Include.NON_ABSENT) - @JsonDeserialize(builder = Assignment.Builder.class) - public static final class Assignment { - private final Optional adminId; - - private final Optional assigneeId; - - private final Map additionalProperties; - - private Assignment( - Optional adminId, Optional assigneeId, Map additionalProperties) { - this.adminId = adminId; - this.assigneeId = assigneeId; - this.additionalProperties = additionalProperties; - } - /** - * @return The ID of the admin performing the action. + *

    The attributes set on the ticket.

    + * @return Reference to {@code this} so that method calls can be chained together. */ - @JsonProperty("admin_id") - public Optional getAdminId() { - return adminId; + @java.lang.Override + public _FinalStage ticketAttributes(Map ticketAttributes) { + this.ticketAttributes = Optional.ofNullable(ticketAttributes); + return this; } /** - * @return The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. + *

    The attributes set on the ticket.

    */ - @JsonProperty("assignee_id") - public Optional getAssigneeId() { - return assigneeId; - } - - @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 adminId.equals(other.adminId) && assigneeId.equals(other.assigneeId); - } - @java.lang.Override - public int hashCode() { - return Objects.hash(this.adminId, this.assigneeId); + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public _FinalStage ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; + return this; } @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 adminId = Optional.empty(); - - private Optional assigneeId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Assignment other) { - adminId(other.getAdminId()); - assigneeId(other.getAssigneeId()); - 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; - return this; - } - - public Builder adminId(String adminId) { - this.adminId = Optional.ofNullable(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; - return this; - } - - public Builder assigneeId(String assigneeId) { - this.assigneeId = Optional.ofNullable(assigneeId); - return this; - } - - public Assignment build() { - return new Assignment(adminId, assigneeId, additionalProperties); - } + public UpdateTicketRequest build() { + return new UpdateTicketRequest( + ticketId, + ticketAttributes, + ticketStateId, + companyId, + open, + isShared, + snoozedUntil, + adminId, + assigneeId, + additionalProperties); } } } diff --git a/src/main/java/com/intercom/api/resources/tickets/types/DeleteTicketResponse.java b/src/main/java/com/intercom/api/resources/tickets/types/DeleteTicketResponse.java new file mode 100644 index 0000000..52ccea1 --- /dev/null +++ b/src/main/java/com/intercom/api/resources/tickets/types/DeleteTicketResponse.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.intercom.api.resources.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/tickets/types/Ticket.java b/src/main/java/com/intercom/api/resources/tickets/types/Ticket.java index 4fb4b46..3f4a197 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 @@ -17,28 +17,28 @@ import com.intercom.api.types.LinkedObjectList; import com.intercom.api.types.TicketParts; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; -import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = Ticket.Builder.class) public final class Ticket { - private final String id; + private final Optional type; - private final String ticketId; + private final Optional id; - private final Category category; + private final Optional ticketId; - private final Map ticketAttributes; + private final Optional category; - private final TicketState ticketState; + private final Optional> ticketAttributes; - private final TicketType ticketType; + private final Optional ticketState; - private final TicketContacts contacts; + private final Optional ticketType; + + private final Optional contacts; private final Optional adminAssigneeId; @@ -58,20 +58,17 @@ public final class Ticket { private final Optional isShared; - private final Optional ticketStateInternalLabel; - - private final Optional ticketStateExternalLabel; - private final Map additionalProperties; private Ticket( - String id, - String ticketId, - Category category, - Map ticketAttributes, - TicketState ticketState, - TicketType ticketType, - TicketContacts contacts, + Optional type, + Optional id, + Optional ticketId, + Optional category, + Optional> ticketAttributes, + Optional ticketState, + Optional ticketType, + Optional contacts, Optional adminAssigneeId, Optional teamAssigneeId, Optional createdAt, @@ -81,9 +78,8 @@ private Ticket( Optional linkedObjects, Optional ticketParts, Optional isShared, - Optional ticketStateInternalLabel, - Optional ticketStateExternalLabel, Map additionalProperties) { + this.type = type; this.id = id; this.ticketId = ticketId; this.category = category; @@ -100,8 +96,6 @@ private Ticket( this.linkedObjects = linkedObjects; this.ticketParts = ticketParts; this.isShared = isShared; - this.ticketStateInternalLabel = ticketStateInternalLabel; - this.ticketStateExternalLabel = ticketStateExternalLabel; this.additionalProperties = additionalProperties; } @@ -109,15 +103,15 @@ private Ticket( * @return Always ticket */ @JsonProperty("type") - public String getType() { - return "ticket"; + public Optional getType() { + return type; } /** * @return The unique identifier for the ticket which is given by Intercom. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -125,7 +119,7 @@ public String getId() { * @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 String getTicketId() { + public Optional getTicketId() { return ticketId; } @@ -133,30 +127,27 @@ public String getTicketId() { * @return Category of the Ticket. */ @JsonProperty("category") - public Category getCategory() { + public Optional getCategory() { return category; } @JsonProperty("ticket_attributes") - public Map getTicketAttributes() { + public Optional> getTicketAttributes() { return ticketAttributes; } - /** - * @return The state the ticket is currently in - */ @JsonProperty("ticket_state") - public TicketState getTicketState() { + public Optional getTicketState() { return ticketState; } @JsonProperty("ticket_type") - public TicketType getTicketType() { + public Optional getTicketType() { return ticketType; } @JsonProperty("contacts") - public TicketContacts getContacts() { + public Optional getContacts() { return contacts; } @@ -226,22 +217,6 @@ public Optional getIsShared() { return isShared; } - /** - * @return The state the ticket is currently in, in a human readable form - visible in Intercom - */ - @JsonProperty("ticket_state_internal_label") - public Optional getTicketStateInternalLabel() { - return ticketStateInternalLabel; - } - - /** - * @return The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. - */ - @JsonProperty("ticket_state_external_label") - public Optional getTicketStateExternalLabel() { - return ticketStateExternalLabel; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -254,7 +229,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(Ticket other) { - return id.equals(other.id) + return type.equals(other.type) + && id.equals(other.id) && ticketId.equals(other.ticketId) && category.equals(other.category) && ticketAttributes.equals(other.ticketAttributes) @@ -269,14 +245,13 @@ private boolean equalTo(Ticket other) { && snoozedUntil.equals(other.snoozedUntil) && linkedObjects.equals(other.linkedObjects) && ticketParts.equals(other.ticketParts) - && isShared.equals(other.isShared) - && ticketStateInternalLabel.equals(other.ticketStateInternalLabel) - && ticketStateExternalLabel.equals(other.ticketStateExternalLabel); + && isShared.equals(other.isShared); } @java.lang.Override public int hashCode() { return Objects.hash( + this.type, this.id, this.ticketId, this.category, @@ -292,9 +267,7 @@ public int hashCode() { this.snoozedUntil, this.linkedObjects, this.ticketParts, - this.isShared, - this.ticketStateInternalLabel, - this.ticketStateExternalLabel); + this.isShared); } @java.lang.Override @@ -302,181 +275,53 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - } - - public interface TicketTypeStage { - ContactsStage ticketType(@NotNull TicketType ticketType); - } - - public interface ContactsStage { - _FinalStage contacts(@NotNull TicketContacts contacts); - } - - public interface _FinalStage { - Ticket build(); - - _FinalStage ticketAttributes(Map ticketAttributes); - - _FinalStage putAllTicketAttributes(Map ticketAttributes); - - _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); - - _FinalStage linkedObjects(Optional linkedObjects); - - _FinalStage linkedObjects(LinkedObjectList linkedObjects); - - _FinalStage ticketParts(Optional ticketParts); - - _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); - } - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - TicketIdStage, - CategoryStage, - TicketStateStage, - TicketTypeStage, - ContactsStage, - _FinalStage { - private String id; + public static final class Builder { + private Optional type = Optional.empty(); - private String ticketId; + private Optional id = Optional.empty(); - private Category category; + private Optional ticketId = Optional.empty(); - private TicketState ticketState; + private Optional category = Optional.empty(); - private TicketType ticketType; + private Optional> ticketAttributes = Optional.empty(); - private TicketContacts contacts; + private Optional ticketState = Optional.empty(); - private Optional ticketStateExternalLabel = Optional.empty(); + private Optional ticketType = Optional.empty(); - private Optional ticketStateInternalLabel = Optional.empty(); + private Optional contacts = Optional.empty(); - private Optional isShared = Optional.empty(); + private Optional adminAssigneeId = Optional.empty(); - private Optional ticketParts = Optional.empty(); + private Optional teamAssigneeId = Optional.empty(); - private Optional linkedObjects = Optional.empty(); + private Optional createdAt = Optional.empty(); - private Optional snoozedUntil = Optional.empty(); + private Optional updatedAt = Optional.empty(); private Optional open = Optional.empty(); - private Optional updatedAt = Optional.empty(); - - private Optional createdAt = Optional.empty(); + private Optional snoozedUntil = Optional.empty(); - private Optional teamAssigneeId = Optional.empty(); + private Optional linkedObjects = Optional.empty(); - private Optional adminAssigneeId = Optional.empty(); + private Optional ticketParts = Optional.empty(); - private Map ticketAttributes = new LinkedHashMap<>(); + private Optional isShared = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(Ticket other) { + type(other.getType()); id(other.getId()); ticketId(other.getTicketId()); category(other.getCategory()); @@ -493,298 +338,232 @@ public Builder from(Ticket other) { linkedObjects(other.getLinkedObjects()); ticketParts(other.getTicketParts()); isShared(other.getIsShared()); - ticketStateInternalLabel(other.getTicketStateInternalLabel()); - ticketStateExternalLabel(other.getTicketStateExternalLabel()); 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. + *

    Always ticket

    */ - @java.lang.Override - @JsonSetter("id") - public TicketIdStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * 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 - @JsonSetter("ticket_id") - public CategoryStage ticketId(@NotNull String ticketId) { - this.ticketId = Objects.requireNonNull(ticketId, "ticketId must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * Category of the Ticket.

    Category of the Ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

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

    */ - @java.lang.Override - @JsonSetter("category") - public TicketStateStage category(@NotNull Category category) { - this.category = Objects.requireNonNull(category, "category must not be null"); + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; return this; } - /** - * 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 - @JsonSetter("ticket_state") - public TicketTypeStage ticketState(@NotNull TicketState ticketState) { - this.ticketState = Objects.requireNonNull(ticketState, "ticketState must not be null"); + public Builder id(String id) { + this.id = Optional.ofNullable(id); return this; } - @java.lang.Override - @JsonSetter("ticket_type") - public ContactsStage ticketType(@NotNull TicketType ticketType) { - this.ticketType = Objects.requireNonNull(ticketType, "ticketType must not be null"); + /** + *

    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; } - @java.lang.Override - @JsonSetter("contacts") - public _FinalStage contacts(@NotNull TicketContacts contacts) { - this.contacts = Objects.requireNonNull(contacts, "contacts must not be null"); + public Builder ticketId(String ticketId) { + this.ticketId = Optional.ofNullable(ticketId); return this; } /** - *

    The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    Category of the Ticket.

    */ - @java.lang.Override - public _FinalStage ticketStateExternalLabel(String ticketStateExternalLabel) { - this.ticketStateExternalLabel = Optional.ofNullable(ticketStateExternalLabel); + @JsonSetter(value = "category", nulls = Nulls.SKIP) + public Builder category(Optional category) { + this.category = category; 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) { - this.ticketStateExternalLabel = ticketStateExternalLabel; + public Builder category(Category category) { + this.category = Optional.ofNullable(category); return this; } - /** - *

    The state the ticket is currently in, in a human readable form - visible in Intercom

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage ticketStateInternalLabel(String ticketStateInternalLabel) { - this.ticketStateInternalLabel = Optional.ofNullable(ticketStateInternalLabel); + @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) + public Builder ticketAttributes(Optional> ticketAttributes) { + this.ticketAttributes = ticketAttributes; 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) { - this.ticketStateInternalLabel = ticketStateInternalLabel; + public Builder ticketAttributes(Map ticketAttributes) { + this.ticketAttributes = Optional.ofNullable(ticketAttributes); return this; } - /** - *

    Whether or not the ticket is shared with the customer.

    - * @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); + @JsonSetter(value = "ticket_state", nulls = Nulls.SKIP) + public Builder ticketState(Optional ticketState) { + this.ticketState = ticketState; 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) { - this.isShared = isShared; + public Builder ticketState(TicketState ticketState) { + this.ticketState = Optional.ofNullable(ticketState); return this; } - @java.lang.Override - public _FinalStage ticketParts(TicketParts ticketParts) { - this.ticketParts = Optional.ofNullable(ticketParts); + @JsonSetter(value = "ticket_type", nulls = Nulls.SKIP) + public Builder ticketType(Optional ticketType) { + this.ticketType = ticketType; return this; } - @java.lang.Override - @JsonSetter(value = "ticket_parts", nulls = Nulls.SKIP) - public _FinalStage ticketParts(Optional ticketParts) { - this.ticketParts = ticketParts; + public Builder ticketType(TicketType ticketType) { + this.ticketType = Optional.ofNullable(ticketType); return this; } - @java.lang.Override - public _FinalStage linkedObjects(LinkedObjectList linkedObjects) { - this.linkedObjects = Optional.ofNullable(linkedObjects); + @JsonSetter(value = "contacts", nulls = Nulls.SKIP) + public Builder contacts(Optional contacts) { + this.contacts = contacts; return this; } - @java.lang.Override - @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) - public _FinalStage linkedObjects(Optional linkedObjects) { - this.linkedObjects = linkedObjects; + public Builder contacts(TicketContacts contacts) { + this.contacts = Optional.ofNullable(contacts); return this; } /** - *

    The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id representing the admin assigned to the ticket.

    */ - @java.lang.Override - public _FinalStage snoozedUntil(Integer snoozedUntil) { - this.snoozedUntil = Optional.ofNullable(snoozedUntil); + @JsonSetter(value = "admin_assignee_id", nulls = Nulls.SKIP) + public Builder adminAssigneeId(Optional adminAssigneeId) { + this.adminAssigneeId = adminAssigneeId; 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) { - this.snoozedUntil = snoozedUntil; + public Builder adminAssigneeId(String adminAssigneeId) { + this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); return this; } /** - *

    Whether or not the ticket is open. If false, the ticket is closed.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id representing the team assigned to the ticket.

    */ - @java.lang.Override - public _FinalStage open(Boolean open) { - this.open = Optional.ofNullable(open); + @JsonSetter(value = "team_assignee_id", nulls = Nulls.SKIP) + public Builder teamAssigneeId(Optional teamAssigneeId) { + this.teamAssigneeId = teamAssigneeId; 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) { - this.open = open; + public Builder teamAssigneeId(String teamAssigneeId) { + this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); return this; } /** - *

    The last time the ticket was updated as a UTC Unix timestamp.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The time the ticket was created as a UTC Unix timestamp.

    */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + @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.

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

    The time the ticket was created as a UTC Unix timestamp.

    - * @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); + public Builder updatedAt(Integer updatedAt) { + this.updatedAt = Optional.ofNullable(updatedAt); return this; } /** - *

    The time the ticket was created as a UTC Unix timestamp.

    + *

    Whether or not the ticket is open. If false, the ticket is closed.

    */ - @java.lang.Override - @JsonSetter(value = "created_at", nulls = Nulls.SKIP) - public _FinalStage createdAt(Optional createdAt) { - this.createdAt = createdAt; + @JsonSetter(value = "open", nulls = Nulls.SKIP) + public Builder open(Optional open) { + this.open = open; return this; } - /** - *

    The id representing the team assigned to the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage teamAssigneeId(String teamAssigneeId) { - this.teamAssigneeId = Optional.ofNullable(teamAssigneeId); + public Builder open(Boolean open) { + this.open = Optional.ofNullable(open); return this; } /** - *

    The id representing the team assigned to the ticket.

    + *

    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 = "team_assignee_id", nulls = Nulls.SKIP) - public _FinalStage teamAssigneeId(Optional teamAssigneeId) { - this.teamAssigneeId = teamAssigneeId; + @JsonSetter(value = "snoozed_until", nulls = Nulls.SKIP) + public Builder snoozedUntil(Optional snoozedUntil) { + this.snoozedUntil = snoozedUntil; return this; } - /** - *

    The id representing the admin assigned to the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage adminAssigneeId(String adminAssigneeId) { - this.adminAssigneeId = Optional.ofNullable(adminAssigneeId); + public Builder snoozedUntil(Integer snoozedUntil) { + this.snoozedUntil = Optional.ofNullable(snoozedUntil); 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) { - this.adminAssigneeId = adminAssigneeId; + @JsonSetter(value = "linked_objects", nulls = Nulls.SKIP) + public Builder linkedObjects(Optional linkedObjects) { + this.linkedObjects = linkedObjects; return this; } - @java.lang.Override - public _FinalStage ticketAttributes(String key, Object value) { - this.ticketAttributes.put(key, value); + public Builder linkedObjects(LinkedObjectList linkedObjects) { + this.linkedObjects = Optional.ofNullable(linkedObjects); return this; } - @java.lang.Override - public _FinalStage putAllTicketAttributes(Map ticketAttributes) { - this.ticketAttributes.putAll(ticketAttributes); + @JsonSetter(value = "ticket_parts", nulls = Nulls.SKIP) + public Builder ticketParts(Optional ticketParts) { + this.ticketParts = ticketParts; return this; } - @java.lang.Override - @JsonSetter(value = "ticket_attributes", nulls = Nulls.SKIP) - public _FinalStage ticketAttributes(Map ticketAttributes) { - this.ticketAttributes.clear(); - this.ticketAttributes.putAll(ticketAttributes); + 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; } - @java.lang.Override public Ticket build() { return new Ticket( + type, id, ticketId, category, @@ -801,109 +580,10 @@ public Ticket build() { linkedObjects, ticketParts, isShared, - ticketStateInternalLabel, - ticketStateExternalLabel, 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); - } - } - public static final class Category { public static final Category BACK_OFFICE = new Category(Value.BACK_OFFICE, "Back-office"); 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 b1406f9..06e83ad 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 @@ -13,20 +13,26 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.ContactReference; -import java.util.ArrayList; 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 List contacts; + private final Optional type; + + private final Optional> contacts; private final Map additionalProperties; - private TicketContacts(List contacts, Map additionalProperties) { + private TicketContacts( + Optional type, + Optional> contacts, + Map additionalProperties) { + this.type = type; this.contacts = contacts; this.additionalProperties = additionalProperties; } @@ -35,15 +41,15 @@ private TicketContacts(List contacts, Map addi * @return always contact.list */ @JsonProperty("type") - public String getType() { - return "contact.list"; + public Optional getType() { + return type; } /** * @return The list of contacts affected by this ticket. */ @JsonProperty("contacts") - public List getContacts() { + public Optional> getContacts() { return contacts; } @@ -59,12 +65,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(TicketContacts other) { - return contacts.equals(other.contacts); + return type.equals(other.type) && contacts.equals(other.contacts); } @java.lang.Override public int hashCode() { - return Objects.hash(this.contacts); + return Objects.hash(this.type, this.contacts); } @java.lang.Override @@ -78,7 +84,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private List contacts = new ArrayList<>(); + private Optional type = Optional.empty(); + + private Optional> contacts = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -86,32 +94,41 @@ public static final class Builder { private Builder() {} public Builder from(TicketContacts other) { + type(other.getType()); contacts(other.getContacts()); return this; } /** - *

    The list of contacts affected by this ticket.

    + *

    always contact.list

    */ - @JsonSetter(value = "contacts", nulls = Nulls.SKIP) - public Builder contacts(List contacts) { - this.contacts.clear(); - this.contacts.addAll(contacts); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - public Builder addContacts(ContactReference contacts) { - this.contacts.add(contacts); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } - public Builder addAllContacts(List contacts) { - this.contacts.addAll(contacts); + /** + *

    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(contacts, additionalProperties); + return new TicketContacts(type, contacts, additionalProperties); } } } 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 fd9f787..89d17ee 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 @@ -12,11 +12,17 @@ import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.intercom.api.core.ObjectMappers; import com.intercom.api.types.PartAttachment; import com.intercom.api.types.Reference; import com.intercom.api.types.TicketPartAuthor; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,17 +33,19 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TicketPart.Builder.class) public final class TicketPart { - private final String id; + private final Optional type; - private final String partType; + private final Optional id; + + private final Optional partType; private final Optional body; private final Optional previousTicketState; - private final TicketState ticketState; + private final Optional ticketState; - private final int createdAt; + private final Optional createdAt; private final Optional updatedAt; @@ -51,22 +59,30 @@ public final class TicketPart { private final Optional redacted; + private final Optional appPackageCode; + + private final Optional updatedAttributeData; + private final Map additionalProperties; private TicketPart( - String id, - String partType, + Optional type, + Optional id, + Optional partType, Optional body, Optional previousTicketState, - TicketState ticketState, - int createdAt, + 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; @@ -79,6 +95,8 @@ private TicketPart( this.attachments = attachments; this.externalId = externalId; this.redacted = redacted; + this.appPackageCode = appPackageCode; + this.updatedAttributeData = updatedAttributeData; this.additionalProperties = additionalProperties; } @@ -86,15 +104,15 @@ private TicketPart( * @return Always ticket_part */ @JsonProperty("type") - public String getType() { - return "ticket_part"; + public Optional getType() { + return type; } /** * @return The id representing the ticket part. */ @JsonProperty("id") - public String getId() { + public Optional getId() { return id; } @@ -102,7 +120,7 @@ public String getId() { * @return The type of ticket part. */ @JsonProperty("part_type") - public String getPartType() { + public Optional getPartType() { return partType; } @@ -126,7 +144,7 @@ public Optional getPreviousTicketState() { * @return The state of the ticket. */ @JsonProperty("ticket_state") - public TicketState getTicketState() { + public Optional getTicketState() { return ticketState; } @@ -134,7 +152,7 @@ public TicketState getTicketState() { * @return The time the ticket part was created. */ @JsonProperty("created_at") - public int getCreatedAt() { + public Optional getCreatedAt() { return createdAt; } @@ -183,6 +201,22 @@ 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; @@ -195,23 +229,27 @@ public Map getAdditionalProperties() { } private boolean equalTo(TicketPart other) { - return id.equals(other.id) + 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 == other.createdAt + && 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); + && 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, @@ -223,7 +261,9 @@ public int hashCode() { this.author, this.attachments, this.externalId, - this.redacted); + this.redacted, + this.appPackageCode, + this.updatedAttributeData); } @java.lang.Override @@ -231,130 +271,49 @@ public String toString() { return ObjectMappers.stringify(this); } - public static IdStage builder() { + public static Builder builder() { return new 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); - - _FinalStage author(Optional author); - - _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); + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional type = Optional.empty(); - _FinalStage externalId(String externalId); + private Optional id = Optional.empty(); - /** - *

    Whether or not the ticket part has been redacted.

    - */ - _FinalStage redacted(Optional redacted); + private Optional partType = Optional.empty(); - _FinalStage redacted(Boolean redacted); - } + private Optional body = Optional.empty(); - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, PartTypeStage, TicketStateStage, CreatedAtStage, _FinalStage { - private String id; + private Optional previousTicketState = Optional.empty(); - private String partType; + private Optional ticketState = Optional.empty(); - private TicketState ticketState; + private Optional createdAt = Optional.empty(); - private int createdAt; + private Optional updatedAt = Optional.empty(); - private Optional redacted = Optional.empty(); + private Optional assignedTo = Optional.empty(); - private Optional externalId = Optional.empty(); + private Optional author = Optional.empty(); private Optional> attachments = Optional.empty(); - private Optional author = Optional.empty(); - - private Optional assignedTo = Optional.empty(); + private Optional externalId = Optional.empty(); - private Optional updatedAt = Optional.empty(); + private Optional redacted = Optional.empty(); - private Optional previousTicketState = Optional.empty(); + private Optional appPackageCode = Optional.empty(); - private Optional body = Optional.empty(); + private Optional updatedAttributeData = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - @java.lang.Override public Builder from(TicketPart other) { + type(other.getType()); id(other.getId()); partType(other.getPartType()); body(other.getBody()); @@ -367,209 +326,221 @@ public Builder from(TicketPart other) { attachments(other.getAttachments()); externalId(other.getExternalId()); redacted(other.getRedacted()); + appPackageCode(other.getAppPackageCode()); + updatedAttributeData(other.getUpdatedAttributeData()); return this; } /** - * 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. + *

    Always ticket_part

    */ - @java.lang.Override - @JsonSetter("id") - public PartTypeStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; return this; } - /** - * 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 - @JsonSetter("part_type") - public TicketStateStage partType(@NotNull String partType) { - this.partType = Objects.requireNonNull(partType, "partType must not be null"); + public Builder type(String type) { + this.type = Optional.ofNullable(type); return this; } /** - * The state of the ticket.

    The state of the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The id representing the ticket part.

    */ - @java.lang.Override - @JsonSetter("ticket_state") - public CreatedAtStage ticketState(@NotNull TicketState ticketState) { - this.ticketState = Objects.requireNonNull(ticketState, "ticketState must not be null"); + @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 ticket part was created.

    The time the ticket part was created.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The type of ticket part.

    */ - @java.lang.Override - @JsonSetter("created_at") - public _FinalStage createdAt(int createdAt) { - this.createdAt = createdAt; + @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; } /** - *

    Whether or not the ticket part has been redacted.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The message body, which may contain HTML.

    */ - @java.lang.Override - public _FinalStage redacted(Boolean redacted) { - this.redacted = Optional.ofNullable(redacted); + @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; } /** - *

    Whether or not the ticket part has been redacted.

    + *

    The previous state of the ticket.

    */ - @java.lang.Override - @JsonSetter(value = "redacted", nulls = Nulls.SKIP) - public _FinalStage redacted(Optional redacted) { - this.redacted = redacted; + @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 external id of the ticket part

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The state of the ticket.

    */ - @java.lang.Override - public _FinalStage externalId(String externalId) { - this.externalId = Optional.ofNullable(externalId); + @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 external id of the ticket part

    + *

    The time the ticket part was created.

    */ - @java.lang.Override - @JsonSetter(value = "external_id", nulls = Nulls.SKIP) - public _FinalStage externalId(Optional externalId) { - this.externalId = externalId; + @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; } /** - *

    A list of attachments for the part.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    The last time the ticket part was updated.

    */ - @java.lang.Override - public _FinalStage attachments(List attachments) { - this.attachments = Optional.ofNullable(attachments); + @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; } /** - *

    A list of attachments for the part.

    + *

    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 = "attachments", nulls = Nulls.SKIP) - public _FinalStage attachments(Optional> attachments) { - this.attachments = attachments; + @JsonSetter(value = "assigned_to", nulls = Nulls.SKIP) + public Builder assignedTo(Optional assignedTo) { + this.assignedTo = assignedTo; return this; } - @java.lang.Override - public _FinalStage author(TicketPartAuthor author) { - this.author = Optional.ofNullable(author); + public Builder assignedTo(Reference assignedTo) { + this.assignedTo = Optional.ofNullable(assignedTo); return this; } - @java.lang.Override @JsonSetter(value = "author", nulls = Nulls.SKIP) - public _FinalStage author(Optional author) { + public Builder author(Optional author) { this.author = author; 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.)

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage assignedTo(Reference assignedTo) { - this.assignedTo = Optional.ofNullable(assignedTo); + public Builder author(TicketPartAuthor author) { + this.author = Optional.ofNullable(author); 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.)

    + *

    A list of attachments for the part.

    */ - @java.lang.Override - @JsonSetter(value = "assigned_to", nulls = Nulls.SKIP) - public _FinalStage assignedTo(Optional assignedTo) { - this.assignedTo = assignedTo; + @JsonSetter(value = "attachments", nulls = Nulls.SKIP) + public Builder attachments(Optional> attachments) { + this.attachments = attachments; return this; } - /** - *

    The last time the ticket part was updated.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage updatedAt(Integer updatedAt) { - this.updatedAt = Optional.ofNullable(updatedAt); + public Builder attachments(List attachments) { + this.attachments = Optional.ofNullable(attachments); return this; } /** - *

    The last time the ticket part was updated.

    + *

    The external id of the ticket part

    */ - @java.lang.Override - @JsonSetter(value = "updated_at", nulls = Nulls.SKIP) - public _FinalStage updatedAt(Optional updatedAt) { - this.updatedAt = updatedAt; + @JsonSetter(value = "external_id", nulls = Nulls.SKIP) + public Builder externalId(Optional externalId) { + this.externalId = externalId; return this; } - /** - *

    The previous state of the ticket.

    - * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage previousTicketState(PreviousTicketState previousTicketState) { - this.previousTicketState = Optional.ofNullable(previousTicketState); + public Builder externalId(String externalId) { + this.externalId = Optional.ofNullable(externalId); return this; } /** - *

    The previous state of the ticket.

    + *

    Whether or not the ticket part has been redacted.

    */ - @java.lang.Override - @JsonSetter(value = "previous_ticket_state", nulls = Nulls.SKIP) - public _FinalStage previousTicketState(Optional previousTicketState) { - this.previousTicketState = previousTicketState; + @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 message body, which may contain HTML.

    - * @return Reference to {@code this} so that method calls can be chained together. + *

    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.

    */ - @java.lang.Override - public _FinalStage body(String body) { - this.body = Optional.ofNullable(body); + @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 message body, which may contain HTML.

    + *

    The updated attribute data of the ticket part. Only present for attribute update parts.

    */ - @java.lang.Override - @JsonSetter(value = "body", nulls = Nulls.SKIP) - public _FinalStage body(Optional body) { - this.body = body; + @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; } - @java.lang.Override public TicketPart build() { return new TicketPart( + type, id, partType, body, @@ -582,6 +553,8 @@ public TicketPart build() { attachments, externalId, redacted, + appPackageCode, + updatedAttributeData, additionalProperties); } } @@ -780,4 +753,550 @@ public interface Visitor { 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 = Attribute.Builder.class) + public static final class Attribute { + private final String id; + + private final String label; + + private final Map additionalProperties; + + private Attribute(String id, String label, Map additionalProperties) { + this.id = id; + this.label = label; + this.additionalProperties = additionalProperties; + } + + /** + * @return The type of the object. Always 'attribute'. + */ + @JsonProperty("type") + public String getType() { + return "attribute"; + } + + /** + * @return The unique identifier of the attribute. + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * @return The human-readable name of the attribute. + */ + @JsonProperty("label") + public String getLabel() { + return label; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof Attribute && equalTo((Attribute) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(Attribute 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 { + /** + *

    The unique identifier of the attribute.

    + */ + LabelStage id(@NotNull String id); + + Builder from(Attribute other); + } + + public interface LabelStage { + /** + *

    The human-readable name of the attribute.

    + */ + _FinalStage label(@NotNull String label); + } + + public interface _FinalStage { + Attribute build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, LabelStage, _FinalStage { + private String id; + + private String label; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(Attribute other) { + id(other.getId()); + label(other.getLabel()); + return this; + } + + /** + *

    The unique identifier of the attribute.

    + *

    The unique identifier of the attribute.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("id") + public LabelStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + /** + *

    The human-readable name of the attribute.

    + *

    The human-readable name of the attribute.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("label") + public _FinalStage label(@NotNull String label) { + this.label = Objects.requireNonNull(label, "label must not be null"); + return this; + } + + @java.lang.Override + public Attribute build() { + return new Attribute(id, label, 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