From 54375ebc6a0bb8bcbf42b65a82acadf9bd783336 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 8 Jun 2025 09:36:01 +0000 Subject: [PATCH 1/7] feat(api): manual updates --- .stats.yml | 4 +- .../api/models/brand/BrandAiQueryParams.kt | 83 +++++++++++++++- .../BrandIdentifyFromTransactionParams.kt | 37 +++++++- .../api/models/brand/BrandPrefetchParams.kt | 94 +++++++++++++++++-- .../brand/BrandRetrieveByTickerParams.kt | 37 +++++++- .../models/brand/BrandRetrieveNaicsParams.kt | 37 +++++++- .../api/models/brand/BrandRetrieveParams.kt | 35 ++++++- .../api/models/brand/BrandSearchParams.kt | 37 +++++++- .../models/brand/BrandAiQueryParamsTest.kt | 3 + .../BrandIdentifyFromTransactionParamsTest.kt | 25 ++++- .../models/brand/BrandPrefetchParamsTest.kt | 13 ++- .../brand/BrandRetrieveByTickerParamsTest.kt | 13 ++- .../brand/BrandRetrieveNaicsParamsTest.kt | 13 ++- .../models/brand/BrandRetrieveParamsTest.kt | 3 + .../api/models/brand/BrandSearchParamsTest.kt | 13 ++- .../api/services/ErrorHandlingTest.kt | 9 ++ .../api/services/ServiceParamsTest.kt | 1 + .../services/async/BrandServiceAsyncTest.kt | 15 ++- .../api/services/blocking/BrandServiceTest.kt | 17 +++- 19 files changed, 447 insertions(+), 42 deletions(-) diff --git a/.stats.yml b/.stats.yml index 950b0fd..fc24298 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 7 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-2df861cbe235900388f93a2e603090b713f6c5029e4daf2220bddface7882032.yml -openapi_spec_hash: d5a5643aea6c45631d7df49692cf9328 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-a960d67a89f2e62fcb3fb61f13e0cba71a803ff00b378730cf72a8209ae8e36a.yml +openapi_spec_hash: a2c7aa9e4b1e5265d502d3f005ffb5f9 config_hash: bb3f3ba0dca413263e40968648f9a1a6 diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt index fc367ec..7e5b1e1 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandAiQueryParams.kt @@ -58,6 +58,16 @@ private constructor( */ fun specificPages(): Optional = body.specificPages() + /** + * 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). + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeoutMs(): Optional = body.timeoutMs() + /** * Returns the raw JSON value of [dataToExtract]. * @@ -79,6 +89,13 @@ private constructor( */ fun _specificPages(): JsonField = body._specificPages() + /** + * Returns the raw JSON value of [timeoutMs]. + * + * Unlike [timeoutMs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _timeoutMs(): JsonField = body._timeoutMs() + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders @@ -123,6 +140,7 @@ private constructor( * - [dataToExtract] * - [domain] * - [specificPages] + * - [timeoutMs] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -178,6 +196,21 @@ private constructor( body.specificPages(specificPages) } + /** + * 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 { body.timeoutMs(timeoutMs) } + + /** + * Sets [Builder.timeoutMs] to an arbitrary JSON value. + * + * You should usually call [Builder.timeoutMs] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timeoutMs(timeoutMs: JsonField) = apply { body.timeoutMs(timeoutMs) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -327,6 +360,7 @@ private constructor( private val dataToExtract: JsonField>, private val domain: JsonField, private val specificPages: JsonField, + private val timeoutMs: JsonField, private val additionalProperties: MutableMap, ) { @@ -339,7 +373,8 @@ private constructor( @JsonProperty("specific_pages") @ExcludeMissing specificPages: JsonField = JsonMissing.of(), - ) : this(dataToExtract, domain, specificPages, mutableMapOf()) + @JsonProperty("timeoutMS") @ExcludeMissing timeoutMs: JsonField = JsonMissing.of(), + ) : this(dataToExtract, domain, specificPages, timeoutMs, mutableMapOf()) /** * Array of data points to extract from the website @@ -365,6 +400,16 @@ private constructor( */ fun specificPages(): Optional = specificPages.getOptional("specific_pages") + /** + * 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). + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timeoutMs(): Optional = timeoutMs.getOptional("timeoutMS") + /** * Returns the raw JSON value of [dataToExtract]. * @@ -392,6 +437,13 @@ private constructor( @ExcludeMissing fun _specificPages(): JsonField = specificPages + /** + * Returns the raw JSON value of [timeoutMs]. + * + * Unlike [timeoutMs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeoutMS") @ExcludeMissing fun _timeoutMs(): JsonField = timeoutMs + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -424,6 +476,7 @@ private constructor( private var dataToExtract: JsonField>? = null private var domain: JsonField? = null private var specificPages: JsonField = JsonMissing.of() + private var timeoutMs: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -431,6 +484,7 @@ private constructor( dataToExtract = body.dataToExtract.map { it.toMutableList() } domain = body.domain specificPages = body.specificPages + timeoutMs = body.timeoutMs additionalProperties = body.additionalProperties.toMutableMap() } @@ -488,6 +542,22 @@ private constructor( this.specificPages = specificPages } + /** + * 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) = timeoutMs(JsonField.of(timeoutMs)) + + /** + * Sets [Builder.timeoutMs] to an arbitrary JSON value. + * + * You should usually call [Builder.timeoutMs] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeoutMs(timeoutMs: JsonField) = apply { this.timeoutMs = timeoutMs } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -525,6 +595,7 @@ private constructor( checkRequired("dataToExtract", dataToExtract).map { it.toImmutable() }, checkRequired("domain", domain), specificPages, + timeoutMs, additionalProperties.toMutableMap(), ) } @@ -539,6 +610,7 @@ private constructor( dataToExtract().forEach { it.validate() } domain() specificPages().ifPresent { it.validate() } + timeoutMs() validated = true } @@ -560,24 +632,25 @@ private constructor( internal fun validity(): Int = (dataToExtract.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (domain.asKnown().isPresent) 1 else 0) + - (specificPages.asKnown().getOrNull()?.validity() ?: 0) + (specificPages.asKnown().getOrNull()?.validity() ?: 0) + + (if (timeoutMs.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Body && dataToExtract == other.dataToExtract && domain == other.domain && specificPages == other.specificPages && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && dataToExtract == other.dataToExtract && domain == other.domain && specificPages == other.specificPages && timeoutMs == other.timeoutMs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dataToExtract, domain, specificPages, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(dataToExtract, domain, specificPages, timeoutMs, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{dataToExtract=$dataToExtract, domain=$domain, specificPages=$specificPages, additionalProperties=$additionalProperties}" + "Body{dataToExtract=$dataToExtract, domain=$domain, specificPages=$specificPages, timeoutMs=$timeoutMs, additionalProperties=$additionalProperties}" } class DataToExtract diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt index 33954fd..6cbcd35 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParams.kt @@ -7,6 +7,8 @@ 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 /** * Endpoint specially designed for platforms that want to identify transaction data by the @@ -15,6 +17,7 @@ import java.util.Objects class BrandIdentifyFromTransactionParams private constructor( private val transactionInfo: String, + private val timeoutMs: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -22,6 +25,13 @@ private constructor( /** Transaction information to identify the brand */ fun transactionInfo(): String = transactionInfo + /** + * 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 @@ -46,6 +56,7 @@ private constructor( class Builder internal constructor() { private var transactionInfo: String? = null + private var timeoutMs: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -53,6 +64,7 @@ private constructor( internal fun from(brandIdentifyFromTransactionParams: BrandIdentifyFromTransactionParams) = apply { transactionInfo = brandIdentifyFromTransactionParams.transactionInfo + timeoutMs = brandIdentifyFromTransactionParams.timeoutMs additionalHeaders = brandIdentifyFromTransactionParams.additionalHeaders.toBuilder() additionalQueryParams = brandIdentifyFromTransactionParams.additionalQueryParams.toBuilder() @@ -63,6 +75,23 @@ private constructor( this.transactionInfo = transactionInfo } + /** + * 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) @@ -176,6 +205,7 @@ private constructor( fun build(): BrandIdentifyFromTransactionParams = BrandIdentifyFromTransactionParams( checkRequired("transactionInfo", transactionInfo), + timeoutMs, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -187,6 +217,7 @@ private constructor( QueryParams.builder() .apply { put("transaction_info", transactionInfo) + timeoutMs?.let { put("timeoutMS", it.toString()) } putAll(additionalQueryParams) } .build() @@ -196,11 +227,11 @@ private constructor( return true } - return /* spotless:off */ other is BrandIdentifyFromTransactionParams && transactionInfo == other.transactionInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is BrandIdentifyFromTransactionParams && transactionInfo == other.transactionInfo && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(transactionInfo, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(transactionInfo, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "BrandIdentifyFromTransactionParams{transactionInfo=$transactionInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BrandIdentifyFromTransactionParams{transactionInfo=$transactionInfo, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandPrefetchParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandPrefetchParams.kt index 4afa4fa..f88713a 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandPrefetchParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandPrefetchParams.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects +import java.util.Optional /** * Signal that you may fetch brand data for a particular domain soon to improve latency. This @@ -38,6 +39,16 @@ private constructor( */ fun domain(): String = body.domain() + /** + * 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). + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeoutMs(): Optional = body.timeoutMs() + /** * Returns the raw JSON value of [domain]. * @@ -45,6 +56,13 @@ private constructor( */ fun _domain(): JsonField = body._domain() + /** + * Returns the raw JSON value of [timeoutMs]. + * + * Unlike [timeoutMs], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _timeoutMs(): JsonField = body._timeoutMs() + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders @@ -86,6 +104,7 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [domain] + * - [timeoutMs] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -100,6 +119,21 @@ private constructor( */ fun domain(domain: JsonField) = apply { body.domain(domain) } + /** + * 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 { body.timeoutMs(timeoutMs) } + + /** + * Sets [Builder.timeoutMs] to an arbitrary JSON value. + * + * You should usually call [Builder.timeoutMs] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timeoutMs(timeoutMs: JsonField) = apply { body.timeoutMs(timeoutMs) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -246,13 +280,15 @@ private constructor( class Body private constructor( private val domain: JsonField, + private val timeoutMs: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of() - ) : this(domain, mutableMapOf()) + @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(), + @JsonProperty("timeoutMS") @ExcludeMissing timeoutMs: JsonField = JsonMissing.of(), + ) : this(domain, timeoutMs, mutableMapOf()) /** * Domain name to prefetch brand data for @@ -262,6 +298,16 @@ private constructor( */ fun domain(): String = domain.getRequired("domain") + /** + * 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). + * + * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timeoutMs(): Optional = timeoutMs.getOptional("timeoutMS") + /** * Returns the raw JSON value of [domain]. * @@ -269,6 +315,13 @@ private constructor( */ @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain + /** + * Returns the raw JSON value of [timeoutMs]. + * + * Unlike [timeoutMs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeoutMS") @ExcludeMissing fun _timeoutMs(): JsonField = timeoutMs + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -298,11 +351,13 @@ private constructor( class Builder internal constructor() { private var domain: JsonField? = null + private var timeoutMs: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { domain = body.domain + timeoutMs = body.timeoutMs additionalProperties = body.additionalProperties.toMutableMap() } @@ -318,6 +373,22 @@ private constructor( */ fun domain(domain: JsonField) = apply { this.domain = domain } + /** + * 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) = timeoutMs(JsonField.of(timeoutMs)) + + /** + * Sets [Builder.timeoutMs] to an arbitrary JSON value. + * + * You should usually call [Builder.timeoutMs] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeoutMs(timeoutMs: JsonField) = apply { this.timeoutMs = timeoutMs } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -350,7 +421,11 @@ private constructor( * @throws IllegalStateException if any required field is unset. */ fun build(): Body = - Body(checkRequired("domain", domain), additionalProperties.toMutableMap()) + Body( + checkRequired("domain", domain), + timeoutMs, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -361,6 +436,7 @@ private constructor( } domain() + timeoutMs() validated = true } @@ -378,23 +454,27 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (domain.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (domain.asKnown().isPresent) 1 else 0) + + (if (timeoutMs.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Body && domain == other.domain && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && domain == other.domain && timeoutMs == other.timeoutMs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(domain, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(domain, timeoutMs, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Body{domain=$domain, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{domain=$domain, timeoutMs=$timeoutMs, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt index f755b62..9d48064 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParams.kt @@ -7,11 +7,14 @@ 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 /** Retrieve brand data by stock ticker (e.g. AAPL, TSLA, etc.) */ class BrandRetrieveByTickerParams private constructor( private val ticker: String, + private val timeoutMs: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -19,6 +22,13 @@ private constructor( /** Stock ticker symbol to retrieve brand data for (e.g. AAPL, TSLA, etc.) */ fun ticker(): String = ticker + /** + * 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 @@ -42,12 +52,14 @@ private constructor( class Builder internal constructor() { private var ticker: 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(brandRetrieveByTickerParams: BrandRetrieveByTickerParams) = apply { ticker = brandRetrieveByTickerParams.ticker + timeoutMs = brandRetrieveByTickerParams.timeoutMs additionalHeaders = brandRetrieveByTickerParams.additionalHeaders.toBuilder() additionalQueryParams = brandRetrieveByTickerParams.additionalQueryParams.toBuilder() } @@ -55,6 +67,23 @@ private constructor( /** Stock ticker symbol to retrieve brand data for (e.g. AAPL, TSLA, etc.) */ fun ticker(ticker: String) = apply { this.ticker = ticker } + /** + * 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) @@ -168,6 +197,7 @@ private constructor( fun build(): BrandRetrieveByTickerParams = BrandRetrieveByTickerParams( checkRequired("ticker", ticker), + timeoutMs, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -179,6 +209,7 @@ private constructor( QueryParams.builder() .apply { put("ticker", ticker) + timeoutMs?.let { put("timeoutMS", it.toString()) } putAll(additionalQueryParams) } .build() @@ -188,11 +219,11 @@ private constructor( return true } - return /* spotless:off */ other is BrandRetrieveByTickerParams && ticker == other.ticker && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is BrandRetrieveByTickerParams && ticker == other.ticker && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(ticker, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(ticker, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "BrandRetrieveByTickerParams{ticker=$ticker, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BrandRetrieveByTickerParams{ticker=$ticker, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParams.kt index 92330a8..d8057fe 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParams.kt @@ -7,11 +7,14 @@ 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 /** Endpoint to classify any brand into a 2022 NAICS code. */ class BrandRetrieveNaicsParams private constructor( private val input: String, + private val timeoutMs: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -23,6 +26,13 @@ private constructor( */ fun input(): String = input + /** + * 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 @@ -46,12 +56,14 @@ private constructor( class Builder internal constructor() { private var input: 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(brandRetrieveNaicsParams: BrandRetrieveNaicsParams) = apply { input = brandRetrieveNaicsParams.input + timeoutMs = brandRetrieveNaicsParams.timeoutMs additionalHeaders = brandRetrieveNaicsParams.additionalHeaders.toBuilder() additionalQueryParams = brandRetrieveNaicsParams.additionalQueryParams.toBuilder() } @@ -63,6 +75,23 @@ private constructor( */ fun input(input: String) = apply { this.input = input } + /** + * 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) @@ -176,6 +205,7 @@ private constructor( fun build(): BrandRetrieveNaicsParams = BrandRetrieveNaicsParams( checkRequired("input", input), + timeoutMs, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -187,6 +217,7 @@ private constructor( QueryParams.builder() .apply { put("input", input) + timeoutMs?.let { put("timeoutMS", it.toString()) } putAll(additionalQueryParams) } .build() @@ -196,11 +227,11 @@ private constructor( return true } - return /* spotless:off */ other is BrandRetrieveNaicsParams && input == other.input && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is BrandRetrieveNaicsParams && input == other.input && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(input, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(input, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "BrandRetrieveNaicsParams{input=$input, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BrandRetrieveNaicsParams{input=$input, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt index d0ccb0e..8388e7a 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveParams.kt @@ -20,6 +20,7 @@ private constructor( private val domain: String, private val forceLanguage: ForceLanguage?, private val maxSpeed: Boolean?, + private val timeoutMs: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -36,6 +37,13 @@ private constructor( */ fun maxSpeed(): Optional = Optional.ofNullable(maxSpeed) + /** + * 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 @@ -61,6 +69,7 @@ private constructor( private var domain: String? = null private var forceLanguage: ForceLanguage? = null private var maxSpeed: Boolean? = null + private var timeoutMs: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -69,6 +78,7 @@ private constructor( domain = brandRetrieveParams.domain forceLanguage = brandRetrieveParams.forceLanguage maxSpeed = brandRetrieveParams.maxSpeed + timeoutMs = brandRetrieveParams.timeoutMs additionalHeaders = brandRetrieveParams.additionalHeaders.toBuilder() additionalQueryParams = brandRetrieveParams.additionalQueryParams.toBuilder() } @@ -102,6 +112,23 @@ private constructor( /** Alias for calling [Builder.maxSpeed] with `maxSpeed.orElse(null)`. */ fun maxSpeed(maxSpeed: Optional) = maxSpeed(maxSpeed.getOrNull()) + /** + * 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) @@ -217,6 +244,7 @@ private constructor( checkRequired("domain", domain), forceLanguage, maxSpeed, + timeoutMs, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -230,6 +258,7 @@ private constructor( put("domain", domain) forceLanguage?.let { put("force_language", it.toString()) } maxSpeed?.let { put("maxSpeed", it.toString()) } + timeoutMs?.let { put("timeoutMS", it.toString()) } putAll(additionalQueryParams) } .build() @@ -671,11 +700,11 @@ private constructor( return true } - return /* spotless:off */ other is BrandRetrieveParams && domain == other.domain && forceLanguage == other.forceLanguage && maxSpeed == other.maxSpeed && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is BrandRetrieveParams && domain == other.domain && forceLanguage == other.forceLanguage && maxSpeed == other.maxSpeed && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(domain, forceLanguage, maxSpeed, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(domain, forceLanguage, maxSpeed, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "BrandRetrieveParams{domain=$domain, forceLanguage=$forceLanguage, maxSpeed=$maxSpeed, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BrandRetrieveParams{domain=$domain, forceLanguage=$forceLanguage, maxSpeed=$maxSpeed, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 index 12fc38f..54b1c3e 100644 --- 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 @@ -7,11 +7,14 @@ 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 { @@ -19,6 +22,13 @@ private constructor( /** 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 @@ -42,12 +52,14 @@ private constructor( 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() } @@ -55,6 +67,23 @@ private constructor( /** 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) @@ -168,6 +197,7 @@ private constructor( fun build(): BrandSearchParams = BrandSearchParams( checkRequired("query", query), + timeoutMs, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -179,6 +209,7 @@ private constructor( QueryParams.builder() .apply { put("query", query) + timeoutMs?.let { put("timeoutMS", it.toString()) } putAll(additionalQueryParams) } .build() @@ -188,11 +219,11 @@ private constructor( return true } - return /* spotless:off */ other is BrandSearchParams && query == other.query && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + 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, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(query, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "BrandSearchParams{query=$query, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BrandSearchParams{query=$query, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt index c0da953..207e7c2 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandAiQueryParamsTest.kt @@ -33,6 +33,7 @@ internal class BrandAiQueryParamsTest { .termsAndConditions(true) .build() ) + .timeoutMs(1L) .build() } @@ -62,6 +63,7 @@ internal class BrandAiQueryParamsTest { .termsAndConditions(true) .build() ) + .timeoutMs(1L) .build() val body = params._body() @@ -89,6 +91,7 @@ internal class BrandAiQueryParamsTest { .termsAndConditions(true) .build() ) + assertThat(body.timeoutMs()).contains(1L) } @Disabled("skipped: tests are disabled for the time being") diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt index a223e03..0eef281 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionParamsTest.kt @@ -12,12 +12,35 @@ internal class BrandIdentifyFromTransactionParamsTest { @Disabled("skipped: tests are disabled for the time being") @Test fun create() { - BrandIdentifyFromTransactionParams.builder().transactionInfo("transaction_info").build() + BrandIdentifyFromTransactionParams.builder() + .transactionInfo("transaction_info") + .timeoutMs(1L) + .build() } @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { + val params = + BrandIdentifyFromTransactionParams.builder() + .transactionInfo("transaction_info") + .timeoutMs(1L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("transaction_info", "transaction_info") + .put("timeoutMS", "1") + .build() + ) + } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun queryParamsWithoutOptionalFields() { val params = BrandIdentifyFromTransactionParams.builder().transactionInfo("transaction_info").build() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt index 74c8ccc..a6162b8 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandPrefetchParamsTest.kt @@ -11,12 +11,23 @@ internal class BrandPrefetchParamsTest { @Disabled("skipped: tests are disabled for the time being") @Test fun create() { - BrandPrefetchParams.builder().domain("domain").build() + BrandPrefetchParams.builder().domain("domain").timeoutMs(1L).build() } @Disabled("skipped: tests are disabled for the time being") @Test fun body() { + val params = BrandPrefetchParams.builder().domain("domain").timeoutMs(1L).build() + + val body = params._body() + + assertThat(body.domain()).isEqualTo("domain") + assertThat(body.timeoutMs()).contains(1L) + } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun bodyWithoutOptionalFields() { val params = BrandPrefetchParams.builder().domain("domain").build() val body = params._body() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt index 2ba0031..8474257 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerParamsTest.kt @@ -12,12 +12,23 @@ internal class BrandRetrieveByTickerParamsTest { @Disabled("skipped: tests are disabled for the time being") @Test fun create() { - BrandRetrieveByTickerParams.builder().ticker("ticker").build() + BrandRetrieveByTickerParams.builder().ticker("ticker").timeoutMs(1L).build() } @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { + val params = BrandRetrieveByTickerParams.builder().ticker("ticker").timeoutMs(1L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("ticker", "ticker").put("timeoutMS", "1").build()) + } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun queryParamsWithoutOptionalFields() { val params = BrandRetrieveByTickerParams.builder().ticker("ticker").build() val queryParams = params._queryParams() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt index b1bd5ef..f1de4cf 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveNaicsParamsTest.kt @@ -12,12 +12,23 @@ internal class BrandRetrieveNaicsParamsTest { @Disabled("skipped: tests are disabled for the time being") @Test fun create() { - BrandRetrieveNaicsParams.builder().input("input").build() + BrandRetrieveNaicsParams.builder().input("input").timeoutMs(1L).build() } @Disabled("skipped: tests are disabled for the time being") @Test fun queryParams() { + val params = BrandRetrieveNaicsParams.builder().input("input").timeoutMs(1L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("input", "input").put("timeoutMS", "1").build()) + } + + @Disabled("skipped: tests are disabled for the time being") + @Test + fun queryParamsWithoutOptionalFields() { val params = BrandRetrieveNaicsParams.builder().input("input").build() val queryParams = params._queryParams() diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt index 497e0f1..2b2d5df 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/models/brand/BrandRetrieveParamsTest.kt @@ -16,6 +16,7 @@ internal class BrandRetrieveParamsTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() } @@ -27,6 +28,7 @@ internal class BrandRetrieveParamsTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() val queryParams = params._queryParams() @@ -37,6 +39,7 @@ internal class BrandRetrieveParamsTest { .put("domain", "domain") .put("force_language", "albanian") .put("maxSpeed", "true") + .put("timeoutMS", "1") .build() ) } 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 index 0292180..aafa4eb 100644 --- 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 @@ -12,12 +12,23 @@ internal class BrandSearchParamsTest { @Disabled("skipped: tests are disabled for the time being") @Test fun create() { - BrandSearchParams.builder().query("query").build() + 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() 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 4d14ac1..5299ae6 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 @@ -77,6 +77,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -104,6 +105,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -131,6 +133,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -158,6 +161,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -185,6 +189,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -212,6 +217,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -239,6 +245,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -266,6 +273,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } @@ -291,6 +299,7 @@ internal class ErrorHandlingTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) } diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ServiceParamsTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ServiceParamsTest.kt index fc986df..a683123 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ServiceParamsTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/services/ServiceParamsTest.kt @@ -45,6 +45,7 @@ internal class ServiceParamsTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .build() 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 376aa70..95227f7 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 @@ -34,6 +34,7 @@ internal class BrandServiceAsyncTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) @@ -75,6 +76,7 @@ internal class BrandServiceAsyncTest { .termsAndConditions(true) .build() ) + .timeoutMs(1L) .build() ) @@ -96,6 +98,7 @@ internal class BrandServiceAsyncTest { brandServiceAsync.identifyFromTransaction( BrandIdentifyFromTransactionParams.builder() .transactionInfo("transaction_info") + .timeoutMs(1L) .build() ) @@ -114,7 +117,9 @@ internal class BrandServiceAsyncTest { val brandServiceAsync = client.brand() val responseFuture = - brandServiceAsync.prefetch(BrandPrefetchParams.builder().domain("domain").build()) + brandServiceAsync.prefetch( + BrandPrefetchParams.builder().domain("domain").timeoutMs(1L).build() + ) val response = responseFuture.get() response.validate() @@ -132,7 +137,7 @@ internal class BrandServiceAsyncTest { val responseFuture = brandServiceAsync.retrieveByTicker( - BrandRetrieveByTickerParams.builder().ticker("ticker").build() + BrandRetrieveByTickerParams.builder().ticker("ticker").timeoutMs(1L).build() ) val response = responseFuture.get() @@ -151,7 +156,7 @@ internal class BrandServiceAsyncTest { val responseFuture = brandServiceAsync.retrieveNaics( - BrandRetrieveNaicsParams.builder().input("input").build() + BrandRetrieveNaicsParams.builder().input("input").timeoutMs(1L).build() ) val response = responseFuture.get() @@ -169,7 +174,9 @@ internal class BrandServiceAsyncTest { val brandServiceAsync = client.brand() val responseFuture = - brandServiceAsync.search(BrandSearchParams.builder().query("query").build()) + brandServiceAsync.search( + BrandSearchParams.builder().query("query").timeoutMs(1L).build() + ) val response = responseFuture.get() response.forEach { it.validate() } 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 f765a9f..78f0b44 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 @@ -34,6 +34,7 @@ internal class BrandServiceTest { .domain("domain") .forceLanguage(BrandRetrieveParams.ForceLanguage.ALBANIAN) .maxSpeed(true) + .timeoutMs(1L) .build() ) @@ -74,6 +75,7 @@ internal class BrandServiceTest { .termsAndConditions(true) .build() ) + .timeoutMs(1L) .build() ) @@ -94,6 +96,7 @@ internal class BrandServiceTest { brandService.identifyFromTransaction( BrandIdentifyFromTransactionParams.builder() .transactionInfo("transaction_info") + .timeoutMs(1L) .build() ) @@ -110,7 +113,10 @@ internal class BrandServiceTest { .build() val brandService = client.brand() - val response = brandService.prefetch(BrandPrefetchParams.builder().domain("domain").build()) + val response = + brandService.prefetch( + BrandPrefetchParams.builder().domain("domain").timeoutMs(1L).build() + ) response.validate() } @@ -127,7 +133,7 @@ internal class BrandServiceTest { val response = brandService.retrieveByTicker( - BrandRetrieveByTickerParams.builder().ticker("ticker").build() + BrandRetrieveByTickerParams.builder().ticker("ticker").timeoutMs(1L).build() ) response.validate() @@ -144,7 +150,9 @@ internal class BrandServiceTest { val brandService = client.brand() val response = - brandService.retrieveNaics(BrandRetrieveNaicsParams.builder().input("input").build()) + brandService.retrieveNaics( + BrandRetrieveNaicsParams.builder().input("input").timeoutMs(1L).build() + ) response.validate() } @@ -159,7 +167,8 @@ internal class BrandServiceTest { .build() val brandService = client.brand() - val response = brandService.search(BrandSearchParams.builder().query("query").build()) + val response = + brandService.search(BrandSearchParams.builder().query("query").timeoutMs(1L).build()) response.forEach { it.validate() } } From dd60539df0eb21c82900eab1bd136d947b9af9d5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 05:32:00 +0000 Subject: [PATCH 2/7] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index fc24298..6be4170 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 7 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-a960d67a89f2e62fcb3fb61f13e0cba71a803ff00b378730cf72a8209ae8e36a.yml -openapi_spec_hash: a2c7aa9e4b1e5265d502d3f005ffb5f9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-a0307b03264f35449e6f919d727c947ac3bfaace32b45d04752598ad47bb9f09.yml +openapi_spec_hash: c88aaaf2607057f4f1ff7f5fd06e1b5d config_hash: bb3f3ba0dca413263e40968648f9a1a6 From 086940b825cc310601ccc62bb3465e45d550328c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 05:33:36 +0000 Subject: [PATCH 3/7] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6be4170..d85b78c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 7 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-a0307b03264f35449e6f919d727c947ac3bfaace32b45d04752598ad47bb9f09.yml openapi_spec_hash: c88aaaf2607057f4f1ff7f5fd06e1b5d -config_hash: bb3f3ba0dca413263e40968648f9a1a6 +config_hash: 4ab8d35881cc0191126ff443317e03ba From 8a45033639c999fa265f0f33bf677758492d4b82 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 18:19:18 +0000 Subject: [PATCH 4/7] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d85b78c..e5a78c5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 7 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-a0307b03264f35449e6f919d727c947ac3bfaace32b45d04752598ad47bb9f09.yml -openapi_spec_hash: c88aaaf2607057f4f1ff7f5fd06e1b5d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-103a28182099d9866bc8c40db00f3356fe5be36302874e7ee84ee4fd2f593859.yml +openapi_spec_hash: 30241efa79f9aab6e430c29383d9a2cf config_hash: 4ab8d35881cc0191126ff443317e03ba From a01b1d5539251f6fb2d99b6e5d2b0a3d7ab075cb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Jun 2025 03:26:53 +0000 Subject: [PATCH 5/7] feat(client): implement per-endpoint base URL support Refactor `HttpRequest` to always take a `baseUrl`, instead of storing this in `OkHttpClient`. This allows better reuse of `OkHttpClient` when changing the `baseUrl`. --- .../api/client/okhttp/BrandDevOkHttpClient.kt | 8 +---- .../okhttp/BrandDevOkHttpClientAsync.kt | 8 +---- .../api/client/okhttp/OkHttpClient.kt | 17 ++--------- .../com/branddev/api/core/ClientOptions.kt | 15 ++++++---- .../com/branddev/api/core/http/HttpRequest.kt | 12 ++++---- .../services/async/BrandServiceAsyncImpl.kt | 7 +++++ .../api/services/blocking/BrandServiceImpl.kt | 7 +++++ .../api/core/http/RetryingHttpClientTest.kt | 29 +++++++++++++++---- 8 files changed, 59 insertions(+), 44 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 3c00827..2d7f0a6 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 @@ -161,13 +161,7 @@ class BrandDevOkHttpClient private constructor() { fun build(): BrandDevClient = BrandDevClientImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(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 9e48a20..f682f7a 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 @@ -163,13 +163,7 @@ class BrandDevOkHttpClientAsync private constructor() { fun build(): BrandDevClientAsync = BrandDevClientAsyncImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).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 71a626e..e6cd706 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 @@ -2,7 +2,6 @@ package com.branddev.api.client.okhttp import com.branddev.api.core.RequestOptions import com.branddev.api.core.Timeout -import com.branddev.api.core.checkRequired import com.branddev.api.core.http.Headers import com.branddev.api.core.http.HttpClient import com.branddev.api.core.http.HttpMethod @@ -17,7 +16,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -28,8 +26,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient -private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { @@ -140,11 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun HttpRequest.toUrl(): String { - url?.let { - return it - } - - val builder = baseUrl.newBuilder() + val builder = baseUrl.toHttpUrl().newBuilder() pathSegments.forEach(builder::addPathSegment) queryParams.keys().forEach { key -> queryParams.values(key).forEach { builder.addQueryParameter(key, it) } @@ -194,12 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { - private var baseUrl: HttpUrl? = null private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) @@ -214,8 +204,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) - .build(), - checkRequired("baseUrl", baseUrl), + .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 6a2b17b..ab4990d 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,8 @@ 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.util.Optional +import kotlin.jvm.optionals.getOrNull class ClientOptions private constructor( @@ -17,7 +19,7 @@ private constructor( @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, - @get:JvmName("baseUrl") val baseUrl: String, + private val baseUrl: String?, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @@ -32,6 +34,8 @@ private constructor( } } + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + fun toBuilder() = Builder().from(this) companion object { @@ -59,7 +63,7 @@ private constructor( private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() - private var baseUrl: String = PRODUCTION_URL + private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false @@ -92,7 +96,10 @@ private constructor( fun clock(clock: Clock) = apply { this.clock = clock } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -184,8 +191,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun baseUrl(): String = baseUrl - fun fromEnv() = apply { System.getenv("BRAND_DEV_BASE_URL")?.let { baseUrl(it) } System.getenv("BRAND_DEV_API_KEY")?.let { apiKey(it) } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/HttpRequest.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/HttpRequest.kt index 46d874b..fea19e7 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/HttpRequest.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/http/HttpRequest.kt @@ -6,7 +6,7 @@ import com.branddev.api.core.toImmutable class HttpRequest private constructor( @get:JvmName("method") val method: HttpMethod, - @get:JvmName("url") val url: String?, + @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("pathSegments") val pathSegments: List, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @@ -16,7 +16,7 @@ private constructor( fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = - "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" companion object { @JvmStatic fun builder() = Builder() @@ -25,7 +25,7 @@ private constructor( class Builder internal constructor() { private var method: HttpMethod? = null - private var url: String? = null + private var baseUrl: String? = null private var pathSegments: MutableList = mutableListOf() private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() @@ -34,7 +34,7 @@ private constructor( @JvmSynthetic internal fun from(request: HttpRequest) = apply { method = request.method - url = request.url + baseUrl = request.baseUrl pathSegments = request.pathSegments.toMutableList() headers = request.headers.toBuilder() queryParams = request.queryParams.toBuilder() @@ -43,7 +43,7 @@ private constructor( fun method(method: HttpMethod) = apply { this.method = method } - fun url(url: String) = apply { this.url = url } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } @@ -136,7 +136,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( checkRequired("method", method), - url, + checkRequired("baseUrl", baseUrl), pathSegments.toImmutable(), headers.build(), queryParams.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 276623a..7632c21 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 @@ -105,6 +105,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "retrieve") .build() .prepareAsync(clientOptions, params) @@ -135,6 +136,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "ai", "query") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -166,6 +168,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "transaction_identifier") .build() .prepareAsync(clientOptions, params) @@ -196,6 +199,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "prefetch") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -227,6 +231,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "retrieve-by-ticker") .build() .prepareAsync(clientOptions, params) @@ -257,6 +262,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "naics") .build() .prepareAsync(clientOptions, params) @@ -287,6 +293,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "search") .build() .prepareAsync(clientOptions, params) 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 5a87d11..2b66669 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 @@ -104,6 +104,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "retrieve") .build() .prepare(clientOptions, params) @@ -131,6 +132,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "ai", "query") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -159,6 +161,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "transaction_identifier") .build() .prepare(clientOptions, params) @@ -186,6 +189,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "prefetch") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -214,6 +218,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "retrieve-by-ticker") .build() .prepare(clientOptions, params) @@ -241,6 +246,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "naics") .build() .prepare(clientOptions, params) @@ -268,6 +274,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("brand", "search") .build() .prepare(clientOptions, params) diff --git a/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt index d2bba26..6272d41 100644 --- a/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt +++ b/brand-dev-java-core/src/test/kotlin/com/branddev/api/core/http/RetryingHttpClientTest.kt @@ -20,11 +20,13 @@ import org.junit.jupiter.params.provider.ValueSource internal class RetryingHttpClientTest { private var openResponseCount = 0 + private lateinit var baseUrl: String private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() httpClient = object : HttpClient { @@ -75,7 +77,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -97,7 +103,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -139,7 +149,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -187,6 +201,7 @@ internal class RetryingHttpClientTest { retryingClient.execute( HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(baseUrl) .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), @@ -223,7 +238,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) From 3cfe90c94543b1c271026eaeed3b4b941a311d81 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 03:29:24 +0000 Subject: [PATCH 6/7] feat(client): add a `withOptions` method --- README.md | 15 +++++++++++++++ .../com/branddev/api/client/BrandDevClient.kt | 16 ++++++++++++++++ .../branddev/api/client/BrandDevClientAsync.kt | 18 ++++++++++++++++++ .../api/client/BrandDevClientAsyncImpl.kt | 11 +++++++++++ .../branddev/api/client/BrandDevClientImpl.kt | 11 +++++++++++ .../api/services/async/BrandServiceAsync.kt | 18 ++++++++++++++++++ .../services/async/BrandServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/blocking/BrandService.kt | 16 ++++++++++++++++ .../api/services/blocking/BrandServiceImpl.kt | 11 +++++++++++ 9 files changed, 127 insertions(+) diff --git a/README.md b/README.md index 70d79a9..e4ed886 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,21 @@ See this table for the available options: > Don't create more than one client in the same application. Each client has a connection pool and > thread pools, which are more efficient to share between requests. +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import com.branddev.api.client.BrandDevClient; + +BrandDevClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + ## Requests and responses To send a request to the Brand Dev API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClient.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClient.kt index c4fd6da..3b1ad41 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClient.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClient.kt @@ -2,7 +2,9 @@ package com.branddev.api.client +import com.branddev.api.core.ClientOptions import com.branddev.api.services.blocking.BrandService +import java.util.function.Consumer /** * A client for interacting with the Brand Dev REST API synchronously. You can also switch to @@ -33,6 +35,13 @@ interface BrandDevClient { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandDevClient + fun brand(): BrandService /** @@ -51,6 +60,13 @@ interface BrandDevClient { /** A view of [BrandDevClient] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandDevClient.WithRawResponse + fun brand(): BrandService.WithRawResponse } } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsync.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsync.kt index 30d2115..0e8da88 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsync.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsync.kt @@ -2,7 +2,9 @@ package com.branddev.api.client +import com.branddev.api.core.ClientOptions import com.branddev.api.services.async.BrandServiceAsync +import java.util.function.Consumer /** * A client for interacting with the Brand Dev REST API asynchronously. You can also switch to @@ -33,6 +35,13 @@ interface BrandDevClientAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandDevClientAsync + fun brand(): BrandServiceAsync /** @@ -53,6 +62,15 @@ interface BrandDevClientAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BrandDevClientAsync.WithRawResponse + fun brand(): BrandServiceAsync.WithRawResponse } } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsyncImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsyncImpl.kt index 6e1fcbd..0a281ab 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsyncImpl.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientAsyncImpl.kt @@ -6,6 +6,7 @@ import com.branddev.api.core.ClientOptions import com.branddev.api.core.getPackageVersion import com.branddev.api.services.async.BrandServiceAsync import com.branddev.api.services.async.BrandServiceAsyncImpl +import java.util.function.Consumer class BrandDevClientAsyncImpl(private val clientOptions: ClientOptions) : BrandDevClientAsync { @@ -32,6 +33,9 @@ class BrandDevClientAsyncImpl(private val clientOptions: ClientOptions) : BrandD override fun withRawResponse(): BrandDevClientAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BrandDevClientAsync = + BrandDevClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun brand(): BrandServiceAsync = brand override fun close() = clientOptions.httpClient.close() @@ -43,6 +47,13 @@ class BrandDevClientAsyncImpl(private val clientOptions: ClientOptions) : BrandD BrandServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BrandDevClientAsync.WithRawResponse = + BrandDevClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun brand(): BrandServiceAsync.WithRawResponse = brand } } diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientImpl.kt index af376a2..9d41e1c 100644 --- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientImpl.kt +++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/client/BrandDevClientImpl.kt @@ -6,6 +6,7 @@ import com.branddev.api.core.ClientOptions import com.branddev.api.core.getPackageVersion import com.branddev.api.services.blocking.BrandService import com.branddev.api.services.blocking.BrandServiceImpl +import java.util.function.Consumer class BrandDevClientImpl(private val clientOptions: ClientOptions) : BrandDevClient { @@ -30,6 +31,9 @@ class BrandDevClientImpl(private val clientOptions: ClientOptions) : BrandDevCli override fun withRawResponse(): BrandDevClient.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BrandDevClient = + BrandDevClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun brand(): BrandService = brand override fun close() = clientOptions.httpClient.close() @@ -41,6 +45,13 @@ class BrandDevClientImpl(private val clientOptions: ClientOptions) : BrandDevCli BrandServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BrandDevClient.WithRawResponse = + BrandDevClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun brand(): BrandService.WithRawResponse = brand } } 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 738e11c..2444d02 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 @@ -2,6 +2,7 @@ package com.branddev.api.services.async +import com.branddev.api.core.ClientOptions import com.branddev.api.core.RequestOptions import com.branddev.api.core.http.HttpResponseFor import com.branddev.api.models.brand.BrandAiQueryParams @@ -19,6 +20,7 @@ import com.branddev.api.models.brand.BrandRetrieveResponse import com.branddev.api.models.brand.BrandSearchParams import com.branddev.api.models.brand.BrandSearchResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface BrandServiceAsync { @@ -27,6 +29,13 @@ interface BrandServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandServiceAsync + /** Retrieve brand data by domain */ fun retrieve(params: BrandRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) @@ -115,6 +124,15 @@ interface BrandServiceAsync { /** A view of [BrandServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BrandServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /brand/retrieve`, but is otherwise the same as * [BrandServiceAsync.retrieve]. 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 7632c21..e468296 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 @@ -30,6 +30,7 @@ import com.branddev.api.models.brand.BrandRetrieveResponse import com.branddev.api.models.brand.BrandSearchParams import com.branddev.api.models.brand.BrandSearchResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class BrandServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BrandServiceAsync { @@ -40,6 +41,9 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): BrandServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BrandServiceAsync = + BrandServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: BrandRetrieveParams, requestOptions: RequestOptions, @@ -94,6 +98,13 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BrandServiceAsync.WithRawResponse = + BrandServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) 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 a57f038..274319c 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 @@ -2,6 +2,7 @@ package com.branddev.api.services.blocking +import com.branddev.api.core.ClientOptions import com.branddev.api.core.RequestOptions import com.branddev.api.core.http.HttpResponseFor import com.branddev.api.models.brand.BrandAiQueryParams @@ -19,6 +20,7 @@ import com.branddev.api.models.brand.BrandRetrieveResponse import com.branddev.api.models.brand.BrandSearchParams import com.branddev.api.models.brand.BrandSearchResponse import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer interface BrandService { @@ -27,6 +29,13 @@ interface BrandService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandService + /** Retrieve brand data by domain */ fun retrieve(params: BrandRetrieveParams): BrandRetrieveResponse = retrieve(params, RequestOptions.none()) @@ -111,6 +120,13 @@ interface BrandService { /** A view of [BrandService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandService.WithRawResponse + /** * Returns a raw HTTP response for `get /brand/retrieve`, but is otherwise the same as * [BrandService.retrieve]. 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 2b66669..66f6d89 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 @@ -29,6 +29,7 @@ import com.branddev.api.models.brand.BrandRetrieveParams import com.branddev.api.models.brand.BrandRetrieveResponse import com.branddev.api.models.brand.BrandSearchParams import com.branddev.api.models.brand.BrandSearchResponse +import java.util.function.Consumer class BrandServiceImpl internal constructor(private val clientOptions: ClientOptions) : BrandService { @@ -39,6 +40,9 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withRawResponse(): BrandService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BrandService = + BrandServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: BrandRetrieveParams, requestOptions: RequestOptions, @@ -93,6 +97,13 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): BrandService.WithRawResponse = + BrandServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) From 84016d60ff29ed7fc0da78439f3ccdc6e10680f3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 03:29:41 +0000 Subject: [PATCH 7/7] release: 0.1.0-alpha.3 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 10 ++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f14b480..aaf968a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.2" + ".": "0.1.0-alpha.3" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 612f150..131d2cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.1.0-alpha.3 (2025-06-13) + +Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) + +### Features + +* **api:** manual updates ([54375eb](https://github.com/brand-dot-dev/java-sdk/commit/54375ebc6a0bb8bcbf42b65a82acadf9bd783336)) +* **client:** add a `withOptions` method ([3cfe90c](https://github.com/brand-dot-dev/java-sdk/commit/3cfe90c94543b1c271026eaeed3b4b941a311d81)) +* **client:** implement per-endpoint base URL support ([a01b1d5](https://github.com/brand-dot-dev/java-sdk/commit/a01b1d5539251f6fb2d99b6e5d2b0a3d7ab075cb)) + ## 0.1.0-alpha.2 (2025-06-06) Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) diff --git a/README.md b/README.md index e4ed886..b39c707 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.2) -[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.2/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.2) +[![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.3) +[![javadoc](https://javadoc.io/badge2/com.branddev.api/brand-dev-java/0.1.0-alpha.3/javadoc.svg)](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.3) @@ -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.2). +Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.3). @@ -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.2") +implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.3") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.2") com.branddev.api brand-dev-java - 0.1.0-alpha.2 + 0.1.0-alpha.3 ``` diff --git a/build.gradle.kts b/build.gradle.kts index db0d322..da2effa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.branddev.api" - version = "0.1.0-alpha.2" // x-release-please-version + version = "0.1.0-alpha.3" // x-release-please-version } subprojects {