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 @@
{
".": "0.544.0"
".": "0.545.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: 238
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase/increase-eaee3db1b6a076bc5c49879e3b3154e5ae466d0fd278917a3835f4ed0c9cce63.yml
openapi_spec_hash: 34a379fd12fbaa209f10dde757ede478
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase/increase-6484d90ce90f64f000ef24b6582fb2c5b75496c3c61748425fd581b910940d43.yml
openapi_spec_hash: fc75851d75e458b3d108f7641db28f04
config_hash: ac050010e5453883d5e5fa603554a2e0
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.545.0 (2026-05-07)

Full Changelog: [v0.544.0...v0.545.0](https://github.com/Increase/increase-java/compare/v0.544.0...v0.545.0)

### Features

* **client:** improve logging ([9b9bef7](https://github.com/Increase/increase-java/commit/9b9bef7b960b9042b143e72989fcd6c39461c327))


### Chores

* redact api-key headers in debug logs ([5343ac4](https://github.com/Increase/increase-java/commit/5343ac4d42079700f5efcf704b2356dbe643dd7f))

## 0.544.0 (2026-05-06)

Full Changelog: [v0.543.0...v0.544.0](https://github.com/Increase/increase-java/compare/v0.543.0...v0.544.0)
Expand Down
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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

[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.544.0)
[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.544.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.544.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.545.0)
[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.545.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.545.0)

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

Expand All @@ -13,7 +13,7 @@ The Increase Java SDK is similar to the Increase Kotlin SDK but with minor diffe

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

The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.544.0).
The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.545.0).

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

Expand All @@ -24,7 +24,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d
### Gradle

```kotlin
implementation("com.increase.api:increase-java:0.544.0")
implementation("com.increase.api:increase-java:0.545.0")
```

### Maven
Expand All @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.544.0")
<dependency>
<groupId>com.increase.api</groupId>
<artifactId>increase-java</artifactId>
<version>0.544.0</version>
<version>0.545.0</version>
</dependency>
```

Expand Down Expand Up @@ -412,8 +412,6 @@ while (true) {

## Logging

The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).

Enable logging by setting the `INCREASE_LOG` environment variable to `info`:

```sh
Expand All @@ -426,6 +424,19 @@ Or to `debug` for more verbose logging:
export INCREASE_LOG=debug
```

Or configure the client manually using the `logLevel` method:

```java
import com.increase.api.client.IncreaseClient;
import com.increase.api.client.okhttp.IncreaseOkHttpClient;
import com.increase.api.core.LogLevel;

IncreaseClient client = IncreaseOkHttpClient.builder()
.fromEnv()
.logLevel(LogLevel.INFO)
.build();
```

## Webhook Verification

We provide helper methods for verifying that a webhook request came from Increase, and not a malicious third party.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {

allprojects {
group = "com.increase.api"
version = "0.544.0" // x-release-please-version
version = "0.545.0" // x-release-please-version
}

subprojects {
Expand Down
1 change: 0 additions & 1 deletion increase-java-client-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies {
api(project(":increase-java-core"))

implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")

testImplementation(kotlin("test"))
testImplementation("org.assertj:assertj-core:3.27.7")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.increase.api.client.IncreaseClient
import com.increase.api.client.IncreaseClientImpl
import com.increase.api.core.ClientOptions
import com.increase.api.core.LogLevel
import com.increase.api.core.Sleeper
import com.increase.api.core.Timeout
import com.increase.api.core.http.AsyncStreamResponse
Expand Down Expand Up @@ -296,6 +297,15 @@ class IncreaseOkHttpClient private constructor() {
*/
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

/**
* The level at which to log request and response information.
*
* [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv].
*
* Defaults to [LogLevel.fromEnv].
*/
fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) }

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }

fun webhookSecret(webhookSecret: String?) = apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.increase.api.client.IncreaseClientAsync
import com.increase.api.client.IncreaseClientAsyncImpl
import com.increase.api.core.ClientOptions
import com.increase.api.core.LogLevel
import com.increase.api.core.Sleeper
import com.increase.api.core.Timeout
import com.increase.api.core.http.AsyncStreamResponse
Expand Down Expand Up @@ -296,6 +297,15 @@ class IncreaseOkHttpClientAsync private constructor() {
*/
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

/**
* The level at which to log request and response information.
*
* [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv].
*
* Defaults to [LogLevel.fromEnv].
*/
fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) }

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }

fun webhookSecret(webhookSecret: String?) = apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import okio.BufferedSink
import okio.buffer
import okio.sink
Expand Down Expand Up @@ -93,18 +92,6 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie
private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call {
val clientBuilder = okHttpClient.newBuilder()

val logLevel =
when (System.getenv("INCREASE_LOG")?.lowercase()) {
"info" -> HttpLoggingInterceptor.Level.BASIC
"debug" -> HttpLoggingInterceptor.Level.BODY
else -> null
}
if (logLevel != null) {
clientBuilder.addNetworkInterceptor(
HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") }
)
}

requestOptions.timeout?.let {
clientBuilder
.connectTimeout(it.connect())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.increase.api.core.http.AsyncStreamResponse
import com.increase.api.core.http.Headers
import com.increase.api.core.http.HttpClient
import com.increase.api.core.http.LoggingHttpClient
import com.increase.api.core.http.PhantomReachableClosingHttpClient
import com.increase.api.core.http.QueryParams
import com.increase.api.core.http.RetryingHttpClient
Expand Down Expand Up @@ -110,6 +111,14 @@ private constructor(
* Defaults to 2.
*/
@get:JvmName("maxRetries") val maxRetries: Int,
/**
* The level at which to log request and response information.
*
* [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv].
*
* Defaults to [LogLevel.fromEnv].
*/
@get:JvmName("logLevel") val logLevel: LogLevel,
@get:JvmName("apiKey") val apiKey: String,
private val webhookSecret: String?,
) {
Expand Down Expand Up @@ -174,6 +183,7 @@ private constructor(
private var responseValidation: Boolean = false
private var timeout: Timeout = Timeout.default()
private var maxRetries: Int = 2
private var logLevel: LogLevel = LogLevel.fromEnv()
private var apiKey: String? = null
private var webhookSecret: String? = null

Expand All @@ -191,6 +201,7 @@ private constructor(
responseValidation = clientOptions.responseValidation
timeout = clientOptions.timeout
maxRetries = clientOptions.maxRetries
logLevel = clientOptions.logLevel
apiKey = clientOptions.apiKey
webhookSecret = clientOptions.webhookSecret
}
Expand Down Expand Up @@ -322,6 +333,15 @@ private constructor(
*/
fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries }

/**
* The level at which to log request and response information.
*
* [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv].
*
* Defaults to [LogLevel.fromEnv].
*/
fun logLevel(logLevel: LogLevel) = apply { this.logLevel = logLevel }

fun apiKey(apiKey: String) = apply { this.apiKey = apiKey }

fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret }
Expand Down Expand Up @@ -426,6 +446,7 @@ private constructor(
* System properties take precedence over environment variables.
*/
fun fromEnv() = apply {
logLevel(LogLevel.fromEnv())
(System.getProperty("increase.baseUrl") ?: System.getenv("INCREASE_BASE_URL"))?.let {
baseUrl(it)
}
Expand Down Expand Up @@ -503,7 +524,13 @@ private constructor(
return ClientOptions(
httpClient,
RetryingHttpClient.builder()
.httpClient(httpClient)
.httpClient(
LoggingHttpClient.builder()
.httpClient(httpClient)
.clock(clock)
.level(logLevel)
.build()
)
.sleeper(sleeper)
.clock(clock)
.maxRetries(maxRetries)
Expand All @@ -520,6 +547,7 @@ private constructor(
responseValidation,
timeout,
maxRetries,
logLevel,
apiKey,
webhookSecret,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// File generated from our OpenAPI spec by Stainless.

package com.increase.api.core

/** The level at which to log request and response information. */
enum class LogLevel {
/** No logging. */
OFF,
/** Minimal request and response summary logs. No headers or bodies are logged. */
INFO,
/** [INFO] logs plus details about request failures. */
ERROR,
/**
* Full request and response logs. Sensitive headers are redacted, but sensitive data in request
* and response bodies may still be visible.
*/
DEBUG;

/** Returns whether this level is at or higher than the given [level]. */
fun shouldLog(level: LogLevel): Boolean = ordinal >= level.ordinal

companion object {

/** Returns a [LogLevel] based on the `INCREASE_LOG` environment variable. */
fun fromEnv() =
when (System.getenv("INCREASE_LOG")?.lowercase()) {
"info" -> INFO
"error" -> ERROR
"debug" -> DEBUG
else -> OFF
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.increase.api.core.http.Headers
import com.increase.api.errors.IncreaseInvalidDataException
import java.util.Collections
import java.util.SortedMap
import java.util.SortedSet
import java.util.concurrent.CompletableFuture
import java.util.concurrent.locks.Lock

Expand All @@ -17,6 +18,11 @@ internal fun <T : Any> T?.getOrThrow(name: String): T =
internal fun <T> List<T>.toImmutable(): List<T> =
if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList())

@JvmSynthetic
internal fun <V : Comparable<V>> SortedSet<V>.toImmutable(): SortedSet<V> =
if (isEmpty()) Collections.emptySortedSet()
else Collections.unmodifiableSortedSet(toSortedSet(comparator() ?: Comparator.naturalOrder()))

@JvmSynthetic
internal fun <K, V> Map<K, V>.toImmutable(): Map<K, V> =
if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap())
Expand Down
Loading
Loading