Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -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
}
}
11 changes: 0 additions & 11 deletions .github/workflows/label-ai-generated-prs.yml

This file was deleted.

113 changes: 97 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<dependency>
<groupId>io.intercom</groupId>
<artifactId>intercom-java</artifactId>
<version>4.0.0</version>
</dependency>
```

## Reference

A full reference for this library is available [here](https://github.com/intercom/intercom-java/blob/HEAD/./reference.md).

## Usage

Expand All @@ -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) {
Expand All @@ -22,14 +66,10 @@ public class Example {
.token("<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()
);
}
Expand Down Expand Up @@ -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...
}
```
Expand All @@ -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
Expand All @@ -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:

Expand Down Expand Up @@ -134,7 +176,7 @@ Intercom client = Intercom
.build();

// Request level
client.articles().create(
client.aiContent().createContentImportSource(
...,
RequestOptions
.builder()
Expand All @@ -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.
Expand Down
18 changes: 10 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}


Expand All @@ -46,7 +47,7 @@ java {

group = 'io.intercom'

version = '3.0.0'
version = '4.0.0'

jar {
dependsOn(":generatePomFileForMavenPublication")
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading
Loading