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.174.0"
".": "0.175.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 201
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-28ffd3b61bd618b2a60b46dd2afb8f52370c43e02cab2e9106465c3cffafb95a.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-ce741f23d99b551b38099da78d730af0cf9019e3b51e61bc988a5e5979c26143.yml
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.175.0 (2025-02-04)

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

### Features

* **api:** api update ([#756](https://github.com/Increase/increase-java/issues/756)) ([7087292](https://github.com/Increase/increase-java/commit/708729236be5d99454876a7d99a3e161ddb8e358))
* **client:** send client-side timeout headers ([#754](https://github.com/Increase/increase-java/issues/754)) ([4403efc](https://github.com/Increase/increase-java/commit/4403efc7197c379c1204d3b99c8cd9ea974ef758))

## 0.174.0 (2025-02-03)

Full Changelog: [v0.173.0...v0.174.0](https://github.com/Increase/increase-java/compare/v0.173.0...v0.174.0)
Expand Down
6 changes: 3 additions & 3 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.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.174.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.175.0)

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

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

```kotlin
implementation("com.increase.api:increase-java:0.174.0")
implementation("com.increase.api:increase-java:0.175.0")
```

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

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.increase.api"
version = "0.174.0" // x-release-please-version
version = "0.175.0" // x-release-please-version
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,11 @@ class OkHttpClient
private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) :
HttpClient {

private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient {
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") }
)
}

val timeout = requestOptions.timeout
if (timeout != null) {
clientBuilder
.connectTimeout(timeout)
.readTimeout(timeout)
.writeTimeout(timeout)
.callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30))
}

return clientBuilder.build()
}

override fun execute(
request: HttpRequest,
requestOptions: RequestOptions,
): HttpResponse {
val call = getClient(requestOptions).newCall(request.toRequest())
val call = newCall(request, requestOptions)

return try {
call.execute().toResponse()
Expand All @@ -81,18 +54,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

request.body?.run { future.whenComplete { _, _ -> close() } }

val call = getClient(requestOptions).newCall(request.toRequest())
call.enqueue(
object : Callback {
override fun onResponse(call: Call, response: Response) {
future.complete(response.toResponse())
}
newCall(request, requestOptions)
.enqueue(
object : Callback {
override fun onResponse(call: Call, response: Response) {
future.complete(response.toResponse())
}

override fun onFailure(call: Call, e: IOException) {
future.completeExceptionally(IncreaseIoException("Request failed", e))
override fun onFailure(call: Call, e: IOException) {
future.completeExceptionally(IncreaseIoException("Request failed", e))
}
}
}
)
)

return future
}
Expand All @@ -103,7 +76,35 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
okHttpClient.cache?.close()
}

private fun HttpRequest.toRequest(): Request {
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") }
)
}

val timeout = requestOptions.timeout
if (timeout != null) {
clientBuilder
.connectTimeout(timeout)
.readTimeout(timeout)
.writeTimeout(timeout)
.callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30))
}

val client = clientBuilder.build()
return client.newCall(request.toRequest(client))
}

private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request {
var body: RequestBody? = body?.toRequestBody()
// OkHttpClient always requires a request body for PUT and POST methods.
if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) {
Expand All @@ -115,6 +116,21 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
headers.values(name).forEach { builder.header(name, it) }
}

if (
!headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0
) {
builder.header(
"X-Stainless-Read-Timeout",
Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString()
)
}
if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) {
builder.header(
"X-Stainless-Timeout",
Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString()
)
}

return builder.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ private constructor(
/** Blue Ridge Bank, N.A. */
@JvmField val BLUE_RIDGE_BANK = of("blue_ridge_bank")

/** Core Bank */
@JvmField val CORE_BANK = of("core_bank")

/** First Internet Bank of Indiana */
@JvmField val FIRST_INTERNET_BANK = of("first_internet_bank")

Expand All @@ -561,6 +564,8 @@ private constructor(
enum class Known {
/** Blue Ridge Bank, N.A. */
BLUE_RIDGE_BANK,
/** Core Bank */
CORE_BANK,
/** First Internet Bank of Indiana */
FIRST_INTERNET_BANK,
/** Grasshopper Bank */
Expand All @@ -579,6 +584,8 @@ private constructor(
enum class Value {
/** Blue Ridge Bank, N.A. */
BLUE_RIDGE_BANK,
/** Core Bank */
CORE_BANK,
/** First Internet Bank of Indiana */
FIRST_INTERNET_BANK,
/** Grasshopper Bank */
Expand All @@ -597,6 +604,7 @@ private constructor(
fun value(): Value =
when (this) {
BLUE_RIDGE_BANK -> Value.BLUE_RIDGE_BANK
CORE_BANK -> Value.CORE_BANK
FIRST_INTERNET_BANK -> Value.FIRST_INTERNET_BANK
GRASSHOPPER_BANK -> Value.GRASSHOPPER_BANK
else -> Value._UNKNOWN
Expand All @@ -614,6 +622,7 @@ private constructor(
fun known(): Known =
when (this) {
BLUE_RIDGE_BANK -> Known.BLUE_RIDGE_BANK
CORE_BANK -> Known.CORE_BANK
FIRST_INTERNET_BANK -> Known.FIRST_INTERNET_BANK
GRASSHOPPER_BANK -> Known.GRASSHOPPER_BANK
else -> throw IncreaseInvalidDataException("Unknown Bank: $value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ private constructor(
/** Blue Ridge Bank, N.A. */
@JvmField val BLUE_RIDGE_BANK = of("blue_ridge_bank")

/** Core Bank */
@JvmField val CORE_BANK = of("core_bank")

/** First Internet Bank of Indiana */
@JvmField val FIRST_INTERNET_BANK = of("first_internet_bank")

Expand All @@ -357,6 +360,8 @@ private constructor(
enum class Known {
/** Blue Ridge Bank, N.A. */
BLUE_RIDGE_BANK,
/** Core Bank */
CORE_BANK,
/** First Internet Bank of Indiana */
FIRST_INTERNET_BANK,
/** Grasshopper Bank */
Expand All @@ -375,6 +380,8 @@ private constructor(
enum class Value {
/** Blue Ridge Bank, N.A. */
BLUE_RIDGE_BANK,
/** Core Bank */
CORE_BANK,
/** First Internet Bank of Indiana */
FIRST_INTERNET_BANK,
/** Grasshopper Bank */
Expand All @@ -393,6 +400,7 @@ private constructor(
fun value(): Value =
when (this) {
BLUE_RIDGE_BANK -> Value.BLUE_RIDGE_BANK
CORE_BANK -> Value.CORE_BANK
FIRST_INTERNET_BANK -> Value.FIRST_INTERNET_BANK
GRASSHOPPER_BANK -> Value.GRASSHOPPER_BANK
else -> Value._UNKNOWN
Expand All @@ -410,6 +418,7 @@ private constructor(
fun known(): Known =
when (this) {
BLUE_RIDGE_BANK -> Known.BLUE_RIDGE_BANK
CORE_BANK -> Known.CORE_BANK
FIRST_INTERNET_BANK -> Known.FIRST_INTERNET_BANK
GRASSHOPPER_BANK -> Known.GRASSHOPPER_BANK
else -> throw IncreaseInvalidDataException("Unknown Bank: $value")
Expand Down