Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.intercom:intercom-java:3.0.0-alpha1'
}
dependencies {
implementation("com.github.intercom:intercom-java:3.0.0-alpha1")
}
<dependency>
<groupId>com.github.intercom</groupId>
<artifactId>intercom-java</artifactId>
<version>3.0.0-alpha1</version>
</dependency>
libraryDependencies += "com.github.intercom" % "intercom-java" % "3.0.0-alpha1"
:dependencies [[com.github.intercom/intercom-java "3.0.0-alpha1"]]
The Intercom Java library provides convenient access to the Intercom APIs from Java.
Add the dependency in your build.gradle file:
dependencies {
implementation 'io.intercom:intercom-java'
}
Add the dependency in your pom.xml file:
<dependency>
<groupId>io.intercom</groupId>
<artifactId>intercom-java</artifactId>
<version>4.0.4</version>
</dependency>
A full reference for this library is available here.
Instantiate and use the client with the following:
package com.example.usage;
import com.intercom.api.Intercom;
import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest;
public class Example {
public static void main(String[] args) {
Intercom client = Intercom
.builder()
.token("<token>")
.build();
client.aiContent().createContentImportSource(
CreateContentImportSourceRequest
.builder()
.url("https://www.example.com")
.build()
);
}
}
This SDK allows you to configure different environments for API requests.
import com.intercom.api.Intercom;
import com.intercom.api.core.Environment;
Intercom client = Intercom
.builder()
.environment(Environment.USProduction)
.build();
You can set a custom base URL when constructing the client.
import com.intercom.api.Intercom;
Intercom client = Intercom
.builder()
.url("https://example.com")
.build();
When the API returns a non-success status code (4xx or 5xx response), an API exception will be thrown.
import com.intercom.api.core.IntercomApiApiException;
try{
client.aiContent().createContentImportSource(...);
} catch (IntercomApiApiException e){
// Do something with the API exception...
}
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:
import com.intercom.api.Intercom;
import okhttp3.OkHttpClient;
OkHttpClient customClient = ...;
Intercom client = Intercom
.builder()
.httpClient(customClient)
.build();
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). 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:
Use the maxRetries client option to configure this behavior.
import com.intercom.api.Intercom;
Intercom client = Intercom
.builder()
.maxRetries(1)
.build();
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
import com.intercom.api.Intercom;
import com.intercom.api.core.RequestOptions;
// Client level
Intercom client = Intercom
.builder()
.timeout(10)
.build();
// Request level
client.aiContent().createContentImportSource(
...,
RequestOptions
.builder()
.timeout(10)
.build()
);
The SDK allows you to add custom headers to requests. You can configure headers at the client level or at the request level.
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()
);
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().)
CreateContentImportSourceHttpResponse response = client.aiContent().withRawResponse().createContentImportSource(...);
System.out.println(response.body());
System.out.println(response.headers().get("X-My-Header"));
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
This SDK is generated using Fern. To regenerate the SDK after API changes:
fern/ directory of the Fern config repoIf you only need regeneration without publishing, you can empty credentials in generators.yml to skip the publish step:
# Example: Clear Maven credentials to skip publish
username: ""
password: ""
signing-key-id: ""
fern generate --group java-sdk
MAVEN_SIGNING_KEY_IDMAVEN_SIGNING_KEYMAVEN_SIGNING_PASSWORDAfter regenerating the SDK and merging the PR:
Manually create and push a Git tag for the release:
git tag v4.0.x
git push origin v4.0.x
The tag push triggers the publish workflow automatically. Ensure the version in the repo config aligns with the intended release.
Publishing requires:
MAVEN_SIGNING_KEY_IDMAVEN_SIGNING_KEYMAVEN_SIGNING_PASSWORDContributors without publish credentials can open regeneration PRs. Team members with credentials can complete the publish steps.
openapi-overrides.yml in the Intercom-OpenAPI repofern generate --group java-sdk