From e245a8943102c4fb296c1a6f99171bd827374daa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 02:43:19 +0000 Subject: [PATCH 1/9] fix(client): don't close client on `withOptions` usage when original is gc'd --- .../com/branddev/api/core/ClientOptions.kt | 16 ++++----- .../branddev/api/core/ClientOptionsTest.kt | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt index ab4990d..4091c88 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt @@ -86,7 +86,9 @@ private constructor( apiKey = clientOptions.apiKey } - fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility @@ -232,13 +234,11 @@ private constructor( return ClientOptions( httpClient, - PhantomReachableClosingHttpClient( - RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build() - ), + RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build(), checkJacksonVersionCompatibility, jsonMapper, clock, diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt new file mode 100644 index 0000000..382f2cb --- /dev/null +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.branddev.api.core + +import com.branddev.api.core.http.HttpClient +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + val httpClient = mock() + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} From 25962facfb9d0e4f9c672d522f12550b7b2cd206 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 1 Jul 2025 02:46:58 +0000 Subject: [PATCH 2/9] refactor(internal): minor `ClientOptionsTest` change --- .../src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt index 382f2cb..ba1072d 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/ClientOptionsTest.kt @@ -14,9 +14,10 @@ import org.mockito.kotlin.verify @ExtendWith(MockitoExtension::class) internal class ClientOptionsTest { + private val httpClient = mock() + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { - val httpClient = mock() var clientOptions = ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() verify(httpClient, never()).close() From ce1d54940f67278ab37e9a1c95596df5ba9dcc75 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 16 Jul 2025 05:27:56 +0000 Subject: [PATCH 3/9] chore(ci): bump `actions/setup-java` to v4 --- .github/workflows/publish-sonatype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index dec7aee..6e6b760 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: temurin java-version: | From 39f74d71d29a9a7cacca25ef0dd472f8c04397ba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 05:57:34 +0000 Subject: [PATCH 4/9] chore(internal): allow running specific example from cli --- brand-dev-java-example/build.gradle.kts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/brand-dev-java-example/build.gradle.kts b/brand-dev-java-example/build.gradle.kts index 839485c..2ffc061 100644 --- a/brand-dev-java-example/build.gradle.kts +++ b/brand-dev-java-example/build.gradle.kts @@ -17,5 +17,12 @@ tasks.withType().configureEach { } application { - mainClass = "com.branddev.api.example.Main" + // Use `./gradlew :brand-dev-java-example:run` to run `Main` + // Use `./gradlew :brand-dev-java-example:run -Dexample=Something` to run `SomethingExample` + mainClass = "com.branddev.api.example.${ + if (project.hasProperty("example")) + "${project.property("example")}Example" + else + "Main" + }" } From be0d35783fd23f1d9cffb4ff60857d6e2100769f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 18 Jul 2025 03:39:16 +0000 Subject: [PATCH 5/9] fix(client): ensure error handling always occurs --- .../api/core/handlers/ErrorHandler.kt | 26 +- .../services/async/BrandServiceAsyncImpl.kt | 37 ++- .../api/services/blocking/BrandServiceImpl.kt | 37 ++- .../api/services/ErrorHandlingTest.kt | 224 ++++++++++++++++++ 4 files changed, 265 insertions(+), 59 deletions(-) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt index 108c8bd..05bf0d0 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt @@ -19,7 +19,7 @@ import com.branddev.api.errors.UnprocessableEntityException import com.fasterxml.jackson.databind.json.JsonMapper @JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { val handler = jsonHandler(jsonMapper) return object : Handler { @@ -33,52 +33,52 @@ internal fun errorHandler(jsonMapper: JsonMapper): Handler { } @JvmSynthetic -internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = - object : Handler { - override fun handle(response: HttpResponse): T = +internal fun errorHandler(errorBodyHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): HttpResponse = when (val statusCode = response.statusCode()) { - in 200..299 -> this@withErrorHandler.handle(response) + in 200..299 -> response 400 -> throw BadRequestException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 401 -> throw UnauthorizedException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 403 -> throw PermissionDeniedException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 404 -> throw NotFoundException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 422 -> throw UnprocessableEntityException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() 429 -> throw RateLimitException.builder() .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() in 500..599 -> throw InternalServerException.builder() .statusCode(statusCode) .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() else -> throw UnexpectedStatusCodeException.builder() .statusCode(statusCode) .headers(response.headers()) - .body(errorHandler.handle(response)) + .body(errorBodyHandler.handle(response)) .build() } } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt index 03834cb..850ae3f 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt @@ -3,13 +3,13 @@ package com.branddev.api.services.async import com.branddev.api.core.ClientOptions -import com.branddev.api.core.JsonValue import com.branddev.api.core.RequestOptions +import com.branddev.api.core.handlers.errorBodyHandler import com.branddev.api.core.handlers.errorHandler import com.branddev.api.core.handlers.jsonHandler -import com.branddev.api.core.handlers.withErrorHandler import com.branddev.api.core.http.HttpMethod import com.branddev.api.core.http.HttpRequest +import com.branddev.api.core.http.HttpResponse import com.branddev.api.core.http.HttpResponse.Handler import com.branddev.api.core.http.HttpResponseFor import com.branddev.api.core.http.json @@ -123,7 +123,8 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BrandServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -134,7 +135,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BrandRetrieveParams, @@ -151,7 +151,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -165,7 +165,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val aiQueryHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun aiQuery( params: BrandAiQueryParams, @@ -183,7 +182,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { aiQueryHandler.handle(it) } .also { @@ -197,7 +196,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val identifyFromTransactionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun identifyFromTransaction( params: BrandIdentifyFromTransactionParams, @@ -214,7 +212,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { identifyFromTransactionHandler.handle(it) } .also { @@ -228,7 +226,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val prefetchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun prefetch( params: BrandPrefetchParams, @@ -246,7 +243,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { prefetchHandler.handle(it) } .also { @@ -260,7 +257,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val retrieveByTickerHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveByTicker( params: BrandRetrieveByTickerParams, @@ -277,7 +273,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveByTickerHandler.handle(it) } .also { @@ -291,7 +287,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val retrieveNaicsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveNaics( params: BrandRetrieveNaicsParams, @@ -308,7 +303,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveNaicsHandler.handle(it) } .also { @@ -322,7 +317,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val retrieveSimplifiedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveSimplified( params: BrandRetrieveSimplifiedParams, @@ -339,7 +333,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { retrieveSimplifiedHandler.handle(it) } .also { @@ -353,7 +347,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val screenshotHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun screenshot( params: BrandScreenshotParams, @@ -370,7 +363,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { screenshotHandler.handle(it) } .also { @@ -384,7 +377,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val searchHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun search( params: BrandSearchParams, @@ -401,7 +393,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { searchHandler.handle(it) } .also { @@ -415,7 +407,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val styleguideHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun styleguide( params: BrandStyleguideParams, @@ -432,7 +423,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> - response.parseable { + errorHandler.handle(response).parseable { response .use { styleguideHandler.handle(it) } .also { diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt index 8c64aad..b4ef287 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt @@ -3,13 +3,13 @@ package com.branddev.api.services.blocking import com.branddev.api.core.ClientOptions -import com.branddev.api.core.JsonValue import com.branddev.api.core.RequestOptions +import com.branddev.api.core.handlers.errorBodyHandler import com.branddev.api.core.handlers.errorHandler import com.branddev.api.core.handlers.jsonHandler -import com.branddev.api.core.handlers.withErrorHandler import com.branddev.api.core.http.HttpMethod import com.branddev.api.core.http.HttpRequest +import com.branddev.api.core.http.HttpResponse import com.branddev.api.core.http.HttpResponse.Handler import com.branddev.api.core.http.HttpResponseFor import com.branddev.api.core.http.json @@ -122,7 +122,8 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BrandService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer @@ -133,7 +134,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieve( params: BrandRetrieveParams, @@ -148,7 +148,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveHandler.handle(it) } .also { @@ -161,7 +161,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val aiQueryHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun aiQuery( params: BrandAiQueryParams, @@ -177,7 +176,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { aiQueryHandler.handle(it) } .also { @@ -190,7 +189,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val identifyFromTransactionHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun identifyFromTransaction( params: BrandIdentifyFromTransactionParams, @@ -205,7 +203,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { identifyFromTransactionHandler.handle(it) } .also { @@ -218,7 +216,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val prefetchHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun prefetch( params: BrandPrefetchParams, @@ -234,7 +231,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { prefetchHandler.handle(it) } .also { @@ -247,7 +244,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val retrieveByTickerHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveByTicker( params: BrandRetrieveByTickerParams, @@ -262,7 +258,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveByTickerHandler.handle(it) } .also { @@ -275,7 +271,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val retrieveNaicsHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveNaics( params: BrandRetrieveNaicsParams, @@ -290,7 +285,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveNaicsHandler.handle(it) } .also { @@ -303,7 +298,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val retrieveSimplifiedHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun retrieveSimplified( params: BrandRetrieveSimplifiedParams, @@ -318,7 +312,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { retrieveSimplifiedHandler.handle(it) } .also { @@ -331,7 +325,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val screenshotHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun screenshot( params: BrandScreenshotParams, @@ -346,7 +339,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { screenshotHandler.handle(it) } .also { @@ -359,7 +352,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val searchHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun search( params: BrandSearchParams, @@ -374,7 +366,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { searchHandler.handle(it) } .also { @@ -387,7 +379,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val styleguideHandler: Handler = jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) override fun styleguide( params: BrandStyleguideParams, @@ -402,7 +393,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { + return errorHandler.handle(response).parseable { response .use { styleguideHandler.handle(it) } .also { diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt index 5299ae6..0d4b258 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ErrorHandlingTest.kt @@ -87,6 +87,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve400WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve401() { @@ -115,6 +143,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve401WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve403() { @@ -143,6 +199,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve403WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve404() { @@ -171,6 +255,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve404WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve422() { @@ -199,6 +311,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve422WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve429() { @@ -227,6 +367,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve429WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve500() { @@ -255,6 +423,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve500WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieve999() { @@ -283,6 +479,34 @@ internal class ErrorHandlingTest { assertThat(e.body()).isEqualTo(ERROR_JSON) } + @Disabled("skipped: tests are disabled for the time being") + @Test + fun brandRetrieve999WithRawResponse() { + val brandService = client.brand().withRawResponse() + stubFor( + get(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + brandService.retrieve( + BrandRetrieveParams.builder() + .domain("domain") + .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) + .maxSpeed(true) + .timeoutMs(1L) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Disabled("skipped: tests are disabled for the time being") @Test fun brandRetrieveInvalidJsonBody() { From 66826635fed7d2d03e7d2deaff75b91fe0a7c034 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 19 Jul 2025 03:04:55 +0000 Subject: [PATCH 6/9] chore(internal): refactor delegating from client to options --- .../api/client/okhttp/BrandDevOkHttpClient.kt | 58 ++++++++++--------- .../okhttp/BrandDevOkHttpClientAsync.kt | 58 ++++++++++--------- .../com/branddev/api/core/ClientOptions.kt | 26 +++++++++ 3 files changed, 88 insertions(+), 54 deletions(-) diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt index 2d7f0a6..3e9d3b4 100644 --- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt +++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt @@ -8,10 +8,13 @@ import com.branddev.api.core.ClientOptions import com.branddev.api.core.Timeout import com.branddev.api.core.http.Headers import com.branddev.api.core.http.QueryParams +import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class BrandDevOkHttpClient private constructor() { @@ -27,10 +30,9 @@ class BrandDevOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + fun proxy(proxy: Proxy) = apply { this.proxy = proxy } /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -47,6 +49,30 @@ class BrandDevOkHttpClient private constructor() { fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } fun headers(headers: Map>) = apply { @@ -127,30 +153,6 @@ class BrandDevOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } - - /** - * Sets the maximum time allowed for a complete HTTP call, not including retries. - * - * See [Timeout.request] for more details. - * - * For fine-grained control, pass a [Timeout] object. - */ - fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } - - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } - - fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } - fun fromEnv() = apply { clientOptions.fromEnv() } /** @@ -161,7 +163,9 @@ class BrandDevOkHttpClient private constructor() { fun build(): BrandDevClient = BrandDevClientImpl( clientOptions - .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) + .httpClient( + OkHttpClient.builder().timeout(clientOptions.timeout()).proxy(proxy).build() + ) .build() ) } diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt index f682f7a..fe423d7 100644 --- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt +++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt @@ -8,10 +8,13 @@ import com.branddev.api.core.ClientOptions import com.branddev.api.core.Timeout import com.branddev.api.core.http.Headers import com.branddev.api.core.http.QueryParams +import com.branddev.api.core.jsonMapper import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class BrandDevOkHttpClientAsync private constructor() { @@ -29,10 +32,9 @@ class BrandDevOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + fun proxy(proxy: Proxy) = apply { this.proxy = proxy } /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -49,6 +51,30 @@ class BrandDevOkHttpClientAsync private constructor() { fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } fun headers(headers: Map>) = apply { @@ -129,30 +155,6 @@ class BrandDevOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } - - /** - * Sets the maximum time allowed for a complete HTTP call, not including retries. - * - * See [Timeout.request] for more details. - * - * For fine-grained control, pass a [Timeout] object. - */ - fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } - - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } - - fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } - fun fromEnv() = apply { clientOptions.fromEnv() } /** @@ -163,7 +165,9 @@ class BrandDevOkHttpClientAsync private constructor() { fun build(): BrandDevClientAsync = BrandDevClientAsyncImpl( clientOptions - .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) + .httpClient( + OkHttpClient.builder().timeout(clientOptions.timeout()).proxy(proxy).build() + ) .build() ) } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt index 4091c88..6c7c9c6 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt @@ -9,6 +9,7 @@ import com.branddev.api.core.http.QueryParams import com.branddev.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper import java.time.Clock +import java.time.Duration import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -16,6 +17,13 @@ class ClientOptions private constructor( private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee that + * the SDK will work correctly when using an incompatible Jackson version. + */ @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @@ -90,6 +98,13 @@ private constructor( this.httpClient = PhantomReachableClosingHttpClient(httpClient) } + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility } @@ -109,6 +124,15 @@ private constructor( fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } @@ -193,6 +217,8 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + fun timeout(): Timeout = timeout + fun fromEnv() = apply { System.getenv("BRAND_DEV_BASE_URL")?.let { baseUrl(it) } System.getenv("BRAND_DEV_API_KEY")?.let { apiKey(it) } From 508033b672147e010fc171a69fa6d7509acf519c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 19 Jul 2025 04:37:34 +0000 Subject: [PATCH 7/9] feat(client): add https config options --- README.md | 21 ++++++ .../api/client/okhttp/BrandDevOkHttpClient.kt | 67 ++++++++++++++++++- .../okhttp/BrandDevOkHttpClientAsync.kt | 67 ++++++++++++++++++- .../api/client/okhttp/OkHttpClient.kt | 31 +++++++++ 4 files changed, 182 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 79d8a0b..5d940d2 100644 --- a/README.md +++ b/README.md @@ -330,6 +330,27 @@ BrandDevClient client = BrandDevOkHttpClient.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.branddev.api.client.BrandDevClient; +import com.branddev.api.client.okhttp.BrandDevOkHttpClient; + +BrandDevClient client = BrandDevOkHttpClient.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: diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt index 3e9d3b4..8ecc0b0 100644 --- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt +++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt @@ -14,6 +14,9 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager import kotlin.jvm.optionals.getOrNull class BrandDevOkHttpClient private constructor() { @@ -31,8 +34,62 @@ class BrandDevOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -164,7 +221,13 @@ class BrandDevOkHttpClient private constructor() { BrandDevClientImpl( clientOptions .httpClient( - OkHttpClient.builder().timeout(clientOptions.timeout()).proxy(proxy).build() + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() ) .build() ) diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt index fe423d7..8940bdc 100644 --- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt +++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt @@ -14,6 +14,9 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager import kotlin.jvm.optionals.getOrNull class BrandDevOkHttpClientAsync private constructor() { @@ -33,8 +36,62 @@ class BrandDevOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -166,7 +223,13 @@ class BrandDevOkHttpClientAsync private constructor() { BrandDevClientAsyncImpl( clientOptions .httpClient( - OkHttpClient.builder().timeout(clientOptions.timeout()).proxy(proxy).build() + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() ) .build() ) diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt index cf36c66..f9dd922 100644 --- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt +++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt @@ -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 @@ -189,6 +192,9 @@ 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 } @@ -196,6 +202,18 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC 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() @@ -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 From 9c7c07621ea16a0b0adeaa57a96d826d9fa6c045 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 00:42:29 +0000 Subject: [PATCH 8/9] feat(api): manual updates --- .stats.yml | 6 +- .../BrandIdentifyFromTransactionResponse.kt | 232 +---------------- .../brand/BrandRetrieveByTickerResponse.kt | 232 +---------------- .../api/models/brand/BrandRetrieveResponse.kt | 236 +----------------- .../api/models/brand/BrandSearchParams.kt | 229 ----------------- .../api/models/brand/BrandSearchResponse.kt | 221 ---------------- .../api/services/async/BrandServiceAsync.kt | 27 -- .../services/async/BrandServiceAsyncImpl.kt | 39 --- .../api/services/blocking/BrandService.kt | 27 -- .../api/services/blocking/BrandServiceImpl.kt | 36 --- ...randIdentifyFromTransactionResponseTest.kt | 18 -- .../BrandRetrieveByTickerResponseTest.kt | 18 -- .../models/brand/BrandRetrieveResponseTest.kt | 18 -- .../api/models/brand/BrandSearchParamsTest.kt | 38 --- .../models/brand/BrandSearchResponseTest.kt | 39 --- .../services/async/BrandServiceAsyncTest.kt | 20 -- .../api/services/blocking/BrandServiceTest.kt | 17 -- .../main/kotlin/brand-dev.publish.gradle.kts | 2 +- 18 files changed, 13 insertions(+), 1442 deletions(-) delete mode 100644 brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchParams.kt delete mode 100644 brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchResponse.kt delete mode 100644 brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchParamsTest.kt delete mode 100644 brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchResponseTest.kt diff --git a/.stats.yml b/.stats.yml index b3fbada..7daf4a5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 10 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-aff48154fa37f0eb293cf660842ceab35c597509aee08f6b76df066828229c58.yml -openapi_spec_hash: a8ade5d7246da14e2ff161e829d11c12 +configured_endpoints: 9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-70f44e886c51bd700af031ad9b5c8f0042ef15fde038ba83ed08f61cd9d05266.yml +openapi_spec_hash: 9b834ba9e373689a8e2fbd8312b1f2de config_hash: 8f3ee44d690a305369555016a77ed016 diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt index 3ed57c4..5622cb0 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt @@ -224,7 +224,6 @@ private constructor( private val colors: JsonField>, private val description: JsonField, private val domain: JsonField, - private val fonts: JsonField>, private val logos: JsonField>, private val slogan: JsonField, private val socials: JsonField>, @@ -246,7 +245,6 @@ private constructor( @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), - @JsonProperty("fonts") @ExcludeMissing fonts: JsonField> = JsonMissing.of(), @JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(), @JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(), @JsonProperty("socials") @@ -260,7 +258,6 @@ private constructor( colors, description, domain, - fonts, logos, slogan, socials, @@ -309,14 +306,6 @@ private constructor( */ fun domain(): Optional = domain.getOptional("domain") - /** - * An array of fonts used by the brand's website - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fonts(): Optional> = fonts.getOptional("fonts") - /** * An array of logos associated with the brand * @@ -396,13 +385,6 @@ private constructor( */ @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain - /** - * Returns the raw JSON value of [fonts]. - * - * Unlike [fonts], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("fonts") @ExcludeMissing fun _fonts(): JsonField> = fonts - /** * Returns the raw JSON value of [logos]. * @@ -464,7 +446,6 @@ private constructor( private var colors: JsonField>? = null private var description: JsonField = JsonMissing.of() private var domain: JsonField = JsonMissing.of() - private var fonts: JsonField>? = null private var logos: JsonField>? = null private var slogan: JsonField = JsonMissing.of() private var socials: JsonField>? = null @@ -479,7 +460,6 @@ private constructor( colors = brand.colors.map { it.toMutableList() } description = brand.description domain = brand.domain - fonts = brand.fonts.map { it.toMutableList() } logos = brand.logos.map { it.toMutableList() } slogan = brand.slogan socials = brand.socials.map { it.toMutableList() } @@ -578,32 +558,6 @@ private constructor( */ fun domain(domain: JsonField) = apply { this.domain = domain } - /** An array of fonts used by the brand's website */ - fun fonts(fonts: List) = fonts(JsonField.of(fonts)) - - /** - * Sets [Builder.fonts] to an arbitrary JSON value. - * - * You should usually call [Builder.fonts] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fonts(fonts: JsonField>) = apply { - this.fonts = fonts.map { it.toMutableList() } - } - - /** - * Adds a single [Font] to [fonts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFont(font: Font) = apply { - fonts = - (fonts ?: JsonField.of(mutableListOf())).also { - checkKnown("fonts", it).add(font) - } - } - /** An array of logos associated with the brand */ fun logos(logos: List) = logos(JsonField.of(logos)) @@ -726,7 +680,6 @@ private constructor( (colors ?: JsonMissing.of()).map { it.toImmutable() }, description, domain, - (fonts ?: JsonMissing.of()).map { it.toImmutable() }, (logos ?: JsonMissing.of()).map { it.toImmutable() }, slogan, (socials ?: JsonMissing.of()).map { it.toImmutable() }, @@ -748,7 +701,6 @@ private constructor( colors().ifPresent { it.forEach { it.validate() } } description() domain() - fonts().ifPresent { it.forEach { it.validate() } } logos().ifPresent { it.forEach { it.validate() } } slogan() socials().ifPresent { it.forEach { it.validate() } } @@ -778,7 +730,6 @@ private constructor( (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (domain.asKnown().isPresent) 1 else 0) + - (fonts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (slogan.asKnown().isPresent) 1 else 0) + (socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -1957,183 +1908,6 @@ private constructor( "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" } - class Font - private constructor( - private val name: JsonField, - private val usage: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), - ) : this(name, usage, mutableMapOf()) - - /** - * Name of the font - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Usage of the font, e.g., 'title', 'body', 'button' - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun usage(): Optional = usage.getOptional("usage") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [usage]. - * - * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Font]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Font]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var usage: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(font: Font) = apply { - name = font.name - usage = font.usage - additionalProperties = font.additionalProperties.toMutableMap() - } - - /** Name of the font */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Usage of the font, e.g., 'title', 'body', 'button' */ - fun usage(usage: String) = usage(JsonField.of(usage)) - - /** - * Sets [Builder.usage] to an arbitrary JSON value. - * - * You should usually call [Builder.usage] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun usage(usage: JsonField) = apply { this.usage = usage } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Font]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Font = Font(name, usage, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Font = apply { - if (validated) { - return@apply - } - - name() - usage() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: BrandDevInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + (if (usage.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Font && name == other.name && usage == other.usage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, usage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Font{name=$name, usage=$usage, additionalProperties=$additionalProperties}" - } - class Logo private constructor( private val colors: JsonField>, @@ -3171,17 +2945,17 @@ private constructor( return true } - return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && fonts == other.fonts && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, fonts, logos, slogan, socials, stock, title, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, logos, slogan, socials, stock, title, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, fonts=$fonts, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" + "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt index a7c96ba..e8c395e 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt @@ -216,7 +216,6 @@ private constructor( private val colors: JsonField>, private val description: JsonField, private val domain: JsonField, - private val fonts: JsonField>, private val logos: JsonField>, private val slogan: JsonField, private val socials: JsonField>, @@ -238,7 +237,6 @@ private constructor( @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), - @JsonProperty("fonts") @ExcludeMissing fonts: JsonField> = JsonMissing.of(), @JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(), @JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(), @JsonProperty("socials") @@ -252,7 +250,6 @@ private constructor( colors, description, domain, - fonts, logos, slogan, socials, @@ -301,14 +298,6 @@ private constructor( */ fun domain(): Optional = domain.getOptional("domain") - /** - * An array of fonts used by the brand's website - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fonts(): Optional> = fonts.getOptional("fonts") - /** * An array of logos associated with the brand * @@ -388,13 +377,6 @@ private constructor( */ @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain - /** - * Returns the raw JSON value of [fonts]. - * - * Unlike [fonts], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("fonts") @ExcludeMissing fun _fonts(): JsonField> = fonts - /** * Returns the raw JSON value of [logos]. * @@ -456,7 +438,6 @@ private constructor( private var colors: JsonField>? = null private var description: JsonField = JsonMissing.of() private var domain: JsonField = JsonMissing.of() - private var fonts: JsonField>? = null private var logos: JsonField>? = null private var slogan: JsonField = JsonMissing.of() private var socials: JsonField>? = null @@ -471,7 +452,6 @@ private constructor( colors = brand.colors.map { it.toMutableList() } description = brand.description domain = brand.domain - fonts = brand.fonts.map { it.toMutableList() } logos = brand.logos.map { it.toMutableList() } slogan = brand.slogan socials = brand.socials.map { it.toMutableList() } @@ -570,32 +550,6 @@ private constructor( */ fun domain(domain: JsonField) = apply { this.domain = domain } - /** An array of fonts used by the brand's website */ - fun fonts(fonts: List) = fonts(JsonField.of(fonts)) - - /** - * Sets [Builder.fonts] to an arbitrary JSON value. - * - * You should usually call [Builder.fonts] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fonts(fonts: JsonField>) = apply { - this.fonts = fonts.map { it.toMutableList() } - } - - /** - * Adds a single [Font] to [fonts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFont(font: Font) = apply { - fonts = - (fonts ?: JsonField.of(mutableListOf())).also { - checkKnown("fonts", it).add(font) - } - } - /** An array of logos associated with the brand */ fun logos(logos: List) = logos(JsonField.of(logos)) @@ -718,7 +672,6 @@ private constructor( (colors ?: JsonMissing.of()).map { it.toImmutable() }, description, domain, - (fonts ?: JsonMissing.of()).map { it.toImmutable() }, (logos ?: JsonMissing.of()).map { it.toImmutable() }, slogan, (socials ?: JsonMissing.of()).map { it.toImmutable() }, @@ -740,7 +693,6 @@ private constructor( colors().ifPresent { it.forEach { it.validate() } } description() domain() - fonts().ifPresent { it.forEach { it.validate() } } logos().ifPresent { it.forEach { it.validate() } } slogan() socials().ifPresent { it.forEach { it.validate() } } @@ -770,7 +722,6 @@ private constructor( (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (domain.asKnown().isPresent) 1 else 0) + - (fonts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (slogan.asKnown().isPresent) 1 else 0) + (socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -1949,183 +1900,6 @@ private constructor( "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" } - class Font - private constructor( - private val name: JsonField, - private val usage: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), - ) : this(name, usage, mutableMapOf()) - - /** - * Name of the font - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Usage of the font, e.g., 'title', 'body', 'button' - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun usage(): Optional = usage.getOptional("usage") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [usage]. - * - * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Font]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Font]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var usage: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(font: Font) = apply { - name = font.name - usage = font.usage - additionalProperties = font.additionalProperties.toMutableMap() - } - - /** Name of the font */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Usage of the font, e.g., 'title', 'body', 'button' */ - fun usage(usage: String) = usage(JsonField.of(usage)) - - /** - * Sets [Builder.usage] to an arbitrary JSON value. - * - * You should usually call [Builder.usage] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun usage(usage: JsonField) = apply { this.usage = usage } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Font]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Font = Font(name, usage, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Font = apply { - if (validated) { - return@apply - } - - name() - usage() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: BrandDevInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + (if (usage.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Font && name == other.name && usage == other.usage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, usage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Font{name=$name, usage=$usage, additionalProperties=$additionalProperties}" - } - class Logo private constructor( private val colors: JsonField>, @@ -3163,17 +2937,17 @@ private constructor( return true } - return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && fonts == other.fonts && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, fonts, logos, slogan, socials, stock, title, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, logos, slogan, socials, stock, title, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, fonts=$fonts, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" + "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt index e384ca9..64e9022 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt @@ -213,7 +213,6 @@ private constructor( private val colors: JsonField>, private val description: JsonField, private val domain: JsonField, - private val fonts: JsonField>, private val logos: JsonField>, private val slogan: JsonField, private val socials: JsonField>, @@ -235,7 +234,6 @@ private constructor( @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), - @JsonProperty("fonts") @ExcludeMissing fonts: JsonField> = JsonMissing.of(), @JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(), @JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(), @JsonProperty("socials") @@ -249,7 +247,6 @@ private constructor( colors, description, domain, - fonts, logos, slogan, socials, @@ -298,15 +295,6 @@ private constructor( */ fun domain(): Optional = domain.getOptional("domain") - /** - * An array of fonts used by the brand's website. NOTE: This is deprecated and will be - * removed in the future. Please migrate to the styleguide API. - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fonts(): Optional> = fonts.getOptional("fonts") - /** * An array of logos associated with the brand * @@ -386,13 +374,6 @@ private constructor( */ @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain - /** - * Returns the raw JSON value of [fonts]. - * - * Unlike [fonts], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("fonts") @ExcludeMissing fun _fonts(): JsonField> = fonts - /** * Returns the raw JSON value of [logos]. * @@ -454,7 +435,6 @@ private constructor( private var colors: JsonField>? = null private var description: JsonField = JsonMissing.of() private var domain: JsonField = JsonMissing.of() - private var fonts: JsonField>? = null private var logos: JsonField>? = null private var slogan: JsonField = JsonMissing.of() private var socials: JsonField>? = null @@ -469,7 +449,6 @@ private constructor( colors = brand.colors.map { it.toMutableList() } description = brand.description domain = brand.domain - fonts = brand.fonts.map { it.toMutableList() } logos = brand.logos.map { it.toMutableList() } slogan = brand.slogan socials = brand.socials.map { it.toMutableList() } @@ -568,35 +547,6 @@ private constructor( */ fun domain(domain: JsonField) = apply { this.domain = domain } - /** - * An array of fonts used by the brand's website. NOTE: This is deprecated and will be - * removed in the future. Please migrate to the styleguide API. - */ - fun fonts(fonts: List) = fonts(JsonField.of(fonts)) - - /** - * Sets [Builder.fonts] to an arbitrary JSON value. - * - * You should usually call [Builder.fonts] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fonts(fonts: JsonField>) = apply { - this.fonts = fonts.map { it.toMutableList() } - } - - /** - * Adds a single [Font] to [fonts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFont(font: Font) = apply { - fonts = - (fonts ?: JsonField.of(mutableListOf())).also { - checkKnown("fonts", it).add(font) - } - } - /** An array of logos associated with the brand */ fun logos(logos: List) = logos(JsonField.of(logos)) @@ -719,7 +669,6 @@ private constructor( (colors ?: JsonMissing.of()).map { it.toImmutable() }, description, domain, - (fonts ?: JsonMissing.of()).map { it.toImmutable() }, (logos ?: JsonMissing.of()).map { it.toImmutable() }, slogan, (socials ?: JsonMissing.of()).map { it.toImmutable() }, @@ -741,7 +690,6 @@ private constructor( colors().ifPresent { it.forEach { it.validate() } } description() domain() - fonts().ifPresent { it.forEach { it.validate() } } logos().ifPresent { it.forEach { it.validate() } } slogan() socials().ifPresent { it.forEach { it.validate() } } @@ -771,7 +719,6 @@ private constructor( (colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (domain.asKnown().isPresent) 1 else 0) + - (fonts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (slogan.asKnown().isPresent) 1 else 0) + (socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -1950,183 +1897,6 @@ private constructor( "Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}" } - class Font - private constructor( - private val name: JsonField, - private val usage: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), - ) : this(name, usage, mutableMapOf()) - - /** - * Name of the font - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Usage of the font, e.g., 'title', 'body', 'button' - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun usage(): Optional = usage.getOptional("usage") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [usage]. - * - * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Font]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Font]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var usage: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(font: Font) = apply { - name = font.name - usage = font.usage - additionalProperties = font.additionalProperties.toMutableMap() - } - - /** Name of the font */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Usage of the font, e.g., 'title', 'body', 'button' */ - fun usage(usage: String) = usage(JsonField.of(usage)) - - /** - * Sets [Builder.usage] to an arbitrary JSON value. - * - * You should usually call [Builder.usage] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun usage(usage: JsonField) = apply { this.usage = usage } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Font]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Font = Font(name, usage, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Font = apply { - if (validated) { - return@apply - } - - name() - usage() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: BrandDevInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + (if (usage.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Font && name == other.name && usage == other.usage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, usage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Font{name=$name, usage=$usage, additionalProperties=$additionalProperties}" - } - class Logo private constructor( private val colors: JsonField>, @@ -3164,17 +2934,17 @@ private constructor( return true } - return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && fonts == other.fonts && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, fonts, logos, slogan, socials, stock, title, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, logos, slogan, socials, stock, title, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, fonts=$fonts, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" + "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchParams.kt deleted file mode 100644 index 54b1c3e..0000000 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.branddev.api.models.brand - -import com.branddev.api.core.Params -import com.branddev.api.core.checkRequired -import com.branddev.api.core.http.Headers -import com.branddev.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Search brands by query */ -class BrandSearchParams -private constructor( - private val query: String, - private val timeoutMs: Long?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** Query string to search brands */ - fun query(): String = query - - /** - * Optional timeout in milliseconds for the request. If the request takes longer than this - * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 - * minutes). - */ - fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BrandSearchParams]. - * - * The following fields are required: - * ```java - * .query() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandSearchParams]. */ - class Builder internal constructor() { - - private var query: String? = null - private var timeoutMs: Long? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(brandSearchParams: BrandSearchParams) = apply { - query = brandSearchParams.query - timeoutMs = brandSearchParams.timeoutMs - additionalHeaders = brandSearchParams.additionalHeaders.toBuilder() - additionalQueryParams = brandSearchParams.additionalQueryParams.toBuilder() - } - - /** Query string to search brands */ - fun query(query: String) = apply { this.query = query } - - /** - * Optional timeout in milliseconds for the request. If the request takes longer than this - * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 - * minutes). - */ - fun timeoutMs(timeoutMs: Long?) = apply { this.timeoutMs = timeoutMs } - - /** - * Alias for [Builder.timeoutMs]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun timeoutMs(timeoutMs: Long) = timeoutMs(timeoutMs as Long?) - - /** Alias for calling [Builder.timeoutMs] with `timeoutMs.orElse(null)`. */ - fun timeoutMs(timeoutMs: Optional) = timeoutMs(timeoutMs.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BrandSearchParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .query() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BrandSearchParams = - BrandSearchParams( - checkRequired("query", query), - timeoutMs, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - put("query", query) - timeoutMs?.let { put("timeoutMS", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BrandSearchParams && query == other.query && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(query, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "BrandSearchParams{query=$query, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchResponse.kt deleted file mode 100644 index a332456..0000000 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchResponse.kt +++ /dev/null @@ -1,221 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.branddev.api.models.brand - -import com.branddev.api.core.ExcludeMissing -import com.branddev.api.core.JsonField -import com.branddev.api.core.JsonMissing -import com.branddev.api.core.JsonValue -import com.branddev.api.errors.BrandDevInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional - -class BrandSearchResponse -private constructor( - private val domain: JsonField, - private val logo: JsonField, - private val title: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), - @JsonProperty("logo") @ExcludeMissing logo: JsonField = JsonMissing.of(), - @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - ) : this(domain, logo, title, mutableMapOf()) - - /** - * Domain name of the brand - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun domain(): Optional = domain.getOptional("domain") - - /** - * URL of the brand's logo - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun logo(): Optional = logo.getOptional("logo") - - /** - * Title or name of the brand - * - * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun title(): Optional = title.getOptional("title") - - /** - * Returns the raw JSON value of [domain]. - * - * Unlike [domain], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain - - /** - * Returns the raw JSON value of [logo]. - * - * Unlike [logo], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("logo") @ExcludeMissing fun _logo(): JsonField = logo - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [BrandSearchResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandSearchResponse]. */ - class Builder internal constructor() { - - private var domain: JsonField = JsonMissing.of() - private var logo: JsonField = JsonMissing.of() - private var title: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brandSearchResponse: BrandSearchResponse) = apply { - domain = brandSearchResponse.domain - logo = brandSearchResponse.logo - title = brandSearchResponse.title - additionalProperties = brandSearchResponse.additionalProperties.toMutableMap() - } - - /** Domain name of the brand */ - fun domain(domain: String) = domain(JsonField.of(domain)) - - /** - * Sets [Builder.domain] to an arbitrary JSON value. - * - * You should usually call [Builder.domain] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun domain(domain: JsonField) = apply { this.domain = domain } - - /** URL of the brand's logo */ - fun logo(logo: String) = logo(JsonField.of(logo)) - - /** - * Sets [Builder.logo] to an arbitrary JSON value. - * - * You should usually call [Builder.logo] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun logo(logo: JsonField) = apply { this.logo = logo } - - /** Title or name of the brand */ - fun title(title: String) = title(JsonField.of(title)) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BrandSearchResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BrandSearchResponse = - BrandSearchResponse(domain, logo, title, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): BrandSearchResponse = apply { - if (validated) { - return@apply - } - - domain() - logo() - title() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: BrandDevInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (domain.asKnown().isPresent) 1 else 0) + - (if (logo.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BrandSearchResponse && domain == other.domain && logo == other.logo && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(domain, logo, title, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BrandSearchResponse{domain=$domain, logo=$logo, title=$title, additionalProperties=$additionalProperties}" -} diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt index 2336ea9..02dd1d5 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt @@ -21,8 +21,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse import com.branddev.api.models.brand.BrandScreenshotParams import com.branddev.api.models.brand.BrandScreenshotResponse -import com.branddev.api.models.brand.BrandSearchParams -import com.branddev.api.models.brand.BrandSearchResponse import com.branddev.api.models.brand.BrandStyleguideParams import com.branddev.api.models.brand.BrandStyleguideResponse import java.util.concurrent.CompletableFuture @@ -147,16 +145,6 @@ interface BrandServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Search brands by query */ - fun search(params: BrandSearchParams): CompletableFuture> = - search(params, RequestOptions.none()) - - /** @see [search] */ - fun search( - params: BrandSearchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - /** * Beta feature: Automatically extract comprehensive design system information from a brand's * website including colors, typography, spacing, shadows, and UI components. @@ -302,21 +290,6 @@ interface BrandServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /brand/search`, but is otherwise the same as - * [BrandServiceAsync.search]. - */ - fun search( - params: BrandSearchParams - ): CompletableFuture>> = - search(params, RequestOptions.none()) - - /** @see [search] */ - fun search( - params: BrandSearchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> - /** * Returns a raw HTTP response for `get /brand/styleguide`, but is otherwise the same as * [BrandServiceAsync.styleguide]. diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt index 850ae3f..e032da1 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt @@ -31,8 +31,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse import com.branddev.api.models.brand.BrandScreenshotParams import com.branddev.api.models.brand.BrandScreenshotResponse -import com.branddev.api.models.brand.BrandSearchParams -import com.branddev.api.models.brand.BrandSearchResponse import com.branddev.api.models.brand.BrandStyleguideParams import com.branddev.api.models.brand.BrandStyleguideResponse import java.util.concurrent.CompletableFuture @@ -106,13 +104,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie // get /brand/screenshot withRawResponse().screenshot(params, requestOptions).thenApply { it.parse() } - override fun search( - params: BrandSearchParams, - requestOptions: RequestOptions, - ): CompletableFuture> = - // get /brand/search - withRawResponse().search(params, requestOptions).thenApply { it.parse() } - override fun styleguide( params: BrandStyleguideParams, requestOptions: RequestOptions, @@ -375,36 +366,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie } } - private val searchHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - - override fun search( - params: BrandSearchParams, - requestOptions: RequestOptions, - ): CompletableFuture>> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brand", "search") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { searchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } - } - } - } - } - } - private val styleguideHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt index d34e663..d5f473c 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt @@ -21,8 +21,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse import com.branddev.api.models.brand.BrandScreenshotParams import com.branddev.api.models.brand.BrandScreenshotResponse -import com.branddev.api.models.brand.BrandSearchParams -import com.branddev.api.models.brand.BrandSearchResponse import com.branddev.api.models.brand.BrandStyleguideParams import com.branddev.api.models.brand.BrandStyleguideResponse import com.google.errorprone.annotations.MustBeClosed @@ -141,16 +139,6 @@ interface BrandService { requestOptions: RequestOptions = RequestOptions.none(), ): BrandScreenshotResponse - /** Search brands by query */ - fun search(params: BrandSearchParams): List = - search(params, RequestOptions.none()) - - /** @see [search] */ - fun search( - params: BrandSearchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): List - /** * Beta feature: Automatically extract comprehensive design system information from a brand's * website including colors, typography, spacing, shadows, and UI components. @@ -302,21 +290,6 @@ interface BrandService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /brand/search`, but is otherwise the same as - * [BrandService.search]. - */ - @MustBeClosed - fun search(params: BrandSearchParams): HttpResponseFor> = - search(params, RequestOptions.none()) - - /** @see [search] */ - @MustBeClosed - fun search( - params: BrandSearchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> - /** * Returns a raw HTTP response for `get /brand/styleguide`, but is otherwise the same as * [BrandService.styleguide]. diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt index b4ef287..60fcddd 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt @@ -31,8 +31,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse import com.branddev.api.models.brand.BrandScreenshotParams import com.branddev.api.models.brand.BrandScreenshotResponse -import com.branddev.api.models.brand.BrandSearchParams -import com.branddev.api.models.brand.BrandSearchResponse import com.branddev.api.models.brand.BrandStyleguideParams import com.branddev.api.models.brand.BrandStyleguideResponse import java.util.function.Consumer @@ -105,13 +103,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt // get /brand/screenshot withRawResponse().screenshot(params, requestOptions).parse() - override fun search( - params: BrandSearchParams, - requestOptions: RequestOptions, - ): List = - // get /brand/search - withRawResponse().search(params, requestOptions).parse() - override fun styleguide( params: BrandStyleguideParams, requestOptions: RequestOptions, @@ -350,33 +341,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt } } - private val searchHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - - override fun search( - params: BrandSearchParams, - requestOptions: RequestOptions, - ): HttpResponseFor> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brand", "search") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { searchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } - } - } - } - } - private val styleguideHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt index 687db8f..2675cad 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponseTest.kt @@ -55,12 +55,6 @@ internal class BrandIdentifyFromTransactionResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandIdentifyFromTransactionResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandIdentifyFromTransactionResponse.Brand.Logo.builder() .addColor( @@ -141,12 +135,6 @@ internal class BrandIdentifyFromTransactionResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandIdentifyFromTransactionResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandIdentifyFromTransactionResponse.Brand.Logo.builder() .addColor( @@ -232,12 +220,6 @@ internal class BrandIdentifyFromTransactionResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandIdentifyFromTransactionResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandIdentifyFromTransactionResponse.Brand.Logo.builder() .addColor( diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt index 5255ad4..98863d7 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponseTest.kt @@ -54,12 +54,6 @@ internal class BrandRetrieveByTickerResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandRetrieveByTickerResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandRetrieveByTickerResponse.Brand.Logo.builder() .addColor( @@ -138,12 +132,6 @@ internal class BrandRetrieveByTickerResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandRetrieveByTickerResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandRetrieveByTickerResponse.Brand.Logo.builder() .addColor( @@ -228,12 +216,6 @@ internal class BrandRetrieveByTickerResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandRetrieveByTickerResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandRetrieveByTickerResponse.Brand.Logo.builder() .addColor( diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt index 84d5184..1aea000 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveResponseTest.kt @@ -53,12 +53,6 @@ internal class BrandRetrieveResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandRetrieveResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandRetrieveResponse.Brand.Logo.builder() .addColor( @@ -134,12 +128,6 @@ internal class BrandRetrieveResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandRetrieveResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandRetrieveResponse.Brand.Logo.builder() .addColor( @@ -220,12 +208,6 @@ internal class BrandRetrieveResponseTest { ) .description("description") .domain("domain") - .addFont( - BrandRetrieveResponse.Brand.Font.builder() - .name("name") - .usage("usage") - .build() - ) .addLogo( BrandRetrieveResponse.Brand.Logo.builder() .addColor( diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchParamsTest.kt deleted file mode 100644 index aafa4eb..0000000 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchParamsTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.branddev.api.models.brand - -import com.branddev.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BrandSearchParamsTest { - - @Disabled("skipped: tests are disabled for the time being") - @Test - fun create() { - BrandSearchParams.builder().query("query").timeoutMs(1L).build() - } - - @Disabled("skipped: tests are disabled for the time being") - @Test - fun queryParams() { - val params = BrandSearchParams.builder().query("query").timeoutMs(1L).build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("query", "query").put("timeoutMS", "1").build()) - } - - @Disabled("skipped: tests are disabled for the time being") - @Test - fun queryParamsWithoutOptionalFields() { - val params = BrandSearchParams.builder().query("query").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("query", "query").build()) - } -} diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchResponseTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchResponseTest.kt deleted file mode 100644 index 5303e35..0000000 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandSearchResponseTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.branddev.api.models.brand - -import com.branddev.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BrandSearchResponseTest { - - @Disabled("skipped: tests are disabled for the time being") - @Test - fun create() { - val brandSearchResponse = - BrandSearchResponse.builder().domain("domain").logo("logo").title("title").build() - - assertThat(brandSearchResponse.domain()).contains("domain") - assertThat(brandSearchResponse.logo()).contains("logo") - assertThat(brandSearchResponse.title()).contains("title") - } - - @Disabled("skipped: tests are disabled for the time being") - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val brandSearchResponse = - BrandSearchResponse.builder().domain("domain").logo("logo").title("title").build() - - val roundtrippedBrandSearchResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(brandSearchResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBrandSearchResponse).isEqualTo(brandSearchResponse) - } -} diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/async/BrandServiceAsyncTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/async/BrandServiceAsyncTest.kt index fa31c58..d9b9c51 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/async/BrandServiceAsyncTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/async/BrandServiceAsyncTest.kt @@ -12,7 +12,6 @@ import com.branddev.api.models.brand.BrandRetrieveNaicsParams import com.branddev.api.models.brand.BrandRetrieveParams import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams import com.branddev.api.models.brand.BrandScreenshotParams -import com.branddev.api.models.brand.BrandSearchParams import com.branddev.api.models.brand.BrandStyleguideParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -207,25 +206,6 @@ internal class BrandServiceAsyncTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") - @Test - fun search() { - val client = - BrandDevOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandServiceAsync = client.brand() - - val responseFuture = - brandServiceAsync.search( - BrandSearchParams.builder().query("query").timeoutMs(1L).build() - ) - - val response = responseFuture.get() - response.forEach { it.validate() } - } - @Disabled("skipped: tests are disabled for the time being") @Test fun styleguide() { diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/blocking/BrandServiceTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/blocking/BrandServiceTest.kt index 48da838..c602857 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/blocking/BrandServiceTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/blocking/BrandServiceTest.kt @@ -12,7 +12,6 @@ import com.branddev.api.models.brand.BrandRetrieveNaicsParams import com.branddev.api.models.brand.BrandRetrieveParams import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams import com.branddev.api.models.brand.BrandScreenshotParams -import com.branddev.api.models.brand.BrandSearchParams import com.branddev.api.models.brand.BrandStyleguideParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -199,22 +198,6 @@ internal class BrandServiceTest { response.validate() } - @Disabled("skipped: tests are disabled for the time being") - @Test - fun search() { - val client = - BrandDevOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandService = client.brand() - - val response = - brandService.search(BrandSearchParams.builder().query("query").timeoutMs(1L).build()) - - response.forEach { it.validate() } - } - @Disabled("skipped: tests are disabled for the time being") @Test fun styleguide() { diff --git a/buildSrc/src/main/kotlin/brand-dev.publish.gradle.kts b/buildSrc/src/main/kotlin/brand-dev.publish.gradle.kts index fe0a8ca..9e05883 100644 --- a/buildSrc/src/main/kotlin/brand-dev.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/brand-dev.publish.gradle.kts @@ -10,7 +10,7 @@ configure { pom { name.set("Brand API") - description.set("API for retrieving and searching brand data") + description.set("API for retrieving brand data from any website") licenses { license { From 08b7b7726f47b0b0ddf8c0bdf70982e741829cea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 00:42:45 +0000 Subject: [PATCH 9/9] release: 0.1.0-alpha.7 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 27 +++++++++++++++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4f9005e..b5db7ce 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.6" + ".": "0.1.0-alpha.7" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc6396..d5c4914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## 0.1.0-alpha.7 (2025-07-21) + +Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.6...v0.1.0-alpha.7) + +### Features + +* **api:** manual updates ([9c7c076](https://github.com/brand-dot-dev/java-sdk/commit/9c7c07621ea16a0b0adeaa57a96d826d9fa6c045)) +* **client:** add https config options ([508033b](https://github.com/brand-dot-dev/java-sdk/commit/508033b672147e010fc171a69fa6d7509acf519c)) + + +### Bug Fixes + +* **client:** don't close client on `withOptions` usage when original is gc'd ([e245a89](https://github.com/brand-dot-dev/java-sdk/commit/e245a8943102c4fb296c1a6f99171bd827374daa)) +* **client:** ensure error handling always occurs ([be0d357](https://github.com/brand-dot-dev/java-sdk/commit/be0d35783fd23f1d9cffb4ff60857d6e2100769f)) + + +### Chores + +* **ci:** bump `actions/setup-java` to v4 ([ce1d549](https://github.com/brand-dot-dev/java-sdk/commit/ce1d54940f67278ab37e9a1c95596df5ba9dcc75)) +* **internal:** allow running specific example from cli ([39f74d7](https://github.com/brand-dot-dev/java-sdk/commit/39f74d71d29a9a7cacca25ef0dd472f8c04397ba)) +* **internal:** refactor delegating from client to options ([6682663](https://github.com/brand-dot-dev/java-sdk/commit/66826635fed7d2d03e7d2deaff75b91fe0a7c034)) + + +### Refactors + +* **internal:** minor `ClientOptionsTest` change ([25962fa](https://github.com/brand-dot-dev/java-sdk/commit/25962facfb9d0e4f9c672d522f12550b7b2cd206)) + ## 0.1.0-alpha.6 (2025-06-29) Full Changelog: [v0.1.0-alpha.5...v0.1.0-alpha.6](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.5...v0.1.0-alpha.6) diff --git a/README.md b/README.md index 5d940d2..c298ab6 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.6) -[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.6/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.6) +[![Maven Central](https://img.shields.io/maven-central/v/com.branddev.api/brand-dev-java)](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.7) +[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.7/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7) @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/). -Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.6). +Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7). @@ -24,7 +24,7 @@ Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/b ### Gradle ```kotlin -implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.6") +implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.7") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.6") com.branddev.api brand-dev-java - 0.1.0-alpha.6 + 0.1.0-alpha.7 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 3ed8802..0a0ebee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.branddev.api" - version = "0.1.0-alpha.6" // x-release-please-version + version = "0.1.0-alpha.7" // x-release-please-version } subprojects {