Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.6.0"
".": "1.7.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 116
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-373ca3e805c414f75a90b0088c57cbb60ff207abdca0a8e397c551de88606c4a.yml
openapi_spec_hash: 1c30d01bd9c38f8a2aa4bd088fbe69bc
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-a44cccd16bb58080f7cc0669999403f6ed3f77287fad901caa6fd2523f2fbafd.yml
openapi_spec_hash: af6444648d0b2a70b7f7ad234bd37541
config_hash: 1f535c1fa222aacf28b636eed21bec72
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.7.0 (2025-07-21)

Full Changelog: [v1.6.0...v1.7.0](https://github.com/orbcorp/orb-java/compare/v1.6.0...v1.7.0)

### Features

* **api:** api update ([b20980d](https://github.com/orbcorp/orb-java/commit/b20980d5162e0a0e584c6e977aaa5be5c0075211))
* **client:** add https config options ([15ac3d4](https://github.com/orbcorp/orb-java/commit/15ac3d448fcd79c2ea22344642242dc09692fbe0))
* **client:** allow configuring env via system properties ([c32c0d2](https://github.com/orbcorp/orb-java/commit/c32c0d240b8bf8b095bfce12461d34ea4f4a2460))


### Chores

* **internal:** refactor delegating from client to options ([12282fa](https://github.com/orbcorp/orb-java/commit/12282facf5a825f400e54331b80927859062ea32))

## 1.6.0 (2025-07-17)

Full Changelog: [v1.5.1...v1.6.0](https://github.com/orbcorp/orb-java/compare/v1.5.1...v1.6.0)
Expand Down
56 changes: 42 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.6.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.7.0)

<!-- x-release-please-end -->

Expand All @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho
### Gradle

```kotlin
implementation("com.withorb.api:orb-java:1.6.0")
implementation("com.withorb.api:orb-java:1.7.0")
```

### Maven
Expand All @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:1.6.0")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-java</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
</dependency>
```

Expand All @@ -46,7 +46,8 @@ import com.withorb.api.client.okhttp.OrbOkHttpClient;
import com.withorb.api.models.Customer;
import com.withorb.api.models.CustomerCreateParams;

// Configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
// Configures using the `orb.apiKey`, `orb.webhookSecret` and `orb.baseUrl` system properties
// Or configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
OrbClient client = OrbOkHttpClient.fromEnv();

CustomerCreateParams params = CustomerCreateParams.builder()
Expand All @@ -58,13 +59,14 @@ Customer customer = client.customers().create(params);

## Client configuration

Configure the client using environment variables:
Configure the client using system properties or environment variables:

```java
import com.withorb.api.client.OrbClient;
import com.withorb.api.client.okhttp.OrbOkHttpClient;

// Configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
// Configures using the `orb.apiKey`, `orb.webhookSecret` and `orb.baseUrl` system properties
// Or configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
OrbClient client = OrbOkHttpClient.fromEnv();
```

Expand All @@ -86,19 +88,22 @@ import com.withorb.api.client.OrbClient;
import com.withorb.api.client.okhttp.OrbOkHttpClient;

OrbClient client = OrbOkHttpClient.builder()
// Configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
// Configures using the `orb.apiKey`, `orb.webhookSecret` and `orb.baseUrl` system properties
Or configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
.fromEnv()
.apiKey("My API Key")
.build();
```

See this table for the available options:

| Setter | Environment variable | Required | Default value |
| --------------- | -------------------- | -------- | ------------------------------ |
| `apiKey` | `ORB_API_KEY` | true | - |
| `webhookSecret` | `ORB_WEBHOOK_SECRET` | false | - |
| `baseUrl` | `ORB_BASE_URL` | true | `"https://api.withorb.com/v1"` |
| Setter | System property | Environment variable | Required | Default value |
| --------------- | ------------------- | -------------------- | -------- | ------------------------------ |
| `apiKey` | `orb.apiKey` | `ORB_API_KEY` | true | - |
| `webhookSecret` | `orb.webhookSecret` | `ORB_WEBHOOK_SECRET` | false | - |
| `baseUrl` | `orb.baseUrl` | `ORB_BASE_URL` | true | `"https://api.withorb.com/v1"` |

System properties take precedence over environment variables.

> [!TIP]
> Don't create more than one client in the same application. Each client has a connection pool and
Expand Down Expand Up @@ -144,7 +149,8 @@ import com.withorb.api.models.Customer;
import com.withorb.api.models.CustomerCreateParams;
import java.util.concurrent.CompletableFuture;

// Configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
// Configures using the `orb.apiKey`, `orb.webhookSecret` and `orb.baseUrl` system properties
// Or configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
OrbClient client = OrbOkHttpClient.fromEnv();

CustomerCreateParams params = CustomerCreateParams.builder()
Expand All @@ -163,7 +169,8 @@ import com.withorb.api.models.Customer;
import com.withorb.api.models.CustomerCreateParams;
import java.util.concurrent.CompletableFuture;

// Configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
// Configures using the `orb.apiKey`, `orb.webhookSecret` and `orb.baseUrl` system properties
// Or configures using the `ORB_API_KEY`, `ORB_WEBHOOK_SECRET` and `ORB_BASE_URL` environment variables
OrbClientAsync client = OrbOkHttpClientAsync.fromEnv();

CustomerCreateParams params = CustomerCreateParams.builder()
Expand Down Expand Up @@ -440,6 +447,27 @@ OrbClient client = OrbOkHttpClient.builder()
.build();
```

### HTTPS

> [!NOTE]
> Most applications should not call these methods, and instead use the system defaults. The defaults include
> special optimizations that can be lost if the implementations are modified.

To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:

```java
import com.withorb.api.client.OrbClient;
import com.withorb.api.client.okhttp.OrbOkHttpClient;

OrbClient client = OrbOkHttpClient.builder()
.fromEnv()
// If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.
.sslSocketFactory(yourSSLSocketFactory)
.trustManager(yourTrustManager)
.hostnameVerifier(yourHostnameVerifier)
.build();
```

### Custom HTTP client

The SDK consists of three artifacts:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
allprojects {
group = "com.withorb.api"
version = "1.6.0" // x-release-please-version
version = "1.7.0" // x-release-please-version
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import java.io.InputStream
import java.net.Proxy
import java.time.Duration
import java.util.concurrent.CompletableFuture
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import okhttp3.Call
import okhttp3.Callback
import okhttp3.HttpUrl.Companion.toHttpUrl
Expand Down Expand Up @@ -189,13 +192,28 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC

private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null

fun timeout(timeout: Timeout) = apply { this.timeout = timeout }

fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())

fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }

fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
this.sslSocketFactory = sslSocketFactory
}

fun trustManager(trustManager: X509TrustManager?) = apply {
this.trustManager = trustManager
}

fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply {
this.hostnameVerifier = hostnameVerifier
}

fun build(): OkHttpClient =
OkHttpClient(
okhttp3.OkHttpClient.Builder()
Expand All @@ -204,6 +222,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
.writeTimeout(timeout.write())
.callTimeout(timeout.request())
.proxy(proxy)
.apply {
val sslSocketFactory = sslSocketFactory
val trustManager = trustManager
if (sslSocketFactory != null && trustManager != null) {
sslSocketFactory(sslSocketFactory, trustManager)
} else {
check((sslSocketFactory != null) == (trustManager != null)) {
"Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set"
}
}

hostnameVerifier?.let(::hostnameVerifier)
}
.build()
.apply {
// We usually make all our requests to the same host so it makes sense to
Expand Down
Loading