diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml
index dec7aee..6e6b760 100644
--- a/.github/workflows/publish-sonatype.yml
+++ b/.github/workflows/publish-sonatype.yml
@@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Java
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 4f9005e..b5db7ce 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.1.0-alpha.6"
+ ".": "0.1.0-alpha.7"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index b3fbada..7daf4a5 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 10
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-aff48154fa37f0eb293cf660842ceab35c597509aee08f6b76df066828229c58.yml
-openapi_spec_hash: a8ade5d7246da14e2ff161e829d11c12
+configured_endpoints: 9
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brand-dev%2Fbrand.dev-70f44e886c51bd700af031ad9b5c8f0042ef15fde038ba83ed08f61cd9d05266.yml
+openapi_spec_hash: 9b834ba9e373689a8e2fbd8312b1f2de
config_hash: 8f3ee44d690a305369555016a77ed016
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1fc6396..d5c4914 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,32 @@
# Changelog
+## 0.1.0-alpha.7 (2025-07-21)
+
+Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.6...v0.1.0-alpha.7)
+
+### Features
+
+* **api:** manual updates ([9c7c076](https://github.com/brand-dot-dev/java-sdk/commit/9c7c07621ea16a0b0adeaa57a96d826d9fa6c045))
+* **client:** add https config options ([508033b](https://github.com/brand-dot-dev/java-sdk/commit/508033b672147e010fc171a69fa6d7509acf519c))
+
+
+### Bug Fixes
+
+* **client:** don't close client on `withOptions` usage when original is gc'd ([e245a89](https://github.com/brand-dot-dev/java-sdk/commit/e245a8943102c4fb296c1a6f99171bd827374daa))
+* **client:** ensure error handling always occurs ([be0d357](https://github.com/brand-dot-dev/java-sdk/commit/be0d35783fd23f1d9cffb4ff60857d6e2100769f))
+
+
+### Chores
+
+* **ci:** bump `actions/setup-java` to v4 ([ce1d549](https://github.com/brand-dot-dev/java-sdk/commit/ce1d54940f67278ab37e9a1c95596df5ba9dcc75))
+* **internal:** allow running specific example from cli ([39f74d7](https://github.com/brand-dot-dev/java-sdk/commit/39f74d71d29a9a7cacca25ef0dd472f8c04397ba))
+* **internal:** refactor delegating from client to options ([6682663](https://github.com/brand-dot-dev/java-sdk/commit/66826635fed7d2d03e7d2deaff75b91fe0a7c034))
+
+
+### Refactors
+
+* **internal:** minor `ClientOptionsTest` change ([25962fa](https://github.com/brand-dot-dev/java-sdk/commit/25962facfb9d0e4f9c672d522f12550b7b2cd206))
+
## 0.1.0-alpha.6 (2025-06-29)
Full Changelog: [v0.1.0-alpha.5...v0.1.0-alpha.6](https://github.com/brand-dot-dev/java-sdk/compare/v0.1.0-alpha.5...v0.1.0-alpha.6)
diff --git a/README.md b/README.md
index 79d8a0b..c298ab6 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.6)
-[](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.6)
+[](https://central.sonatype.com/artifact/com.branddev.api/brand-dev-java/0.1.0-alpha.7)
+[](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7)
@@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/).
-Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.6).
+Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/brand-dev-java/0.1.0-alpha.7).
@@ -24,7 +24,7 @@ Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.branddev.api/b
### Gradle
```kotlin
-implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.6")
+implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.7")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.branddev.api:brand-dev-java:0.1.0-alpha.6")
com.branddev.api
brand-dev-java
- 0.1.0-alpha.6
+ 0.1.0-alpha.7
```
@@ -330,6 +330,27 @@ BrandDevClient client = BrandDevOkHttpClient.builder()
.build();
```
+### HTTPS
+
+> [!NOTE]
+> Most applications should not call these methods, and instead use the system defaults. The defaults include
+> special optimizations that can be lost if the implementations are modified.
+
+To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:
+
+```java
+import com.branddev.api.client.BrandDevClient;
+import com.branddev.api.client.okhttp.BrandDevOkHttpClient;
+
+BrandDevClient client = BrandDevOkHttpClient.builder()
+ .fromEnv()
+ // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.
+ .sslSocketFactory(yourSSLSocketFactory)
+ .trustManager(yourTrustManager)
+ .hostnameVerifier(yourHostnameVerifier)
+ .build();
+```
+
### Custom HTTP client
The SDK consists of three artifacts:
diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt
index 2d7f0a6..8ecc0b0 100644
--- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt
+++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClient.kt
@@ -8,10 +8,16 @@ import com.branddev.api.core.ClientOptions
import com.branddev.api.core.Timeout
import com.branddev.api.core.http.Headers
import com.branddev.api.core.http.QueryParams
+import com.branddev.api.core.jsonMapper
import com.fasterxml.jackson.databind.json.JsonMapper
import java.net.Proxy
import java.time.Clock
import java.time.Duration
+import java.util.Optional
+import javax.net.ssl.HostnameVerifier
+import javax.net.ssl.SSLSocketFactory
+import javax.net.ssl.X509TrustManager
+import kotlin.jvm.optionals.getOrNull
class BrandDevOkHttpClient private constructor() {
@@ -27,10 +33,63 @@ class BrandDevOkHttpClient private constructor() {
class Builder internal constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
- private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
+ private var sslSocketFactory: SSLSocketFactory? = null
+ private var trustManager: X509TrustManager? = null
+ private var hostnameVerifier: HostnameVerifier? = null
- fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) }
+ fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
+
+ /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
+ fun proxy(proxy: Optional) = proxy(proxy.getOrNull())
+
+ /**
+ * The socket factory used to secure HTTPS connections.
+ *
+ * If this is set, then [trustManager] must also be set.
+ *
+ * If unset, then the system default is used. Most applications should not call this method,
+ * and instead use the system default. The default include special optimizations that can be
+ * lost if the implementation is modified.
+ */
+ fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
+ this.sslSocketFactory = sslSocketFactory
+ }
+
+ /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */
+ fun sslSocketFactory(sslSocketFactory: Optional) =
+ sslSocketFactory(sslSocketFactory.getOrNull())
+
+ /**
+ * The trust manager used to secure HTTPS connections.
+ *
+ * If this is set, then [sslSocketFactory] must also be set.
+ *
+ * If unset, then the system default is used. Most applications should not call this method,
+ * and instead use the system default. The default include special optimizations that can be
+ * lost if the implementation is modified.
+ */
+ fun trustManager(trustManager: X509TrustManager?) = apply {
+ this.trustManager = trustManager
+ }
+
+ /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */
+ fun trustManager(trustManager: Optional) =
+ trustManager(trustManager.getOrNull())
+
+ /**
+ * The verifier used to confirm that response certificates apply to requested hostnames for
+ * HTTPS connections.
+ *
+ * If unset, then a default hostname verifier is used.
+ */
+ fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply {
+ this.hostnameVerifier = hostnameVerifier
+ }
+
+ /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */
+ fun hostnameVerifier(hostnameVerifier: Optional) =
+ hostnameVerifier(hostnameVerifier.getOrNull())
/**
* Whether to throw an exception if any of the Jackson versions detected at runtime are
@@ -47,6 +106,30 @@ class BrandDevOkHttpClient private constructor() {
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
+ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }
+
+ /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
+ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull())
+
+ fun responseValidation(responseValidation: Boolean) = apply {
+ clientOptions.responseValidation(responseValidation)
+ }
+
+ fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) }
+
+ /**
+ * Sets the maximum time allowed for a complete HTTP call, not including retries.
+ *
+ * See [Timeout.request] for more details.
+ *
+ * For fine-grained control, pass a [Timeout] object.
+ */
+ fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) }
+
+ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
+
+ fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
+
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
fun headers(headers: Map>) = apply {
@@ -127,30 +210,6 @@ class BrandDevOkHttpClient private constructor() {
clientOptions.removeAllQueryParams(keys)
}
- fun timeout(timeout: Timeout) = apply {
- clientOptions.timeout(timeout)
- this.timeout = timeout
- }
-
- /**
- * Sets the maximum time allowed for a complete HTTP call, not including retries.
- *
- * See [Timeout.request] for more details.
- *
- * For fine-grained control, pass a [Timeout] object.
- */
- fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
-
- fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
-
- fun proxy(proxy: Proxy) = apply { this.proxy = proxy }
-
- fun responseValidation(responseValidation: Boolean) = apply {
- clientOptions.responseValidation(responseValidation)
- }
-
- fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
-
fun fromEnv() = apply { clientOptions.fromEnv() }
/**
@@ -161,7 +220,15 @@ class BrandDevOkHttpClient private constructor() {
fun build(): BrandDevClient =
BrandDevClientImpl(
clientOptions
- .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
+ .httpClient(
+ OkHttpClient.builder()
+ .timeout(clientOptions.timeout())
+ .proxy(proxy)
+ .sslSocketFactory(sslSocketFactory)
+ .trustManager(trustManager)
+ .hostnameVerifier(hostnameVerifier)
+ .build()
+ )
.build()
)
}
diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt
index f682f7a..8940bdc 100644
--- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt
+++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/BrandDevOkHttpClientAsync.kt
@@ -8,10 +8,16 @@ import com.branddev.api.core.ClientOptions
import com.branddev.api.core.Timeout
import com.branddev.api.core.http.Headers
import com.branddev.api.core.http.QueryParams
+import com.branddev.api.core.jsonMapper
import com.fasterxml.jackson.databind.json.JsonMapper
import java.net.Proxy
import java.time.Clock
import java.time.Duration
+import java.util.Optional
+import javax.net.ssl.HostnameVerifier
+import javax.net.ssl.SSLSocketFactory
+import javax.net.ssl.X509TrustManager
+import kotlin.jvm.optionals.getOrNull
class BrandDevOkHttpClientAsync private constructor() {
@@ -29,10 +35,63 @@ class BrandDevOkHttpClientAsync private constructor() {
class Builder internal constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
- private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
+ private var sslSocketFactory: SSLSocketFactory? = null
+ private var trustManager: X509TrustManager? = null
+ private var hostnameVerifier: HostnameVerifier? = null
- fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) }
+ fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
+
+ /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
+ fun proxy(proxy: Optional) = proxy(proxy.getOrNull())
+
+ /**
+ * The socket factory used to secure HTTPS connections.
+ *
+ * If this is set, then [trustManager] must also be set.
+ *
+ * If unset, then the system default is used. Most applications should not call this method,
+ * and instead use the system default. The default include special optimizations that can be
+ * lost if the implementation is modified.
+ */
+ fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
+ this.sslSocketFactory = sslSocketFactory
+ }
+
+ /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */
+ fun sslSocketFactory(sslSocketFactory: Optional) =
+ sslSocketFactory(sslSocketFactory.getOrNull())
+
+ /**
+ * The trust manager used to secure HTTPS connections.
+ *
+ * If this is set, then [sslSocketFactory] must also be set.
+ *
+ * If unset, then the system default is used. Most applications should not call this method,
+ * and instead use the system default. The default include special optimizations that can be
+ * lost if the implementation is modified.
+ */
+ fun trustManager(trustManager: X509TrustManager?) = apply {
+ this.trustManager = trustManager
+ }
+
+ /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */
+ fun trustManager(trustManager: Optional) =
+ trustManager(trustManager.getOrNull())
+
+ /**
+ * The verifier used to confirm that response certificates apply to requested hostnames for
+ * HTTPS connections.
+ *
+ * If unset, then a default hostname verifier is used.
+ */
+ fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply {
+ this.hostnameVerifier = hostnameVerifier
+ }
+
+ /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */
+ fun hostnameVerifier(hostnameVerifier: Optional) =
+ hostnameVerifier(hostnameVerifier.getOrNull())
/**
* Whether to throw an exception if any of the Jackson versions detected at runtime are
@@ -49,6 +108,30 @@ class BrandDevOkHttpClientAsync private constructor() {
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
+ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }
+
+ /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
+ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull())
+
+ fun responseValidation(responseValidation: Boolean) = apply {
+ clientOptions.responseValidation(responseValidation)
+ }
+
+ fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) }
+
+ /**
+ * Sets the maximum time allowed for a complete HTTP call, not including retries.
+ *
+ * See [Timeout.request] for more details.
+ *
+ * For fine-grained control, pass a [Timeout] object.
+ */
+ fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) }
+
+ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
+
+ fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
+
fun headers(headers: Headers) = apply { clientOptions.headers(headers) }
fun headers(headers: Map>) = apply {
@@ -129,30 +212,6 @@ class BrandDevOkHttpClientAsync private constructor() {
clientOptions.removeAllQueryParams(keys)
}
- fun timeout(timeout: Timeout) = apply {
- clientOptions.timeout(timeout)
- this.timeout = timeout
- }
-
- /**
- * Sets the maximum time allowed for a complete HTTP call, not including retries.
- *
- * See [Timeout.request] for more details.
- *
- * For fine-grained control, pass a [Timeout] object.
- */
- fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
-
- fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
-
- fun proxy(proxy: Proxy) = apply { this.proxy = proxy }
-
- fun responseValidation(responseValidation: Boolean) = apply {
- clientOptions.responseValidation(responseValidation)
- }
-
- fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
-
fun fromEnv() = apply { clientOptions.fromEnv() }
/**
@@ -163,7 +222,15 @@ class BrandDevOkHttpClientAsync private constructor() {
fun build(): BrandDevClientAsync =
BrandDevClientAsyncImpl(
clientOptions
- .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
+ .httpClient(
+ OkHttpClient.builder()
+ .timeout(clientOptions.timeout())
+ .proxy(proxy)
+ .sslSocketFactory(sslSocketFactory)
+ .trustManager(trustManager)
+ .hostnameVerifier(hostnameVerifier)
+ .build()
+ )
.build()
)
}
diff --git a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt
index cf36c66..f9dd922 100644
--- a/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt
+++ b/brand-dev-java-client-okhttp/src/main/kotlin/com/branddev/api/client/okhttp/OkHttpClient.kt
@@ -14,6 +14,9 @@ import java.io.InputStream
import java.net.Proxy
import java.time.Duration
import java.util.concurrent.CompletableFuture
+import javax.net.ssl.HostnameVerifier
+import javax.net.ssl.SSLSocketFactory
+import javax.net.ssl.X509TrustManager
import okhttp3.Call
import okhttp3.Callback
import okhttp3.HttpUrl.Companion.toHttpUrl
@@ -189,6 +192,9 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
+ private var sslSocketFactory: SSLSocketFactory? = null
+ private var trustManager: X509TrustManager? = null
+ private var hostnameVerifier: HostnameVerifier? = null
fun timeout(timeout: Timeout) = apply { this.timeout = timeout }
@@ -196,6 +202,18 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
+ fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
+ this.sslSocketFactory = sslSocketFactory
+ }
+
+ fun trustManager(trustManager: X509TrustManager?) = apply {
+ this.trustManager = trustManager
+ }
+
+ fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply {
+ this.hostnameVerifier = hostnameVerifier
+ }
+
fun build(): OkHttpClient =
OkHttpClient(
okhttp3.OkHttpClient.Builder()
@@ -204,6 +222,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
.writeTimeout(timeout.write())
.callTimeout(timeout.request())
.proxy(proxy)
+ .apply {
+ val sslSocketFactory = sslSocketFactory
+ val trustManager = trustManager
+ if (sslSocketFactory != null && trustManager != null) {
+ sslSocketFactory(sslSocketFactory, trustManager)
+ } else {
+ check((sslSocketFactory != null) == (trustManager != null)) {
+ "Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set"
+ }
+ }
+
+ hostnameVerifier?.let(::hostnameVerifier)
+ }
.build()
.apply {
// We usually make all our requests to the same host so it makes sense to
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt
index ab4990d..6c7c9c6 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/ClientOptions.kt
@@ -9,6 +9,7 @@ import com.branddev.api.core.http.QueryParams
import com.branddev.api.core.http.RetryingHttpClient
import com.fasterxml.jackson.databind.json.JsonMapper
import java.time.Clock
+import java.time.Duration
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
@@ -16,6 +17,13 @@ class ClientOptions
private constructor(
private val originalHttpClient: HttpClient,
@get:JvmName("httpClient") val httpClient: HttpClient,
+ /**
+ * Whether to throw an exception if any of the Jackson versions detected at runtime are
+ * incompatible with the SDK's minimum supported Jackson version (2.13.4).
+ *
+ * Defaults to true. Use extreme caution when disabling this option. There is no guarantee that
+ * the SDK will work correctly when using an incompatible Jackson version.
+ */
@get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean,
@get:JvmName("jsonMapper") val jsonMapper: JsonMapper,
@get:JvmName("clock") val clock: Clock,
@@ -86,8 +94,17 @@ private constructor(
apiKey = clientOptions.apiKey
}
- fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient }
+ fun httpClient(httpClient: HttpClient) = apply {
+ this.httpClient = PhantomReachableClosingHttpClient(httpClient)
+ }
+ /**
+ * Whether to throw an exception if any of the Jackson versions detected at runtime are
+ * incompatible with the SDK's minimum supported Jackson version (2.13.4).
+ *
+ * Defaults to true. Use extreme caution when disabling this option. There is no guarantee
+ * that the SDK will work correctly when using an incompatible Jackson version.
+ */
fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply {
this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility
}
@@ -107,6 +124,15 @@ private constructor(
fun timeout(timeout: Timeout) = apply { this.timeout = timeout }
+ /**
+ * Sets the maximum time allowed for a complete HTTP call, not including retries.
+ *
+ * See [Timeout.request] for more details.
+ *
+ * For fine-grained control, pass a [Timeout] object.
+ */
+ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
+
fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries }
fun apiKey(apiKey: String) = apply { this.apiKey = apiKey }
@@ -191,6 +217,8 @@ private constructor(
fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) }
+ fun timeout(): Timeout = timeout
+
fun fromEnv() = apply {
System.getenv("BRAND_DEV_BASE_URL")?.let { baseUrl(it) }
System.getenv("BRAND_DEV_API_KEY")?.let { apiKey(it) }
@@ -232,13 +260,11 @@ private constructor(
return ClientOptions(
httpClient,
- PhantomReachableClosingHttpClient(
- RetryingHttpClient.builder()
- .httpClient(httpClient)
- .clock(clock)
- .maxRetries(maxRetries)
- .build()
- ),
+ RetryingHttpClient.builder()
+ .httpClient(httpClient)
+ .clock(clock)
+ .maxRetries(maxRetries)
+ .build(),
checkJacksonVersionCompatibility,
jsonMapper,
clock,
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt
index 108c8bd..05bf0d0 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/core/handlers/ErrorHandler.kt
@@ -19,7 +19,7 @@ import com.branddev.api.errors.UnprocessableEntityException
import com.fasterxml.jackson.databind.json.JsonMapper
@JvmSynthetic
-internal fun errorHandler(jsonMapper: JsonMapper): Handler {
+internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler {
val handler = jsonHandler(jsonMapper)
return object : Handler {
@@ -33,52 +33,52 @@ internal fun errorHandler(jsonMapper: JsonMapper): Handler {
}
@JvmSynthetic
-internal fun Handler.withErrorHandler(errorHandler: Handler): Handler =
- object : Handler {
- override fun handle(response: HttpResponse): T =
+internal fun errorHandler(errorBodyHandler: Handler): Handler =
+ object : Handler {
+ override fun handle(response: HttpResponse): HttpResponse =
when (val statusCode = response.statusCode()) {
- in 200..299 -> this@withErrorHandler.handle(response)
+ in 200..299 -> response
400 ->
throw BadRequestException.builder()
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
401 ->
throw UnauthorizedException.builder()
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
403 ->
throw PermissionDeniedException.builder()
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
404 ->
throw NotFoundException.builder()
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
422 ->
throw UnprocessableEntityException.builder()
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
429 ->
throw RateLimitException.builder()
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
in 500..599 ->
throw InternalServerException.builder()
.statusCode(statusCode)
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
else ->
throw UnexpectedStatusCodeException.builder()
.statusCode(statusCode)
.headers(response.headers())
- .body(errorHandler.handle(response))
+ .body(errorBodyHandler.handle(response))
.build()
}
}
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt
index 3ed57c4..5622cb0 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandIdentifyFromTransactionResponse.kt
@@ -224,7 +224,6 @@ private constructor(
private val colors: JsonField>,
private val description: JsonField,
private val domain: JsonField,
- private val fonts: JsonField>,
private val logos: JsonField>,
private val slogan: JsonField,
private val socials: JsonField>,
@@ -246,7 +245,6 @@ private constructor(
@ExcludeMissing
description: JsonField = JsonMissing.of(),
@JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(),
- @JsonProperty("fonts") @ExcludeMissing fonts: JsonField> = JsonMissing.of(),
@JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(),
@JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(),
@JsonProperty("socials")
@@ -260,7 +258,6 @@ private constructor(
colors,
description,
domain,
- fonts,
logos,
slogan,
socials,
@@ -309,14 +306,6 @@ private constructor(
*/
fun domain(): Optional = domain.getOptional("domain")
- /**
- * An array of fonts used by the brand's website
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if
- * the server responded with an unexpected value).
- */
- fun fonts(): Optional> = fonts.getOptional("fonts")
-
/**
* An array of logos associated with the brand
*
@@ -396,13 +385,6 @@ private constructor(
*/
@JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain
- /**
- * Returns the raw JSON value of [fonts].
- *
- * Unlike [fonts], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("fonts") @ExcludeMissing fun _fonts(): JsonField> = fonts
-
/**
* Returns the raw JSON value of [logos].
*
@@ -464,7 +446,6 @@ private constructor(
private var colors: JsonField>? = null
private var description: JsonField = JsonMissing.of()
private var domain: JsonField = JsonMissing.of()
- private var fonts: JsonField>? = null
private var logos: JsonField>? = null
private var slogan: JsonField = JsonMissing.of()
private var socials: JsonField>? = null
@@ -479,7 +460,6 @@ private constructor(
colors = brand.colors.map { it.toMutableList() }
description = brand.description
domain = brand.domain
- fonts = brand.fonts.map { it.toMutableList() }
logos = brand.logos.map { it.toMutableList() }
slogan = brand.slogan
socials = brand.socials.map { it.toMutableList() }
@@ -578,32 +558,6 @@ private constructor(
*/
fun domain(domain: JsonField) = apply { this.domain = domain }
- /** An array of fonts used by the brand's website */
- fun fonts(fonts: List) = fonts(JsonField.of(fonts))
-
- /**
- * Sets [Builder.fonts] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fonts] with a well-typed `List` value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun fonts(fonts: JsonField>) = apply {
- this.fonts = fonts.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Font] to [fonts].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addFont(font: Font) = apply {
- fonts =
- (fonts ?: JsonField.of(mutableListOf())).also {
- checkKnown("fonts", it).add(font)
- }
- }
-
/** An array of logos associated with the brand */
fun logos(logos: List) = logos(JsonField.of(logos))
@@ -726,7 +680,6 @@ private constructor(
(colors ?: JsonMissing.of()).map { it.toImmutable() },
description,
domain,
- (fonts ?: JsonMissing.of()).map { it.toImmutable() },
(logos ?: JsonMissing.of()).map { it.toImmutable() },
slogan,
(socials ?: JsonMissing.of()).map { it.toImmutable() },
@@ -748,7 +701,6 @@ private constructor(
colors().ifPresent { it.forEach { it.validate() } }
description()
domain()
- fonts().ifPresent { it.forEach { it.validate() } }
logos().ifPresent { it.forEach { it.validate() } }
slogan()
socials().ifPresent { it.forEach { it.validate() } }
@@ -778,7 +730,6 @@ private constructor(
(colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (description.asKnown().isPresent) 1 else 0) +
(if (domain.asKnown().isPresent) 1 else 0) +
- (fonts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (slogan.asKnown().isPresent) 1 else 0) +
(socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
@@ -1957,183 +1908,6 @@ private constructor(
"Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}"
}
- class Font
- private constructor(
- private val name: JsonField,
- private val usage: JsonField,
- private val additionalProperties: MutableMap,
- ) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
- @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(),
- ) : this(name, usage, mutableMapOf())
-
- /**
- * Name of the font
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g.
- * if the server responded with an unexpected value).
- */
- fun name(): Optional = name.getOptional("name")
-
- /**
- * Usage of the font, e.g., 'title', 'body', 'button'
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g.
- * if the server responded with an unexpected value).
- */
- fun usage(): Optional = usage.getOptional("usage")
-
- /**
- * Returns the raw JSON value of [name].
- *
- * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
-
- /**
- * Returns the raw JSON value of [usage].
- *
- * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /** Returns a mutable builder for constructing an instance of [Font]. */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Font]. */
- class Builder internal constructor() {
-
- private var name: JsonField = JsonMissing.of()
- private var usage: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(font: Font) = apply {
- name = font.name
- usage = font.usage
- additionalProperties = font.additionalProperties.toMutableMap()
- }
-
- /** Name of the font */
- fun name(name: String) = name(JsonField.of(name))
-
- /**
- * Sets [Builder.name] to an arbitrary JSON value.
- *
- * You should usually call [Builder.name] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun name(name: JsonField) = apply { this.name = name }
-
- /** Usage of the font, e.g., 'title', 'body', 'button' */
- fun usage(usage: String) = usage(JsonField.of(usage))
-
- /**
- * Sets [Builder.usage] to an arbitrary JSON value.
- *
- * You should usually call [Builder.usage] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun usage(usage: JsonField) = apply { this.usage = usage }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) =
- apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply {
- additionalProperties.remove(key)
- }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [Font].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- */
- fun build(): Font = Font(name, usage, additionalProperties.toMutableMap())
- }
-
- private var validated: Boolean = false
-
- fun validate(): Font = apply {
- if (validated) {
- return@apply
- }
-
- name()
- usage()
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: BrandDevInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object
- * recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (name.asKnown().isPresent) 1 else 0) + (if (usage.asKnown().isPresent) 1 else 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Font && name == other.name && usage == other.usage && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(name, usage, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Font{name=$name, usage=$usage, additionalProperties=$additionalProperties}"
- }
-
class Logo
private constructor(
private val colors: JsonField>,
@@ -3171,17 +2945,17 @@ private constructor(
return true
}
- return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && fonts == other.fonts && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */
+ return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */
}
/* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, fonts, logos, slogan, socials, stock, title, additionalProperties) }
+ private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, logos, slogan, socials, stock, title, additionalProperties) }
/* spotless:on */
override fun hashCode(): Int = hashCode
override fun toString() =
- "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, fonts=$fonts, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}"
+ "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}"
}
override fun equals(other: Any?): Boolean {
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt
index a7c96ba..e8c395e 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveByTickerResponse.kt
@@ -216,7 +216,6 @@ private constructor(
private val colors: JsonField>,
private val description: JsonField,
private val domain: JsonField,
- private val fonts: JsonField>,
private val logos: JsonField>,
private val slogan: JsonField,
private val socials: JsonField>,
@@ -238,7 +237,6 @@ private constructor(
@ExcludeMissing
description: JsonField = JsonMissing.of(),
@JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(),
- @JsonProperty("fonts") @ExcludeMissing fonts: JsonField> = JsonMissing.of(),
@JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(),
@JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(),
@JsonProperty("socials")
@@ -252,7 +250,6 @@ private constructor(
colors,
description,
domain,
- fonts,
logos,
slogan,
socials,
@@ -301,14 +298,6 @@ private constructor(
*/
fun domain(): Optional = domain.getOptional("domain")
- /**
- * An array of fonts used by the brand's website
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if
- * the server responded with an unexpected value).
- */
- fun fonts(): Optional> = fonts.getOptional("fonts")
-
/**
* An array of logos associated with the brand
*
@@ -388,13 +377,6 @@ private constructor(
*/
@JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain
- /**
- * Returns the raw JSON value of [fonts].
- *
- * Unlike [fonts], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("fonts") @ExcludeMissing fun _fonts(): JsonField> = fonts
-
/**
* Returns the raw JSON value of [logos].
*
@@ -456,7 +438,6 @@ private constructor(
private var colors: JsonField>? = null
private var description: JsonField = JsonMissing.of()
private var domain: JsonField = JsonMissing.of()
- private var fonts: JsonField>? = null
private var logos: JsonField>? = null
private var slogan: JsonField = JsonMissing.of()
private var socials: JsonField>? = null
@@ -471,7 +452,6 @@ private constructor(
colors = brand.colors.map { it.toMutableList() }
description = brand.description
domain = brand.domain
- fonts = brand.fonts.map { it.toMutableList() }
logos = brand.logos.map { it.toMutableList() }
slogan = brand.slogan
socials = brand.socials.map { it.toMutableList() }
@@ -570,32 +550,6 @@ private constructor(
*/
fun domain(domain: JsonField) = apply { this.domain = domain }
- /** An array of fonts used by the brand's website */
- fun fonts(fonts: List) = fonts(JsonField.of(fonts))
-
- /**
- * Sets [Builder.fonts] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fonts] with a well-typed `List` value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun fonts(fonts: JsonField>) = apply {
- this.fonts = fonts.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Font] to [fonts].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addFont(font: Font) = apply {
- fonts =
- (fonts ?: JsonField.of(mutableListOf())).also {
- checkKnown("fonts", it).add(font)
- }
- }
-
/** An array of logos associated with the brand */
fun logos(logos: List) = logos(JsonField.of(logos))
@@ -718,7 +672,6 @@ private constructor(
(colors ?: JsonMissing.of()).map { it.toImmutable() },
description,
domain,
- (fonts ?: JsonMissing.of()).map { it.toImmutable() },
(logos ?: JsonMissing.of()).map { it.toImmutable() },
slogan,
(socials ?: JsonMissing.of()).map { it.toImmutable() },
@@ -740,7 +693,6 @@ private constructor(
colors().ifPresent { it.forEach { it.validate() } }
description()
domain()
- fonts().ifPresent { it.forEach { it.validate() } }
logos().ifPresent { it.forEach { it.validate() } }
slogan()
socials().ifPresent { it.forEach { it.validate() } }
@@ -770,7 +722,6 @@ private constructor(
(colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (description.asKnown().isPresent) 1 else 0) +
(if (domain.asKnown().isPresent) 1 else 0) +
- (fonts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (slogan.asKnown().isPresent) 1 else 0) +
(socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
@@ -1949,183 +1900,6 @@ private constructor(
"Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}"
}
- class Font
- private constructor(
- private val name: JsonField,
- private val usage: JsonField,
- private val additionalProperties: MutableMap,
- ) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
- @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(),
- ) : this(name, usage, mutableMapOf())
-
- /**
- * Name of the font
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g.
- * if the server responded with an unexpected value).
- */
- fun name(): Optional = name.getOptional("name")
-
- /**
- * Usage of the font, e.g., 'title', 'body', 'button'
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g.
- * if the server responded with an unexpected value).
- */
- fun usage(): Optional = usage.getOptional("usage")
-
- /**
- * Returns the raw JSON value of [name].
- *
- * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
-
- /**
- * Returns the raw JSON value of [usage].
- *
- * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /** Returns a mutable builder for constructing an instance of [Font]. */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Font]. */
- class Builder internal constructor() {
-
- private var name: JsonField = JsonMissing.of()
- private var usage: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(font: Font) = apply {
- name = font.name
- usage = font.usage
- additionalProperties = font.additionalProperties.toMutableMap()
- }
-
- /** Name of the font */
- fun name(name: String) = name(JsonField.of(name))
-
- /**
- * Sets [Builder.name] to an arbitrary JSON value.
- *
- * You should usually call [Builder.name] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun name(name: JsonField) = apply { this.name = name }
-
- /** Usage of the font, e.g., 'title', 'body', 'button' */
- fun usage(usage: String) = usage(JsonField.of(usage))
-
- /**
- * Sets [Builder.usage] to an arbitrary JSON value.
- *
- * You should usually call [Builder.usage] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun usage(usage: JsonField) = apply { this.usage = usage }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) =
- apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply {
- additionalProperties.remove(key)
- }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [Font].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- */
- fun build(): Font = Font(name, usage, additionalProperties.toMutableMap())
- }
-
- private var validated: Boolean = false
-
- fun validate(): Font = apply {
- if (validated) {
- return@apply
- }
-
- name()
- usage()
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: BrandDevInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object
- * recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (name.asKnown().isPresent) 1 else 0) + (if (usage.asKnown().isPresent) 1 else 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Font && name == other.name && usage == other.usage && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(name, usage, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Font{name=$name, usage=$usage, additionalProperties=$additionalProperties}"
- }
-
class Logo
private constructor(
private val colors: JsonField>,
@@ -3163,17 +2937,17 @@ private constructor(
return true
}
- return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && fonts == other.fonts && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */
+ return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */
}
/* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, fonts, logos, slogan, socials, stock, title, additionalProperties) }
+ private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, logos, slogan, socials, stock, title, additionalProperties) }
/* spotless:on */
override fun hashCode(): Int = hashCode
override fun toString() =
- "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, fonts=$fonts, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}"
+ "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}"
}
override fun equals(other: Any?): Boolean {
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt
index e384ca9..64e9022 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandRetrieveResponse.kt
@@ -213,7 +213,6 @@ private constructor(
private val colors: JsonField>,
private val description: JsonField,
private val domain: JsonField,
- private val fonts: JsonField>,
private val logos: JsonField>,
private val slogan: JsonField,
private val socials: JsonField>,
@@ -235,7 +234,6 @@ private constructor(
@ExcludeMissing
description: JsonField = JsonMissing.of(),
@JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(),
- @JsonProperty("fonts") @ExcludeMissing fonts: JsonField> = JsonMissing.of(),
@JsonProperty("logos") @ExcludeMissing logos: JsonField> = JsonMissing.of(),
@JsonProperty("slogan") @ExcludeMissing slogan: JsonField = JsonMissing.of(),
@JsonProperty("socials")
@@ -249,7 +247,6 @@ private constructor(
colors,
description,
domain,
- fonts,
logos,
slogan,
socials,
@@ -298,15 +295,6 @@ private constructor(
*/
fun domain(): Optional = domain.getOptional("domain")
- /**
- * An array of fonts used by the brand's website. NOTE: This is deprecated and will be
- * removed in the future. Please migrate to the styleguide API.
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if
- * the server responded with an unexpected value).
- */
- fun fonts(): Optional> = fonts.getOptional("fonts")
-
/**
* An array of logos associated with the brand
*
@@ -386,13 +374,6 @@ private constructor(
*/
@JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain
- /**
- * Returns the raw JSON value of [fonts].
- *
- * Unlike [fonts], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("fonts") @ExcludeMissing fun _fonts(): JsonField> = fonts
-
/**
* Returns the raw JSON value of [logos].
*
@@ -454,7 +435,6 @@ private constructor(
private var colors: JsonField>? = null
private var description: JsonField = JsonMissing.of()
private var domain: JsonField = JsonMissing.of()
- private var fonts: JsonField>? = null
private var logos: JsonField>? = null
private var slogan: JsonField = JsonMissing.of()
private var socials: JsonField>? = null
@@ -469,7 +449,6 @@ private constructor(
colors = brand.colors.map { it.toMutableList() }
description = brand.description
domain = brand.domain
- fonts = brand.fonts.map { it.toMutableList() }
logos = brand.logos.map { it.toMutableList() }
slogan = brand.slogan
socials = brand.socials.map { it.toMutableList() }
@@ -568,35 +547,6 @@ private constructor(
*/
fun domain(domain: JsonField) = apply { this.domain = domain }
- /**
- * An array of fonts used by the brand's website. NOTE: This is deprecated and will be
- * removed in the future. Please migrate to the styleguide API.
- */
- fun fonts(fonts: List) = fonts(JsonField.of(fonts))
-
- /**
- * Sets [Builder.fonts] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fonts] with a well-typed `List` value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun fonts(fonts: JsonField>) = apply {
- this.fonts = fonts.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Font] to [fonts].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addFont(font: Font) = apply {
- fonts =
- (fonts ?: JsonField.of(mutableListOf())).also {
- checkKnown("fonts", it).add(font)
- }
- }
-
/** An array of logos associated with the brand */
fun logos(logos: List) = logos(JsonField.of(logos))
@@ -719,7 +669,6 @@ private constructor(
(colors ?: JsonMissing.of()).map { it.toImmutable() },
description,
domain,
- (fonts ?: JsonMissing.of()).map { it.toImmutable() },
(logos ?: JsonMissing.of()).map { it.toImmutable() },
slogan,
(socials ?: JsonMissing.of()).map { it.toImmutable() },
@@ -741,7 +690,6 @@ private constructor(
colors().ifPresent { it.forEach { it.validate() } }
description()
domain()
- fonts().ifPresent { it.forEach { it.validate() } }
logos().ifPresent { it.forEach { it.validate() } }
slogan()
socials().ifPresent { it.forEach { it.validate() } }
@@ -771,7 +719,6 @@ private constructor(
(colors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (description.asKnown().isPresent) 1 else 0) +
(if (domain.asKnown().isPresent) 1 else 0) +
- (fonts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(logos.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
(if (slogan.asKnown().isPresent) 1 else 0) +
(socials.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
@@ -1950,183 +1897,6 @@ private constructor(
"Color{hex=$hex, name=$name, additionalProperties=$additionalProperties}"
}
- class Font
- private constructor(
- private val name: JsonField,
- private val usage: JsonField,
- private val additionalProperties: MutableMap,
- ) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
- @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(),
- ) : this(name, usage, mutableMapOf())
-
- /**
- * Name of the font
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g.
- * if the server responded with an unexpected value).
- */
- fun name(): Optional = name.getOptional("name")
-
- /**
- * Usage of the font, e.g., 'title', 'body', 'button'
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g.
- * if the server responded with an unexpected value).
- */
- fun usage(): Optional = usage.getOptional("usage")
-
- /**
- * Returns the raw JSON value of [name].
- *
- * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
-
- /**
- * Returns the raw JSON value of [usage].
- *
- * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /** Returns a mutable builder for constructing an instance of [Font]. */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Font]. */
- class Builder internal constructor() {
-
- private var name: JsonField = JsonMissing.of()
- private var usage: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(font: Font) = apply {
- name = font.name
- usage = font.usage
- additionalProperties = font.additionalProperties.toMutableMap()
- }
-
- /** Name of the font */
- fun name(name: String) = name(JsonField.of(name))
-
- /**
- * Sets [Builder.name] to an arbitrary JSON value.
- *
- * You should usually call [Builder.name] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun name(name: JsonField) = apply { this.name = name }
-
- /** Usage of the font, e.g., 'title', 'body', 'button' */
- fun usage(usage: String) = usage(JsonField.of(usage))
-
- /**
- * Sets [Builder.usage] to an arbitrary JSON value.
- *
- * You should usually call [Builder.usage] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun usage(usage: JsonField) = apply { this.usage = usage }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) =
- apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply {
- additionalProperties.remove(key)
- }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [Font].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- */
- fun build(): Font = Font(name, usage, additionalProperties.toMutableMap())
- }
-
- private var validated: Boolean = false
-
- fun validate(): Font = apply {
- if (validated) {
- return@apply
- }
-
- name()
- usage()
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: BrandDevInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object
- * recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (name.asKnown().isPresent) 1 else 0) + (if (usage.asKnown().isPresent) 1 else 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Font && name == other.name && usage == other.usage && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(name, usage, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Font{name=$name, usage=$usage, additionalProperties=$additionalProperties}"
- }
-
class Logo
private constructor(
private val colors: JsonField>,
@@ -3164,17 +2934,17 @@ private constructor(
return true
}
- return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && fonts == other.fonts && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */
+ return /* spotless:off */ other is Brand && address == other.address && backdrops == other.backdrops && colors == other.colors && description == other.description && domain == other.domain && logos == other.logos && slogan == other.slogan && socials == other.socials && stock == other.stock && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */
}
/* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, fonts, logos, slogan, socials, stock, title, additionalProperties) }
+ private val hashCode: Int by lazy { Objects.hash(address, backdrops, colors, description, domain, logos, slogan, socials, stock, title, additionalProperties) }
/* spotless:on */
override fun hashCode(): Int = hashCode
override fun toString() =
- "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, fonts=$fonts, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}"
+ "Brand{address=$address, backdrops=$backdrops, colors=$colors, description=$description, domain=$domain, logos=$logos, slogan=$slogan, socials=$socials, stock=$stock, title=$title, additionalProperties=$additionalProperties}"
}
override fun equals(other: Any?): Boolean {
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchParams.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchParams.kt
deleted file mode 100644
index 54b1c3e..0000000
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchParams.kt
+++ /dev/null
@@ -1,229 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.branddev.api.models.brand
-
-import com.branddev.api.core.Params
-import com.branddev.api.core.checkRequired
-import com.branddev.api.core.http.Headers
-import com.branddev.api.core.http.QueryParams
-import java.util.Objects
-import java.util.Optional
-import kotlin.jvm.optionals.getOrNull
-
-/** Search brands by query */
-class BrandSearchParams
-private constructor(
- private val query: String,
- private val timeoutMs: Long?,
- private val additionalHeaders: Headers,
- private val additionalQueryParams: QueryParams,
-) : Params {
-
- /** Query string to search brands */
- fun query(): String = query
-
- /**
- * Optional timeout in milliseconds for the request. If the request takes longer than this
- * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5
- * minutes).
- */
- fun timeoutMs(): Optional = Optional.ofNullable(timeoutMs)
-
- fun _additionalHeaders(): Headers = additionalHeaders
-
- fun _additionalQueryParams(): QueryParams = additionalQueryParams
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [BrandSearchParams].
- *
- * The following fields are required:
- * ```java
- * .query()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [BrandSearchParams]. */
- class Builder internal constructor() {
-
- private var query: String? = null
- private var timeoutMs: Long? = null
- private var additionalHeaders: Headers.Builder = Headers.builder()
- private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
-
- @JvmSynthetic
- internal fun from(brandSearchParams: BrandSearchParams) = apply {
- query = brandSearchParams.query
- timeoutMs = brandSearchParams.timeoutMs
- additionalHeaders = brandSearchParams.additionalHeaders.toBuilder()
- additionalQueryParams = brandSearchParams.additionalQueryParams.toBuilder()
- }
-
- /** Query string to search brands */
- fun query(query: String) = apply { this.query = query }
-
- /**
- * Optional timeout in milliseconds for the request. If the request takes longer than this
- * value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5
- * minutes).
- */
- fun timeoutMs(timeoutMs: Long?) = apply { this.timeoutMs = timeoutMs }
-
- /**
- * Alias for [Builder.timeoutMs].
- *
- * This unboxed primitive overload exists for backwards compatibility.
- */
- fun timeoutMs(timeoutMs: Long) = timeoutMs(timeoutMs as Long?)
-
- /** Alias for calling [Builder.timeoutMs] with `timeoutMs.orElse(null)`. */
- fun timeoutMs(timeoutMs: Optional) = timeoutMs(timeoutMs.getOrNull())
-
- fun additionalHeaders(additionalHeaders: Headers) = apply {
- this.additionalHeaders.clear()
- putAllAdditionalHeaders(additionalHeaders)
- }
-
- fun additionalHeaders(additionalHeaders: Map>) = apply {
- this.additionalHeaders.clear()
- putAllAdditionalHeaders(additionalHeaders)
- }
-
- fun putAdditionalHeader(name: String, value: String) = apply {
- additionalHeaders.put(name, value)
- }
-
- fun putAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.put(name, values)
- }
-
- fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
- this.additionalHeaders.putAll(additionalHeaders)
- }
-
- fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- this.additionalHeaders.putAll(additionalHeaders)
- }
-
- fun replaceAdditionalHeaders(name: String, value: String) = apply {
- additionalHeaders.replace(name, value)
- }
-
- fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
- additionalHeaders.replace(name, values)
- }
-
- fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
- this.additionalHeaders.replaceAll(additionalHeaders)
- }
-
- fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
- this.additionalHeaders.replaceAll(additionalHeaders)
- }
-
- fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
-
- fun removeAllAdditionalHeaders(names: Set) = apply {
- additionalHeaders.removeAll(names)
- }
-
- fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
- this.additionalQueryParams.clear()
- putAllAdditionalQueryParams(additionalQueryParams)
- }
-
- fun additionalQueryParams(additionalQueryParams: Map>) = apply {
- this.additionalQueryParams.clear()
- putAllAdditionalQueryParams(additionalQueryParams)
- }
-
- fun putAdditionalQueryParam(key: String, value: String) = apply {
- additionalQueryParams.put(key, value)
- }
-
- fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.put(key, values)
- }
-
- fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
- this.additionalQueryParams.putAll(additionalQueryParams)
- }
-
- fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
- apply {
- this.additionalQueryParams.putAll(additionalQueryParams)
- }
-
- fun replaceAdditionalQueryParams(key: String, value: String) = apply {
- additionalQueryParams.replace(key, value)
- }
-
- fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
- additionalQueryParams.replace(key, values)
- }
-
- fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
- this.additionalQueryParams.replaceAll(additionalQueryParams)
- }
-
- fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
- apply {
- this.additionalQueryParams.replaceAll(additionalQueryParams)
- }
-
- fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
-
- fun removeAllAdditionalQueryParams(keys: Set) = apply {
- additionalQueryParams.removeAll(keys)
- }
-
- /**
- * Returns an immutable instance of [BrandSearchParams].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .query()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): BrandSearchParams =
- BrandSearchParams(
- checkRequired("query", query),
- timeoutMs,
- additionalHeaders.build(),
- additionalQueryParams.build(),
- )
- }
-
- override fun _headers(): Headers = additionalHeaders
-
- override fun _queryParams(): QueryParams =
- QueryParams.builder()
- .apply {
- put("query", query)
- timeoutMs?.let { put("timeoutMS", it.toString()) }
- putAll(additionalQueryParams)
- }
- .build()
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is BrandSearchParams && query == other.query && timeoutMs == other.timeoutMs && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
- }
-
- override fun hashCode(): Int = /* spotless:off */ Objects.hash(query, timeoutMs, additionalHeaders, additionalQueryParams) /* spotless:on */
-
- override fun toString() =
- "BrandSearchParams{query=$query, timeoutMs=$timeoutMs, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
-}
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchResponse.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchResponse.kt
deleted file mode 100644
index a332456..0000000
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/models/brand/BrandSearchResponse.kt
+++ /dev/null
@@ -1,221 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.branddev.api.models.brand
-
-import com.branddev.api.core.ExcludeMissing
-import com.branddev.api.core.JsonField
-import com.branddev.api.core.JsonMissing
-import com.branddev.api.core.JsonValue
-import com.branddev.api.errors.BrandDevInvalidDataException
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import java.util.Collections
-import java.util.Objects
-import java.util.Optional
-
-class BrandSearchResponse
-private constructor(
- private val domain: JsonField,
- private val logo: JsonField,
- private val title: JsonField,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("domain") @ExcludeMissing domain: JsonField = JsonMissing.of(),
- @JsonProperty("logo") @ExcludeMissing logo: JsonField = JsonMissing.of(),
- @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(),
- ) : this(domain, logo, title, mutableMapOf())
-
- /**
- * Domain name of the brand
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun domain(): Optional = domain.getOptional("domain")
-
- /**
- * URL of the brand's logo
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun logo(): Optional = logo.getOptional("logo")
-
- /**
- * Title or name of the brand
- *
- * @throws BrandDevInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun title(): Optional = title.getOptional("title")
-
- /**
- * Returns the raw JSON value of [domain].
- *
- * Unlike [domain], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("domain") @ExcludeMissing fun _domain(): JsonField = domain
-
- /**
- * Returns the raw JSON value of [logo].
- *
- * Unlike [logo], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("logo") @ExcludeMissing fun _logo(): JsonField = logo
-
- /**
- * Returns the raw JSON value of [title].
- *
- * Unlike [title], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /** Returns a mutable builder for constructing an instance of [BrandSearchResponse]. */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [BrandSearchResponse]. */
- class Builder internal constructor() {
-
- private var domain: JsonField = JsonMissing.of()
- private var logo: JsonField = JsonMissing.of()
- private var title: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(brandSearchResponse: BrandSearchResponse) = apply {
- domain = brandSearchResponse.domain
- logo = brandSearchResponse.logo
- title = brandSearchResponse.title
- additionalProperties = brandSearchResponse.additionalProperties.toMutableMap()
- }
-
- /** Domain name of the brand */
- fun domain(domain: String) = domain(JsonField.of(domain))
-
- /**
- * Sets [Builder.domain] to an arbitrary JSON value.
- *
- * You should usually call [Builder.domain] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun domain(domain: JsonField) = apply { this.domain = domain }
-
- /** URL of the brand's logo */
- fun logo(logo: String) = logo(JsonField.of(logo))
-
- /**
- * Sets [Builder.logo] to an arbitrary JSON value.
- *
- * You should usually call [Builder.logo] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun logo(logo: JsonField) = apply { this.logo = logo }
-
- /** Title or name of the brand */
- fun title(title: String) = title(JsonField.of(title))
-
- /**
- * Sets [Builder.title] to an arbitrary JSON value.
- *
- * You should usually call [Builder.title] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun title(title: JsonField) = apply { this.title = title }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [BrandSearchResponse].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- */
- fun build(): BrandSearchResponse =
- BrandSearchResponse(domain, logo, title, additionalProperties.toMutableMap())
- }
-
- private var validated: Boolean = false
-
- fun validate(): BrandSearchResponse = apply {
- if (validated) {
- return@apply
- }
-
- domain()
- logo()
- title()
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: BrandDevInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (domain.asKnown().isPresent) 1 else 0) +
- (if (logo.asKnown().isPresent) 1 else 0) +
- (if (title.asKnown().isPresent) 1 else 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is BrandSearchResponse && domain == other.domain && logo == other.logo && title == other.title && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(domain, logo, title, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "BrandSearchResponse{domain=$domain, logo=$logo, title=$title, additionalProperties=$additionalProperties}"
-}
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt
index 2336ea9..02dd1d5 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsync.kt
@@ -21,8 +21,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams
import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse
import com.branddev.api.models.brand.BrandScreenshotParams
import com.branddev.api.models.brand.BrandScreenshotResponse
-import com.branddev.api.models.brand.BrandSearchParams
-import com.branddev.api.models.brand.BrandSearchResponse
import com.branddev.api.models.brand.BrandStyleguideParams
import com.branddev.api.models.brand.BrandStyleguideResponse
import java.util.concurrent.CompletableFuture
@@ -147,16 +145,6 @@ interface BrandServiceAsync {
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture
- /** Search brands by query */
- fun search(params: BrandSearchParams): CompletableFuture> =
- search(params, RequestOptions.none())
-
- /** @see [search] */
- fun search(
- params: BrandSearchParams,
- requestOptions: RequestOptions = RequestOptions.none(),
- ): CompletableFuture>
-
/**
* Beta feature: Automatically extract comprehensive design system information from a brand's
* website including colors, typography, spacing, shadows, and UI components.
@@ -302,21 +290,6 @@ interface BrandServiceAsync {
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
- /**
- * Returns a raw HTTP response for `get /brand/search`, but is otherwise the same as
- * [BrandServiceAsync.search].
- */
- fun search(
- params: BrandSearchParams
- ): CompletableFuture>> =
- search(params, RequestOptions.none())
-
- /** @see [search] */
- fun search(
- params: BrandSearchParams,
- requestOptions: RequestOptions = RequestOptions.none(),
- ): CompletableFuture>>
-
/**
* Returns a raw HTTP response for `get /brand/styleguide`, but is otherwise the same as
* [BrandServiceAsync.styleguide].
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt
index 03834cb..e032da1 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/async/BrandServiceAsyncImpl.kt
@@ -3,13 +3,13 @@
package com.branddev.api.services.async
import com.branddev.api.core.ClientOptions
-import com.branddev.api.core.JsonValue
import com.branddev.api.core.RequestOptions
+import com.branddev.api.core.handlers.errorBodyHandler
import com.branddev.api.core.handlers.errorHandler
import com.branddev.api.core.handlers.jsonHandler
-import com.branddev.api.core.handlers.withErrorHandler
import com.branddev.api.core.http.HttpMethod
import com.branddev.api.core.http.HttpRequest
+import com.branddev.api.core.http.HttpResponse
import com.branddev.api.core.http.HttpResponse.Handler
import com.branddev.api.core.http.HttpResponseFor
import com.branddev.api.core.http.json
@@ -31,8 +31,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams
import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse
import com.branddev.api.models.brand.BrandScreenshotParams
import com.branddev.api.models.brand.BrandScreenshotResponse
-import com.branddev.api.models.brand.BrandSearchParams
-import com.branddev.api.models.brand.BrandSearchResponse
import com.branddev.api.models.brand.BrandStyleguideParams
import com.branddev.api.models.brand.BrandStyleguideResponse
import java.util.concurrent.CompletableFuture
@@ -106,13 +104,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
// get /brand/screenshot
withRawResponse().screenshot(params, requestOptions).thenApply { it.parse() }
- override fun search(
- params: BrandSearchParams,
- requestOptions: RequestOptions,
- ): CompletableFuture> =
- // get /brand/search
- withRawResponse().search(params, requestOptions).thenApply { it.parse() }
-
override fun styleguide(
params: BrandStyleguideParams,
requestOptions: RequestOptions,
@@ -123,7 +114,8 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
BrandServiceAsync.WithRawResponse {
- private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper)
+ private val errorHandler: Handler =
+ errorHandler(errorBodyHandler(clientOptions.jsonMapper))
override fun withOptions(
modifier: Consumer
@@ -134,7 +126,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val retrieveHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun retrieve(
params: BrandRetrieveParams,
@@ -151,7 +142,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { retrieveHandler.handle(it) }
.also {
@@ -165,7 +156,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val aiQueryHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun aiQuery(
params: BrandAiQueryParams,
@@ -183,7 +173,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { aiQueryHandler.handle(it) }
.also {
@@ -197,7 +187,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val identifyFromTransactionHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun identifyFromTransaction(
params: BrandIdentifyFromTransactionParams,
@@ -214,7 +203,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { identifyFromTransactionHandler.handle(it) }
.also {
@@ -228,7 +217,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val prefetchHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun prefetch(
params: BrandPrefetchParams,
@@ -246,7 +234,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { prefetchHandler.handle(it) }
.also {
@@ -260,7 +248,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val retrieveByTickerHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun retrieveByTicker(
params: BrandRetrieveByTickerParams,
@@ -277,7 +264,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { retrieveByTickerHandler.handle(it) }
.also {
@@ -291,7 +278,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val retrieveNaicsHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun retrieveNaics(
params: BrandRetrieveNaicsParams,
@@ -308,7 +294,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { retrieveNaicsHandler.handle(it) }
.also {
@@ -322,7 +308,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val retrieveSimplifiedHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun retrieveSimplified(
params: BrandRetrieveSimplifiedParams,
@@ -339,7 +324,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { retrieveSimplifiedHandler.handle(it) }
.also {
@@ -353,7 +338,6 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
private val screenshotHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun screenshot(
params: BrandScreenshotParams,
@@ -370,7 +354,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { screenshotHandler.handle(it) }
.also {
@@ -382,40 +366,8 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
}
}
- private val searchHandler: Handler> =
- jsonHandler>(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
-
- override fun search(
- params: BrandSearchParams,
- requestOptions: RequestOptions,
- ): CompletableFuture>> {
- val request =
- HttpRequest.builder()
- .method(HttpMethod.GET)
- .baseUrl(clientOptions.baseUrl())
- .addPathSegments("brand", "search")
- .build()
- .prepareAsync(clientOptions, params)
- val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
- return request
- .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
- .thenApply { response ->
- response.parseable {
- response
- .use { searchHandler.handle(it) }
- .also {
- if (requestOptions.responseValidation!!) {
- it.forEach { it.validate() }
- }
- }
- }
- }
- }
-
private val styleguideHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun styleguide(
params: BrandStyleguideParams,
@@ -432,7 +384,7 @@ class BrandServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
- response.parseable {
+ errorHandler.handle(response).parseable {
response
.use { styleguideHandler.handle(it) }
.also {
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt
index d34e663..d5f473c 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandService.kt
@@ -21,8 +21,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams
import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse
import com.branddev.api.models.brand.BrandScreenshotParams
import com.branddev.api.models.brand.BrandScreenshotResponse
-import com.branddev.api.models.brand.BrandSearchParams
-import com.branddev.api.models.brand.BrandSearchResponse
import com.branddev.api.models.brand.BrandStyleguideParams
import com.branddev.api.models.brand.BrandStyleguideResponse
import com.google.errorprone.annotations.MustBeClosed
@@ -141,16 +139,6 @@ interface BrandService {
requestOptions: RequestOptions = RequestOptions.none(),
): BrandScreenshotResponse
- /** Search brands by query */
- fun search(params: BrandSearchParams): List =
- search(params, RequestOptions.none())
-
- /** @see [search] */
- fun search(
- params: BrandSearchParams,
- requestOptions: RequestOptions = RequestOptions.none(),
- ): List
-
/**
* Beta feature: Automatically extract comprehensive design system information from a brand's
* website including colors, typography, spacing, shadows, and UI components.
@@ -302,21 +290,6 @@ interface BrandService {
requestOptions: RequestOptions = RequestOptions.none(),
): HttpResponseFor
- /**
- * Returns a raw HTTP response for `get /brand/search`, but is otherwise the same as
- * [BrandService.search].
- */
- @MustBeClosed
- fun search(params: BrandSearchParams): HttpResponseFor> =
- search(params, RequestOptions.none())
-
- /** @see [search] */
- @MustBeClosed
- fun search(
- params: BrandSearchParams,
- requestOptions: RequestOptions = RequestOptions.none(),
- ): HttpResponseFor>
-
/**
* Returns a raw HTTP response for `get /brand/styleguide`, but is otherwise the same as
* [BrandService.styleguide].
diff --git a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt
index 8c64aad..60fcddd 100644
--- a/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt
+++ b/brand-dev-java-core/src/main/kotlin/com/branddev/api/services/blocking/BrandServiceImpl.kt
@@ -3,13 +3,13 @@
package com.branddev.api.services.blocking
import com.branddev.api.core.ClientOptions
-import com.branddev.api.core.JsonValue
import com.branddev.api.core.RequestOptions
+import com.branddev.api.core.handlers.errorBodyHandler
import com.branddev.api.core.handlers.errorHandler
import com.branddev.api.core.handlers.jsonHandler
-import com.branddev.api.core.handlers.withErrorHandler
import com.branddev.api.core.http.HttpMethod
import com.branddev.api.core.http.HttpRequest
+import com.branddev.api.core.http.HttpResponse
import com.branddev.api.core.http.HttpResponse.Handler
import com.branddev.api.core.http.HttpResponseFor
import com.branddev.api.core.http.json
@@ -31,8 +31,6 @@ import com.branddev.api.models.brand.BrandRetrieveSimplifiedParams
import com.branddev.api.models.brand.BrandRetrieveSimplifiedResponse
import com.branddev.api.models.brand.BrandScreenshotParams
import com.branddev.api.models.brand.BrandScreenshotResponse
-import com.branddev.api.models.brand.BrandSearchParams
-import com.branddev.api.models.brand.BrandSearchResponse
import com.branddev.api.models.brand.BrandStyleguideParams
import com.branddev.api.models.brand.BrandStyleguideResponse
import java.util.function.Consumer
@@ -105,13 +103,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
// get /brand/screenshot
withRawResponse().screenshot(params, requestOptions).parse()
- override fun search(
- params: BrandSearchParams,
- requestOptions: RequestOptions,
- ): List =
- // get /brand/search
- withRawResponse().search(params, requestOptions).parse()
-
override fun styleguide(
params: BrandStyleguideParams,
requestOptions: RequestOptions,
@@ -122,7 +113,8 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
BrandService.WithRawResponse {
- private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper)
+ private val errorHandler: Handler =
+ errorHandler(errorBodyHandler(clientOptions.jsonMapper))
override fun withOptions(
modifier: Consumer
@@ -133,7 +125,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
private val retrieveHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun retrieve(
params: BrandRetrieveParams,
@@ -148,7 +139,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
.prepare(clientOptions, params)
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
val response = clientOptions.httpClient.execute(request, requestOptions)
- return response.parseable {
+ return errorHandler.handle(response).parseable {
response
.use { retrieveHandler.handle(it) }
.also {
@@ -161,7 +152,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
private val aiQueryHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun aiQuery(
params: BrandAiQueryParams,
@@ -177,7 +167,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
.prepare(clientOptions, params)
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
val response = clientOptions.httpClient.execute(request, requestOptions)
- return response.parseable {
+ return errorHandler.handle(response).parseable {
response
.use { aiQueryHandler.handle(it) }
.also {
@@ -190,7 +180,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
private val identifyFromTransactionHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun identifyFromTransaction(
params: BrandIdentifyFromTransactionParams,
@@ -205,7 +194,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
.prepare(clientOptions, params)
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
val response = clientOptions.httpClient.execute(request, requestOptions)
- return response.parseable {
+ return errorHandler.handle(response).parseable {
response
.use { identifyFromTransactionHandler.handle(it) }
.also {
@@ -218,7 +207,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
private val prefetchHandler: Handler =
jsonHandler(clientOptions.jsonMapper)
- .withErrorHandler(errorHandler)
override fun prefetch(
params: BrandPrefetchParams,
@@ -234,7 +222,7 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
.prepare(clientOptions, params)
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
val response = clientOptions.httpClient.execute(request, requestOptions)
- return response.parseable {
+ return errorHandler.handle(response).parseable {
response
.use { prefetchHandler.handle(it) }
.also {
@@ -247,7 +235,6 @@ class BrandServiceImpl internal constructor(private val clientOptions: ClientOpt
private val retrieveByTickerHandler: Handler =
jsonHandler